generator

package
v0.0.0-...-48d1de2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coordinate

type Coordinate struct {
	Re float64
	Im float64
	// contains filtered or unexported fields
}

Coordinate holds real number 'Re', imaginary number 'Im' and corresponding pixel index

type Mandelbrot

type Mandelbrot struct {
	Width         int
	Height        int
	R             float64
	MaxIterations int
	X             float64
	Y             float64
	ImageData     *image.RGBA
	Colors        int
}

Mandelbrot defines the parameters of the set to render

Width & Height define the dimensions of the output image
R specifies the "zoom"
MaxIterations is upper limit of iterations for the calculation if a pixel is contained in the set or not
X & Y define where the center of the complex plane should be from -2..2

func (*Mandelbrot) Render

func (m *Mandelbrot) Render()

Render generates the Mandelbrot set with N CPU number of go routines

func (*Mandelbrot) RenderSequentially

func (m *Mandelbrot) RenderSequentially()

RenderSequentially generates the Mandelbrot set sequentially, without go routines

func (*Mandelbrot) RenderWithBufferedChannel

func (m *Mandelbrot) RenderWithBufferedChannel()

RenderWithBufferedChannel uses a buffered channel for Coordinates The buffer size is tthe number of pixel devided by n CPU. For each CPU one go routine is started, each reading from the buffered Coorindate channel

func (*Mandelbrot) RenderWithMaxRoutines

func (m *Mandelbrot) RenderWithMaxRoutines(maxRoutines int)

RenderWithMaxRoutines limits the number of go routines All go routines read from one Coordinate channel with no buffer set

func (*Mandelbrot) RenderWithUnlimitedRoutines

func (m *Mandelbrot) RenderWithUnlimitedRoutines()

RenderWithUnlimitedRoutines uses one go routine per Coordinate All go routines read from one Coordinate channel with no buffer set

func (*Mandelbrot) WriteJpeg

func (m *Mandelbrot) WriteJpeg(filename string, quality int) error

WriteJpeg encodes the Mandelbrot.ImageData to a JPEG file The quality for JPEG encoding must be passed as int, value between 0..100

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL