fractal

package module
v0.0.0-...-d342fde Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRender = RenderParams{
	VP:     viewport.New(),
	P:      BlackWhite,
	Mandel: EscapeIterationCount,
	MandelP: MandelParams{
		MaxIterations: 10000,
	},
}

Functions

func BlackWhite

func BlackWhite(c IterationCount) color.Color

The simplest possible coloring function. It colors points in the Mandelbrot set black, and those not in the set white

func ExportPNG

func ExportPNG(m *image.RGBA) error

func Grayscale

func Grayscale(resolution int, percentGray float64) color.Palette

Generates a grayscale palette to a coloring spectrum which is mirrored. Max is the number of maximum interations, for selecting the number in the cycle. Finally, resolution is the number of grayscale colors to pick for generating the palette.

func Paint

func Paint(p Painter, iterImg IterationImage) *image.RGBA

Paint applies a provided coloring function on an IterationImage and turns it into a colored image, which can be saved as a PNG or some other type of stored bitmap on a machine.

func PaintWithPalette

func PaintWithPalette(c IterationCount, p color.Palette) color.Color

Colors a given index according to the maximum number of iterations, and additionally handles linearly interpolating between colors if a fractional portion of the interation count is present

func Render

func Render(params RenderParams) *image.RGBA

Types

type Algorithm

type Algorithm = func(complex128, MandelParams) IterationCount

type IterationCount

type IterationCount struct {
	Count int
	Frac  float64
}

IterationCount is returned by coloring functions. More advanced ones will return a fractional portion. If the count returned is negative, then that should be interpreted as a point being in the set.

func EscapeIterationCount

func EscapeIterationCount(c complex128, p MandelParams) IterationCount

EscapeIterationCount applies a simple algorithm to get an integer color for when a point escapes.

type IterationImage

type IterationImage struct {
	// contains filtered or unexported fields
}

type MandelParams

type MandelParams struct {
	MaxIterations int
	Smooth        bool
}

type Painter

type Painter = func(IterationCount) color.Color

type RenderParams

type RenderParams struct {
	VP      viewport.View
	P       Painter
	Mandel  Algorithm
	MandelP MandelParams
}

Render is a workhorse function that generates a complex plane, uses the selected algorithm for running the mandelbrot, and colors every pixel concurrently

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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