Thursday, March 23, 2023

Burning Mandelbrot set animation in Javascript

Years ago I've blogged about Julia fractals, I've demonstrated how these can be easily implemented in Javascript. I love to put my hands on this from time to time.

Another interesting experiment occurs when the Julia formula

x0   = coordinates of a point from the plane
xn+1 = xn * xn + c       

is changed to

x0   = 0
xn+1 = xn * xn + coordinates of a point from the plane      

This modified formula leads to the Mandelbrot set. It's one of the most amazing discoveries of the computer science and has many interesting properties.

The only subtle detail that can be improved here is that there's only one Mandlelbrot set, there's no obvious way to make an animation here. With Julias - the animation is created when the c parameter is modified somehow, for example using the Lissajous formula, as shown in my old blog entry.

Can we somehow animate Mandelbrot? Yes! Just change the formula slightly

x0   = c
xn+1 = xn * xn + coordinates of a point from the plane      

so instead of starting from 0, we start from a constant c that again can be modified using the Lissajous formula.

The result is interesting. I've called it the Burning Mandelbrot and honestly, I've never seen it before (although the idea is quite simple).

As a nice addition, I've implemented a simple zoom feature, you can zoom into the image by just clicking the point on the canvas. Enjoy!

X:
Y:

No comments: