Skip to content

diego-vicente/fractal-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generating the Mandelbrot set in Go

./example.png

As an exercise for learning Go, I decided to start writing a simple program to generate the Mandelbrot set. While it still needs quite a lot of refactoring, the program still keeps all the methods I have used to generate the set:

  • First, simply sequentially computing the pixels and storing everything in a RGBA image.
  • Then, receiving a number of routines to launch, split the image in several vertical sections and make each of the goroutines compute a band of the image. Once the corresponding section is drawn, signal the main routine using a channel.
  • Eventually, the best results were obtained by creating a channel that works as a job pool and serves each routine an individual line to work on by demand. That way, the workload is distributed equally among all routines.

To run it, use the flag -n to define the number of routines to be launched: for example: fractal-go -n 8 will create 8 goroutines to query jobs from the channel. This will generate an 8K image of the fractal, which in my laptop takes around 30 seconds to compute.

About

Mandelbrot set representation in Go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages