Click the triangle to begin.
The year 2010 will be known for a long time as the year Benoit Mandelbrot died. He was, as I'm sure you already know, the founder of the science of Fractals. So, what better, or more fitting, way is there to commemorate his life and work than through a program to generate a fractal image. The program above does just that, building up a Sierpinski Triangle using very simple Processing.js code. Once you click the empty triangle to begin, you should see the Sierpinski Triangle start to form within a few seconds. If you leave it running for a while it should start looking quite a good representation. To restart the process, just click the triangle again.
The code is based on the random method described in the excellent book 'Introducing Fractals' by Nigel Lesmoir-Gordon, Will Rood and Ralph Edney (Icon Books Ltd, London, 2009). Basically, you click on the triangle and the position is used to calculate a start coordinate (point A). The code then randomly chooses one of the three triangle vertices, and draws a dot at the midpoint between the vertex and point A (point B). For the purposes of the next dot, point B becomes point A, and the process is repeated over and over again. If you look at the code it shouldn't be too difficult to understand, as it's very short.