I’ve added a new fractal generating function to Clisk. It’s pretty general purpose and can handle all kinds of iterative fractals.

Here’s the classic mandelbrot:

(show (viewport [-2 -1.5] [1 1.5]
(fractal
:while (v- 2 (length [x y]))
:update (v+ c [(v- (v* x x) (v* y y)) (v* 2 x y)])
:result (vplasma (v* 0.1 'i))
:bailout-result black
:max-iterations 1000)) 1024 1024)

I’m pretty happy with the little fractal DSL which is implemented using keyword arguments. You can control pretty much every aspect of the iterative procedure used to create the fractal. There are some handy shortcuts you can use in your formulae:

**x, y, z, t** – the current co-ordinates in space that gets updated in each iteration
**pos** – the current co-ordinate vector
**c – **the initial co-orinate vector (i.e. equal to **pos** on the first iteration)
**‘i –** the iteration number. Note this is a symbol, I might make this into a function in the future for convenient to avoid the quote but you need it for now

For example, by tweaking the **:result** formula you can easily create some interesting fractal patterns:

(show (viewport [-2 -1.5] [1 1.5]
(fractal
:while (v- 2 (length [x y]))
:update (v+ c [(v- (v* x x) (v* y y)) (v* 2 x y)])
:result (v* (rgb-from-hsl [(v* 0.13 'i) 0.8 0.8])
(scale 1.5 (checker black white)))
:bailout-result black
:max-iterations 1000)) 512 512)

Performance is also looking good – the image above took around 3secs to render on my machine. It’s amazing how much hardware has progressed – I still remember the days when I had to leave my Atari 800XL running overnight to get a low resolution mandelbrot image!