Model for the optimization/fitting algorithm.

Constructor

new (target:Bitmap, backgroundColor:Rgba)

Creates a new model.

Parameters:

target

The target bitmap.

backgroundColor

The starting background color.

Variables

read onlybuffer:Bitmap

Buffer bitmap.

read onlycurrent:Bitmap

The current bitmap.

read onlyheight:Int

Height of the target bitmap.

read onlytarget:Bitmap

The target bitmap, the bitmap we aim to approximate.

read onlywidth:Int

Width of the target bitmap.

Methods

addShape (shape:Shape, alpha:Int):ShapeResult

Adds a shape to the model.

Parameters:

shape

The shape to add.

alpha

The alpha/opacity of the shape.

Returns:

Data about the shape just added to the model.

step (shapeTypes:Array<ShapeType>, alpha:Int, n:Int, age:Int):Array<ShapeResult>

Steps the optimization/fitting algorithm.

Parameters:

shapeType

The shape types to use.

alpha

The alpha of the shape.

n

The number of shapes to try.

age

The number of mutations to apply to each shape.

Returns:

An array containing data about the shapes added to the model in this step.