Constructor

new (shape:Shape, alpha:Int, target:Bitmap, current:Bitmap, buffer:Bitmap)

Create a new state.

Parameters:

shape

A geometric shape.

alpha

The color alpha of the geometric shape.

target

The target bitmap.

current

The current bitmap.

buffer

The buffer bitmap.

Variables

read onlyalpha:Int

The alpha of the shape.

score:Float

The score of the state, a measure of the improvement applying the state to the current bitmap will have.

read onlyshape:Shape

The geometric shape owned by the state.

Methods

clone ():State

Creates a copy of the state. Deep copy of the shape and alpha, shallow copy of the bitmap buffers. Score not copied.

Returns:

The cloned state.

energy (lastScore:Float):Float

Calculates a measure of the improvement drawing the shape to the current bitmap will have. The lower the energy, the better. The score is cached, set it to < 0 to recalculate it.

Parameters:

lastScore

The last score recorded by the model.

Returns:

The energy measure.

mutate ():State

Modify the current state in a random fashion.

Returns:

The old state - in case we want to go back to the old state.