Confinity

Send Feedback      Home Page > The Tickle Trunk > Confinity

Part of the magic that draws people into programming is the incredible complexity and beauty that can result from a few instructions.  One aspect of this is the enduring popularity of "display hacks", small programs that make pretty pictures.  Such programs date back at least as far as the first graphical displays.  Here is just such a program, a slightly modified implementation of an algorithm presented in A. K. Dewdney's The Turing Omnibus [1]:

for i := 1 to width
    for j := 1 to height
        x := a + i * s / width
        y := b + j * s / height
        c := floor( x2 + y2 ) mod n
        plot( i, j, colourc )

Changing the values of s, a, b, and n will cause different images to be generated; colour refers to a list colour0, colour1, ..., colourn-1 of n different colours to use. Here is the algorithm implemented as a Java applet:

The applet requires that your browser support at least the Java 5 runtime.  If the applet doesn't work properly, this is almost certainly the problem. You can download the latest Java runtime from Sun to correct this.

If you like this kind of thing, here are some other pages on this site that make pretty pictures: Turing's reaction-diffusion model, Lindenmayer systems.

Bibliography

[1] A. K. Dewdney, The Turing Omnibus: 61 Excursions in Computer Science. Computer Science Press, pp. 3–7 (1989).

Return to Home Page    Return to Tickle Trunk    Send Feedback

May 20, 2004 — Updated February 17, 2009