The core functions in Geometrize Haxe.

Static methods

staticbestHillClimbState (shapes:Array<ShapeType>, alpha:Int, n:Int, age:Int, target:Bitmap, current:Bitmap, buffer:Bitmap, lastScore:Float):State

Gets the best state using a hill climbing algorithm.

Parameters:

shapes

The types of shape to use.

alpha

The opacity of the shape.

n

The number of random states to generate.

age

The number of hillclimbing steps.

target

The target bitmap.

current

The current bitmap.

buffer

The buffer bitmap.

lastScore

The last score recorded by the model.

Returns:

The best state acquired from hill climbing i.e. the one with the lowest energy.

staticbestRandomState (shapes:Array<ShapeType>, alpha:Int, n:Int, target:Bitmap, current:Bitmap, buffer:Bitmap, lastScore:Float):State

Gets the best state using a random algorithm.

Parameters:

shapes

The types of shape to use.

alpha

The opacity of the shape.

n

The number of states to try.

target

The target bitmap.

current

The current bitmap.

buffer

The buffer bitmap.

lastScore

The last score recorded by the model.

Returns:

The best random state i.e. the one with the lowest energy.

staticcomputeColor (target:Bitmap, current:Bitmap, lines:Array<Scanline>, alpha:Int):Rgba

Calculates the color of the scanlines.

Parameters:

target

The target image.

current

The current image.

lines

The scanlines.

alpha

The alpha of the scanline.

Returns:

The color of the scanlines.

staticdifferenceFull (first:Bitmap, second:Bitmap):Float

Calculates the root-mean-square error between two bitmaps.

Parameters:

first

The first bitmap.

second

The second bitmap.

Returns:

The difference/error measure between the two bitmaps.

staticdifferencePartial (target:Bitmap, before:Bitmap, after:Bitmap, score:Float, lines:Array<Scanline>):Float

Calculates the root-mean-square error between the parts of the two bitmaps within the scanline mask. This is for optimization purposes, it lets us calculate new error values only for parts of the image we know have changed.

Parameters:

target

The target bitmap.

before

The bitmap before the change.

after

The bitmap after the change.

score

The score.

lines

The scanlines.

Returns:

The difference/error between the two bitmaps, masked by the scanlines.

staticenergy (shape:Shape, alpha:Int, target:Bitmap, current:Bitmap, buffer:Bitmap, score:Float):Float

Calculates a measure of the improvement adding the shape provides - lower energy is better.

Parameters:

shape

The shape to check.

alpha

The alpha of the shape.

target

The target bitmap.

current

The current bitmap.

buffer

The buffer bitmap.

score

The score.

Returns:

The energy measure.

statichillClimb (state:State, maxAge:Int, lastScore:Float):State

Hill climbing optimization algorithm, attempts to minimize energy (the error/difference).

Parameters:

state

The state to optimize.

maxAge

The maximum age.

lastScore

The last score recorded by the model.

Returns:

The best state found from hillclimbing.