Class: TransformationBuilder

Core.Math. TransformationBuilder

A utility class to help create transformations.

new TransformationBuilder( [initial])

A builder class to help facilitate creating transformation matrices.
Parameters:
Name Type Argument Description
initial Array.<Core.Math.Matrix> <optional>
transformation matrix list.

Methods


clear()

Clears the list of all transformations.
Returns:
The tranformation matrix
Type
Core.Math.Matrix

getAt(index)

Gets the transformation at a particular index.
Parameters:
Name Type Description
index number A valid index
Returns:
A transformation matrix
Type
Core.Math.Matrix

getFinalTransform()

Gets the final transformation by multiplying the matrices in the list.
Returns:
The tranformation matrix
Type
Core.Math.Matrix

insertAt(index, transform)

Inserts a transformation matrix at a particular index.
Parameters:
Name Type Description
index number A valid index
transform Core.Math.Matrix A transformation matrix
Returns:
This instance
Type
Core.Math.TransformationBuilder

pop()

Pop and returns the last transformation matrix.
Returns:
This instance
Type
Core.Math.TransformationBuilder

push(transform)

Pushes a transformation matrix into the list.
Parameters:
Name Type Description
transform Core.Math.Matrix The transformation matrix
Returns:
This instance
Type
Core.Math.TransformationBuilder

removeAt(index)

Removes the transformation matrix at a particular index.
Parameters:
Name Type Description
index number A valid index
Returns:
This instance
Type
Core.Math.TransformationBuilder

rotate(angle [, inRadians])

Creates a rotation transform and adds it to the list.
Parameters:
Name Type Argument Default Description
angle number The amount to rotate by
inRadians boolean <optional>
false Whether the amount is in radians. Default: false
Returns:
This instance
Type
Core.Math.TransformationBuilder

scale(sx, sy)

Creates a scale transform and adds it to the list.
Parameters:
Name Type Description
sx number The amount to scale by horizontally. Expects a decimal value. ex. 0.5 for 50%
sy number The amount to scale by vertically. Expects a decimal value. ex. 0.5 for 50%
Returns:
This instance
Type
Core.Math.TransformationBuilder

setAt(index, transform)

Sets the transformation matrix at a particular index.
Parameters:
Name Type Description
index number A valid index
transform Core.Math.Matrix A transformation matrix
Returns:
This instance
Type
Core.Math.TransformationBuilder

skew(sx, sy)

Creates a skew transform and adds it to the list.
Parameters:
Name Type Description
sx number The amount to skew by horizontally. Expects a decimal value. ex. 0.5 for 50%
sy number The amount to skew by vertically. Expects a decimal value. ex. 0.5 for 50%
Returns:
This instance
Type
Core.Math.TransformationBuilder

translate(dx, dy)

Creates a translation transform and adds it to the list.
Parameters:
Name Type Description
dx number The amount to translate by horizontally
dy number The amount to translate by vertically
Returns:
This instance
Type
Core.Math.TransformationBuilder

translateTo(sx, sy, dx, dy)

Creates a translation transform from a source to a destination and adds it to the list.
Parameters:
Name Type Description
sx number The source X value
sy number The source Y value
dx number The destination X value
dy number The destination Y value
Returns:
This instance
Type
Core.Math.TransformationBuilder