Fractals — 24-bit Mandelbrot and Julia Sets
fract_mt64cpu is a multithreaded C fractal viewer that draws to an X11
window. It still builds and runs on macOS under XQuartz, although
zooming no longer works. Recently I used an AI agent to port it to a
single self-contained HTML page. It draws Mandelbrot and Julia sets pixel
by pixel in 24-bit color on an HTML canvas.

The default view
Origins
I wrote the original in 1999 as a student at Boise State University. I developed it on Onyx, a dual-processor HP-UX machine, working from an X terminal running FVWM in a windowless computer lab in the Math and Geosciences building.
It has been through many iterations since. I ported it to CUDA in 2012, and later to OS X.
Threads become Web Workers
The 1999 original split the image across CPU threads, using many different traversal methods, ways of dividing the image among threads. I used them to explore problem decomposition in parallel computing and dynamic scheduling with threads:
- random triangles
- circles of decreasing radius, which looked like raindrops
- random squiggles
- a Sierpinski-style triangle tiling
- grid-based worker allocation
- recursive thread spawning
The circles were the hardest. I hadn’t taken linear algebra or graphics yet, and my floating-point math left gaps of unpainted pixels near the x-axis. Sadly, that version of the code is lost.
In the browser, a pool of Web Workers (one per CPU core) splits the work, each taking horizontal strips of the image. The worker code is inline in the page and started from a Blob URL, so the whole thing remains one file.
The port stays close to the surviving C code:
- The escape test and iteration loop follow
mandelbrot_calc_iter. - The
classicpalette ports themandelbrot_calc_colorhue wheel directly. - While you move, a low-resolution preview is drawn. Once you stop, the image renders at full device-pixel resolution.
Beyond the original
- By default escape counts are smooth (fractional);
sswitches back to hard bands. - Escape counts are kept between frames, so changing or cycling the palette doesn’t recompute anything.
- The URL hash records the current view, so any view can be bookmarked or shared.
jswitches to the Julia set for the point under the cursor.- Zoom depth tops out around 10¹²x, where 64-bit floating point runs out of precision and pixels start to block up.



See also the ASCII version.