A Mandelbrot set generator implemented in Rust, optimized for high-resolution output.
The renderer generates the Mandelbrot set by iterating the complex quadratic polynomial:
For each pixel
-
Coordinate Mapping: The pixel coordinates are mapped to a point
$c$ in the complex plane ($c = a + bi$ ). -
Iteration: Starting with
$z_0 = 0$ , the function is applied repeatedly. -
Escape Condition: If the magnitude
$|z|$ exceeds a threshold (256) within the maximum number of iterations, the point is considered to "escape" to infinity. - Coloring: The number of iterations taken to escape, combined with a renormalization factor, determines the pixel color. Points that do not escape are considered part of the Mandelbrot set.
- Memory Management: Images are rendered and written line-by-line to allow massive scale renders (e.g., 35,000px+) on systems with limited RAM.
- Optimizations: Geometric checks are used to skip interior points (Cardioid/Bulb), and binary P6 PPM output is used for fast I/O.
rayon: Used for parallelizing the computation of each row across all CPU cores.
To run with full optimizations:
cargo run --release