Versions in this module Expand all Collapse all v1 v1.0.0 May 4, 2020 Changes in this version + var LogLevel int + func AverageImageColor(im image.Image) color.NRGBA + func LoadImage(path string) (image.Image, error) + func Log(level int, format string, a ...interface{}) + func NumberString(x float64) string + func PreAnneal(state Annealable, iterations int) float64 + func SaveFile(path, contents string) error + func SaveGIF(path string, frames []image.Image, delay, lastDelay int) error + func SaveGIFImageMagick(path string, frames []image.Image, delay, lastDelay int) error + func SaveJPG(path string, im image.Image, quality int) error + func SavePNG(path string, im image.Image) error + type Annealable interface + Copy func() Annealable + DoMove func() interface{} + Energy func() float64 + UndoMove func(interface{}) + func Anneal(state Annealable, maxTemp, minTemp float64, steps int) Annealable + func HillClimb(state Annealable, maxAge int) Annealable + type Color struct + A int + B int + G int + R int + func MakeColor(c color.Color) Color + func MakeHexColor(x string) Color + func (c *Color) NRGBA() color.NRGBA + type Ellipse struct + Circle bool + Rx int + Ry int + Worker *Worker + X int + Y int + func NewRandomCircle(worker *Worker) *Ellipse + func NewRandomEllipse(worker *Worker) *Ellipse + func (c *Ellipse) Copy() Shape + func (c *Ellipse) Draw(dc *gg.Context, scale float64) + func (c *Ellipse) Mutate() + func (c *Ellipse) Rasterize() []Scanline + func (c *Ellipse) SVG(attrs string) string + type Heatmap struct + Count []uint64 + H int + W int + func NewHeatmap(w, h int) *Heatmap + func (h *Heatmap) Add(lines []Scanline) + func (h *Heatmap) AddHeatmap(a *Heatmap) + func (h *Heatmap) Clear() + func (h *Heatmap) Image(gamma float64) *image.Gray16 + type Model struct + Background Color + Colors []Color + Context *gg.Context + Current *image.RGBA + Scale float64 + Score float64 + Scores []float64 + Sh int + Shapes []Shape + Sw int + Target *image.RGBA + Workers []*Worker + func NewModel(target image.Image, background Color, size, numWorkers int) *Model + func (model *Model) Add(shape Shape, alpha int) + func (model *Model) Frames(scoreDelta float64) []image.Image + func (model *Model) SVG() string + func (model *Model) Step(shapeType ShapeType, alpha, repeat int) int + type Polygon struct + Convex bool + Order int + Worker *Worker + X []float64 + Y []float64 + func NewRandomPolygon(worker *Worker, order int, convex bool) *Polygon + func (p *Polygon) Copy() Shape + func (p *Polygon) Draw(dc *gg.Context, scale float64) + func (p *Polygon) Mutate() + func (p *Polygon) Rasterize() []Scanline + func (p *Polygon) SVG(attrs string) string + func (p *Polygon) Valid() bool + type Quadratic struct + Width float64 + Worker *Worker + X1 float64 + X2 float64 + X3 float64 + Y1 float64 + Y2 float64 + Y3 float64 + func NewRandomQuadratic(worker *Worker) *Quadratic + func (q *Quadratic) Copy() Shape + func (q *Quadratic) Draw(dc *gg.Context, scale float64) + func (q *Quadratic) Mutate() + func (q *Quadratic) Rasterize() []Scanline + func (q *Quadratic) SVG(attrs string) string + func (q *Quadratic) Valid() bool + type Rectangle struct + Worker *Worker + X1 int + X2 int + Y1 int + Y2 int + func NewRandomRectangle(worker *Worker) *Rectangle + func (r *Rectangle) Copy() Shape + func (r *Rectangle) Draw(dc *gg.Context, scale float64) + func (r *Rectangle) Mutate() + func (r *Rectangle) Rasterize() []Scanline + func (r *Rectangle) SVG(attrs string) string + type RotatedEllipse struct + Angle float64 + Rx float64 + Ry float64 + Worker *Worker + X float64 + Y float64 + func NewRandomRotatedEllipse(worker *Worker) *RotatedEllipse + func (c *RotatedEllipse) Copy() Shape + func (c *RotatedEllipse) Draw(dc *gg.Context, scale float64) + func (c *RotatedEllipse) Mutate() + func (c *RotatedEllipse) Rasterize() []Scanline + func (c *RotatedEllipse) SVG(attrs string) string + type RotatedRectangle struct + Angle int + Sx int + Sy int + Worker *Worker + X int + Y int + func NewRandomRotatedRectangle(worker *Worker) *RotatedRectangle + func (r *RotatedRectangle) Copy() Shape + func (r *RotatedRectangle) Draw(dc *gg.Context, scale float64) + func (r *RotatedRectangle) Mutate() + func (r *RotatedRectangle) Rasterize() []Scanline + func (r *RotatedRectangle) SVG(attrs string) string + func (r *RotatedRectangle) Valid() bool + type Scanline struct + Alpha uint32 + X1 int + X2 int + Y int + type Shape interface + Copy func() Shape + Draw func(dc *gg.Context, scale float64) + Mutate func() + Rasterize func() []Scanline + SVG func(attrs string) string + type ShapeType int + const ShapeTypeAny + const ShapeTypeCircle + const ShapeTypeEllipse + const ShapeTypePolygon + const ShapeTypeQuadratic + const ShapeTypeRectangle + const ShapeTypeRotatedEllipse + const ShapeTypeRotatedRectangle + const ShapeTypeTriangle + type State struct + Alpha int + MutateAlpha bool + Score float64 + Shape Shape + Worker *Worker + func NewState(worker *Worker, shape Shape, alpha int) *State + func (state *State) Copy() Annealable + func (state *State) DoMove() interface{} + func (state *State) Energy() float64 + func (state *State) UndoMove(undo interface{}) + type Triangle struct + Worker *Worker + X1 int + X2 int + X3 int + Y1 int + Y2 int + Y3 int + func NewRandomTriangle(worker *Worker) *Triangle + func (t *Triangle) Copy() Shape + func (t *Triangle) Draw(dc *gg.Context, scale float64) + func (t *Triangle) Mutate() + func (t *Triangle) Rasterize() []Scanline + func (t *Triangle) SVG(attrs string) string + func (t *Triangle) Valid() bool + type Worker struct + Buffer *image.RGBA + Counter int + Current *image.RGBA + H int + Heatmap *Heatmap + Lines []Scanline + Rasterizer *raster.Rasterizer + Rnd *rand.Rand + Score float64 + Target *image.RGBA + W int + func NewWorker(target *image.RGBA) *Worker + func (worker *Worker) BestHillClimbState(t ShapeType, a, n, age, m int) *State + func (worker *Worker) BestRandomState(t ShapeType, a, n int) *State + func (worker *Worker) Energy(shape Shape, alpha int) float64 + func (worker *Worker) Init(current *image.RGBA, score float64) + func (worker *Worker) RandomState(t ShapeType, a int) *State