!header Generalized Julia Sets
This one’s been a long time coming. The first applet I ever made for the site was a Julia set explorer, and although it took me months to learn how to optimize it to a reasonable speed, even the first version was a huge step forward in the kind of fractal generating code I’d written up to that point. It wasn’t what I’d made the applet for, but it was fun to mess with the code behind the scenes and make Julia sets from different generating functions. I thought about making new applets out of some of them, but it was never worth copying all the code over just for a slight variation on a theme. What I needed was an applet that allowed for near-complete control over its own code — and so here we are at last.
The large text box contains the function that’s iterated to create the Mandelbrot and Julia sets. It’s written with a proper complex number library, which means the performance is slightly worse than the original Julia set explorer applet, but the tradeoff’s worth it. The other boxes are for parameters that modify the output — how much of the set can be seen and how far away from zero a number has to get before the applet decides it’s never going to come back down.
This is far from the most user-friendly applet, but hopefully you can get something out of it. Here are some functions to get started — see if you can find some interesting ones yourself!
Classical Mandelbrot: cadd(cpow(z, 2.0), c)
Varied exponent: cadd(cpow(z, 4.0), c)
Trig example: csin(cmul(z, c))
Rational map example:
cadd(csub(cpow(z, 2.0), cmul(.05, cpow(z, -2.0))), c)
Creating a complex number from scratch:
cadd(csub(cpow(z, 2.0), vec2(0.0, cmul(.05, cpow(z, -2.0).y))), c)
code Generating Function
resolution 500 Resolution
exposure 1 Exposure
escape-radius 100 Escape Radius
generate l Generate
switch-julia-mode l Pick Julia Set
!text s High Resolution Capture
high-res-dim 2000 Image Size