I have worked with computer graphics for many years – this has been catalysed by Noel’s discussion of the Algorithm puzzles

  1. Noel OBoyle Says:
    November 30th, 2006 at 1:59 pm eI would be *very* impressed if you could figure out the solution without running the program. Try coding it – a picture tells a thousand words. :-)
  2. pm286 Says:
    November 30th, 2006 at 2:55 pm e(3) All right. I have to decide yet again what graphics system I should aim for – GTK, Swing, or even SVG.
    My latest guess is a Cantor set of some sort (perhaps a Sierpinski gasket) with an empty triangle in the middle
  3. Noel OBoyle Says:
    November 30th, 2006 at 5:44 pm eIn the old days, this would take 5 minutes on a BBC to code up and run. Even in Windows with Qbasic, it was easy. The barrier is higher now…Python requires an additional module such as PyGame.

This brings back lots of memories. I remember reading a strange report in (I think) nature about a mysterious function (later to be called the Mandelbrot set). It’s very simple – takes about 5 lines of code. So I set it up on the BBC. (For non-UK readers, in the eighties a wonderful home and educational computer, with an excellent mix of operating system, assembler, graphics and Basic interpreter (though “Basic” doesn’t do it credit).
Anyway I saw this function and wrote a little program to iterate. I ran it and couldn’t see anything special. So I thought I needed a finer grid. It was going to take about 12 hours to draw the picture (not the drawing speed – the iterations through the complex numbers). I didn’t expect but left it on overnight. I came in in the morning, having forgotten that I’d left it on, and got one of the wow! factors of my life:
mandelbrot.png (Thanks, Wikipedia)
I think mine was in monochrome, but still wow!
The great thing about the Beeb was that you could just sit down and run the graphics. That was also true on the AppleII (my first personal machine – well actually the lab’s but all mine!). Now you can’t. If I want to draw some graphics what do I do?
For a quick lash up I might generate an SVG and then view it – but that’s a bit clunky. But otherwise? How do I type move and draw on the commandline? It’s got worse.
I’ve been through the whole range of graphics software – Tek4010, Calcomp plotter, AppleII, Megatek, Evans and Sutherland PS300, BBC, VT200, SGI-GL, GKS, PHIGS, OpenGL, TK, Java AWT1.02, Swing, Java3D, Swing… and some I’ve happily forgotten. If I want reasonable high-quality interactive graphics I suppose I’d choose Swing. I hate Swing. Typical error message “You cannot add a JPanel to JFrame, you must add to a JContentPane” – absurd! The logic is clear only to the authors (if anyone). If some meaningless intermediate object is required, why can’t the software add it? And you have to remember when to use pack() and show() and …The one I remember with most fondness was TK – well ahead of its time.
So I can’t answer Noel’s problem in 5 minutes – it’s half a day or downloading libraries and working out how to use them. Or not. SVG is great, but I can’t just play with it. And I know that I and my colleagues need to start using some graphics. Where should we start…

This entry was posted in programming for scientists. Bookmark the permalink.

2 Responses to Graphics

  1. Dan Wright says:

    Excellent points. I fondly remember doing my first graphics stuff ever with Logo on an AppleII. I think many prospective nerds are missing some great experience with hardware and actually UNDERSTANDING how computers work since doing this kind of messing is all-but-impossible these days.
    As far as Tk goes, though, you could still use it, and it might just be the easiest thing available. If you’re on a UNIX-y machine (MacOSX included) with Tcl/Tk installed just run “wish” and then mess with a canvas object:
    % canvas .c
    % pack .c
    % .c create oval 10 10 100 100
    % .c create line 10 10 200 200
    Poof, simple drawing canvas, almost as easy as the good old days. You see your fiddling appear right when you type it in, too!
    Despite the drawbacks of Tcl/Tk (i.e., calling a “programming language” is probably being a bit charitable), it’s great for rapid prototyping and integrating scripted code into C apps. For an obnoxiously huge example, see:
    (yes, this is a project I’m involved with).
    PS: If I get the web server un-broken on my web host, I’ll probably repost this as an actual blog entry there, since it’s gotten a lot longer then expected…

  2. Noel OBoyle says:

    David Brin argued that now that Basic isn’t easily available, it’s harder to pick up programming as a kid: I’m not sure whether I agree, but he argues very well. (And yes, this is the same David Brin who writes science fiction novels).
    BTW, I recommend Python and PyGame for the above problem; although if you don’t already know Python it will take the same length of time overall (i.e. half a day).

Leave a Reply

Your email address will not be published. Required fields are marked *