## Mandelbrot Renderer

Just open-sourced my Mandelbrot renderer written in Love2D and Lua.

Find it here.

Just open-sourced my Mandelbrot renderer written in Love2D and Lua.

Find it here.

Exam revision gets stale very fast. There’s only really one way to remedy this; do something more enjoyable but completely unrelated and useless. Courtesy of my own procrastination I present:

Mandelbrots. Yeah, I know there are already plenty of Mandelbrot explanations online, but there are also plenty of people scoffing at old friends’ Facebook updates and that’s getting boring. Really, the secret to conquering procrastination is to not bother. Instead, make productive use of it doing something interesting.

The Mandelbrot is a set of coordinates which converge to zero when applying a simple recursive rule:

`Z = z^2 + C`

The X axis represents the real number line and the Y axis represents the imaginary number line. C is the point (x + i * y). Z0 can be anything. I think you can do some clever optimizations with dynamically setting Z0 but I’ll need to look into that.

Of course when you have this set, you don’t immediately get fancy colours like the masterpiece above. Instead you get something like this:

Ugly. If you want colours, you’ve got to assign a value to each pixel which is dictated by the speed at which that pixel diverges. This is calculated as a function of the amount of iterations required to calculate the pixel and the magnitude of Z after the amount of iterations required:

`v = i + 1 - log2( log2(magnitude) / 2)`

Where *i* is the amount of iterations required and *magnitude* is the… magnitude.

What a beauty.

Enjoy your procrastination, I’ve had my fun.