8000 GitHub - ishaan2611/fractals: Fast mandelbrot set renderer using goroutines
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fast mandelbrot set renderer using goroutines

Notifications You must be signed in to change notification settings

ishaan2611/fractals

 
 

Repository files navigation

fractals

fractals is a customizable renderer for the Mandelbrot set written in Go. It uses Go's goroutines to achieve high performance.

Usage

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

Examples

About the Algorithm

The Math in a Nutshell

The Mandelbrot set is defined as the set of complex numbers $z_0$ for which the series

$$z_{n+1} = z²_n + z_0$$

is bounded for all $n ≥ 0$. In other words, $z_0$ is part of the Mandelbrot set if $z_n$ does not approach infinity. This is equivalent to the magnitude $|z_n| ≤ 2$ for all $n ≥ 0$.

But how is this visualized in a colorful image?

The image is interpreted as complex plane, i.e. the horizontal axis being the real part and the vertical axis reperesenting the complex part of $z_0$.

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 a color if it's not. The color is determined by the number of iterations $n$ needed for $z_n$ to exceed $|z_n| = 2$. This $n$ is the escape time, and $|z_n| ≥ 2$ is the escape condition. In our implementation, this is done via the hue parameter in the HSL color model.

And how does it leverage Goroutines?

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.

Advanced Rendering Features

  • Linear color mixing (source)
  • Anti-aliasing by random sampling (source)
  • Normative iteration count to smooth stair-step function (math behind)

About

Fast mandelbrot set renderer using goroutines

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
0