fractals is a customizable renderer for the Mandelbrot set written in Go. It uses Go's goroutines to achieve high performance.
🚀 Featured in Golang Weekly #464 🚀
git clone https://github.com/joweich/fractals.git
cd fractals
go build
./fractals -h # to see list of available customizations
./fractals -height 1000 -width 1000 # fractals.exe for Windows systems
The Mandelbrot set is defined as the set of complex numbers
is bounded for all
The image is interpreted as complex plane, i.e. the horizontal axis being the real part and the vertical axis representing the complex part of
The colors are determined by the so-called naïve escape time algorithm. It's as simple as that: A pixel is painted in a predefined color (often black) if it's in the set and will have another color if it's not. The color is determined by the number of iterations
Each row of the image is added as a job to a channel. These jobs are distributed using goroutines (lightweight threads managed by the Go runtime) that are spun off by consuming from the channel until it's empty.
- Linear color mixing (source)
- Anti-aliasing by random sampling (source)
- Normative iteration count to smooth stair-step function (math behind)