This is my personal attempt at recreating what is probably the most famous fractal ever: the Mandelbrot Set.
The beauty of this fractal lies in its infinite complexity emerging from a deceptively simple mathematical rule. No matter how far you zoom in, you'll always find new intricate patterns.
The Mandelbrot set is based on a surprisingly simple formula involving complex numbers:
zn+1 = zn² + c
Here's what happens:
The colorful regions show points that escape, with colors indicating the speed of escape. The black region is the actual Mandelbrot set!
The main challenge was mapping pixels to complex numbers. Each pixel (x, y) on the screen needs to correspond to a complex number c = a + bi on the complex plane.
I had to scale the pixel coordinates to fit the interesting region of the Mandelbrot set (roughly -2 to 1 on the real axis, -1.5 to 1.5 on the imaginary axis).
Another challenge was determining the escape condition: how many iterations before we decide a point has escaped? Too few iterations and you miss detail; too many and the rendering slows down significantly.