Mandelbrot renderer.
Context
A window to the depths of Mandelbrot sets. The Mandelbrot set is the collection of complex numbers c for which the iteration z₀ = 0, zₙ₊₁ = zₙ² + c stays bounded forever. Plot the ones that do in black, colour the ones that escape by how long they took, and you get the famous self-similar coastline. This renderer is Java + Processing 4, built with Gradle, and turns the set into something you can sit in front of and pan around.
How it works
▸ The iteration
Each on-screen pixel maps to a complex coordinate in the viewport. The renderer iterates the Mandelbrot recurrence per pixel and records the step at which the magnitude crosses 2 — beyond that, divergence is guaranteed. Pixels are coloured by escape time; pixels that never escape stay black and reveal the body of the set.
▸ Mouse mode vs. normal mode
Normal mode renders a fixed rectangular window in complex space — pan with the arrow keys, scale the window with , and .. Mouse mode (toggle with m) restricts work to a moving disc around the cursor, so a deep-zoom probe can be aimed by hand without re-rendering the whole frame.
▸ Multithreaded by default
The renderer fans pixel rows out across worker threads, defaulting to cores − 1 so the UI thread stays responsive. w and s adjust the worker count live — useful for trying out where the gains stop being linear when the iteration count climbs deep into the set.
Controls
arrows pan through complex space
= / - zoom in / zoom out
, / . adjust render window (mouse range in mouse mode)
0 switch between iteration equations
m toggle mouse mode on / off
w / s worker thread count (defaults to cores − 1)
Build & run
Java 11, Gradle. Clone the repo, then:
./gradlew clean test
./gradlew run