Documentation
¶
Overview ¶
Package mandel implements a simple library for generating mandelbrot fractals.
Functions are provided for writing a png or jpeg Basic usage of package is
// Creates a new Generator g := NewGenerator(1024, 768, 0,0) // Generates the image g.Generate() // Writes the image as a png to "test.png" f, _ := os.Create("test.png") g.WritePNG(f)
Index ¶
- Constants
- func Average(colors ...color.RGBA) color.RGBA
- func Calculate(x, y float64, limit int) int
- func DefaultColorize(iter int) color.RGBA
- func FindInterestingPoint(x, y float64, limit int) (float64, float64)
- func Gradient(start, end color.RGBA, size, steps int) color.RGBA
- type ColorFunc
- type Generator
- func (g *Generator) AntiAliasedColor(x, y, inc float64) color.RGBA
- func (g *Generator) Generate()
- func (g *Generator) GetColor(x, y float64) color.RGBA
- func (g *Generator) SetColorize(cf ColorFunc)
- func (g *Generator) SetHeight(height int)
- func (g *Generator) SetLimit(limit int)
- func (g *Generator) SetWidth(width int)
- func (g *Generator) SetX(x float64)
- func (g *Generator) SetY(y float64)
- func (g *Generator) SetZoom(zoom float64)
- func (g *Generator) WithAntiAlias(aa int) *Generator
- func (g *Generator) WithColorizeFunc(f ColorFunc) *Generator
- func (g *Generator) WithLimit(l int) *Generator
- func (g *Generator) WithZoom(z float64) *Generator
- func (g *Generator) WriteJPG(w io.Writer) error
- func (g *Generator) WritePNG(w io.Writer) error
- func (g *Generator) WriteVideo(file string) error
Constants ¶
const VERSION = "v1.0"
Variables ¶
This section is empty.
Functions ¶
func Calculate ¶
Calculate does the actual mandelbrot calculation if it reached the limit it will bail out with (-1) if it exits the mandelbrot constraint, it will return the number of iterations to do so.
func DefaultColorize ¶
DefaultColorze is a very simple Greyscale ColorFunc
func FindInterestingPoint ¶
FindInterestingPoint is a helper function that picks a bunch of random points on the fractal until it find one that is interesting
Types ¶
type ColorFunc ¶
ColorFucn is what is used to generate the colorscheme It takes the number of iterations from the mandelbrot calculation and returns a color DefaultColorize is an extremely basic example
type Generator ¶
type Generator struct {
// Width and Height specify the resolution to use
Width int
Height int
// X and Y specify what point on the fractal to center on
X float64
Y float64
// Zoom specifies how much to zoom in
Zoom float64
// Limit specifies when the mandelbrot calculation
// should bail out and return -1 instead of
// the number of iterations
Limit int
// AntiAlias specifies what level of antialiasing to use
// An AntiAlias of 2 will average 4 points for each pixel
// 3 will average 9 points. The increase is exponential
AntiAlias int
// Colorize is the ColorFunc used to generate the colorscheme
Colorize ColorFunc
// StartX specifies the starting x if generating video
StartX float64
// StartY specifies the starting y if generating video
StartY float64
// StartZoom specifies the starting zoom if generating video
StartZoom float64
// Frames specifies the number of frames to use if generating video
Frames int
// contains filtered or unexported fields
}
Generator is the used to generate the fractal
func NewGenerator ¶
NewGenerator creates a new *Generator it should be used to ensure all fields are filled.
func (*Generator) AntiAliasedColor ¶
AntiAliasedColor breaks a pixel down into parts and gets the color for each point, then averages them out for the pixel color
func (*Generator) Generate ¶
func (g *Generator) Generate()
Generate does the mandelbrot calculation and stores the fractal into an image
func (*Generator) GetColor ¶
GetColor gets the mandelbrot calculation iterations and Uses the defined Colorize function turn into a color
func (*Generator) SetColorize ¶
func (*Generator) WithAntiAlias ¶
Sets the AntiAliasing level
func (*Generator) WithColorizeFunc ¶
Sets the Colorize function used to generate colorscheme
func (*Generator) WriteVideo ¶
WriteVideo generates a video file