Matrix3
is a 3x3 transformation matrix particularly useful for
two-dimensional transformation. It can be used for rotation, scale
and skewing of a two-dimensional object.
Although a 3x3 matrix is represented, configurable values can be considered as a 3x2 matrix:
[ a, c, tx ]
[ c, d, ty ]
[ 0, 0, 1 ]
Constructor
new(a:Float = 1, b:Float = 0, c:Float = 0, d:Float = 1, tx:Float = 0, ty:Float = 0)
Creates a new Matrix
instance
Parameters:
a | (Optional) An initial a component value (default is 1) |
---|---|
b | (Optional) An initial b component value (default is 0) |
c | (Optional) An initial c component value (default is 0) |
d | (Optional) An initial d component value (default is 1) |
tx | (Optional) An initial tx component value (default is 0) |
ty | (Optional) An initial ty component value (default is 0) |
Variables
Methods
copyColumnFrom(column:Int, vector4:Vector4):Void
copyColumnTo(column:Int, vector4:Vector4):Void
copyRowFrom(row:Int, vector4:Vector4):Void
createBox(scaleX:Float, scaleY:Float, rotation:Float = 0, tx:Float = 0, ty:Float = 0):Void
Applies a two-dimensional transformation to the current matrix.
This is the same as calling identity()
, rotate()
, scale()
then translate()
with these values.
Parameters:
scaleX | An x scale transformation value |
---|---|
scaleY | A y scale transformation value |
rotation | (Optional) A rotation value (default is 0) |
tx | (Optional) A translate x value (default is 0) |
ty | (Optional) A translate y value (default is 0) |
createGradientBox(width:Float, height:Float, rotation:Float = 0, tx:Float = 0, ty:Float = 0):Void
Creates a matrix to use for a linear gradient fill
Parameters:
width | The width of the gradient fill |
---|---|
height | The height of the gradient fill |
rotation | (Optional) A rotation for the gradient fill (default is 0) |
tx | (Optional) An x offset for the gradient fill (default is 0) |
ty | (Optional) A y offset for the gradient fill (default is 0) |
Returns:
A new Matrix
instance
deltaTransformVector(Vector2:Vector2, ?result:Vector2):Vector2
equals(matrix3:Matrix3):Bool
Check if two matrices have the same values
Returns:
Whether both matrices are equal
rotate(theta:Float):Void
Applies rotation to the current matrix
Parameters:
theta | A rotation value in degrees |
---|
scale(sx:Float, sy:Float):Void
Scales the current matrix
Parameters:
sx | The x scale to apply |
---|---|
sy | The y scale to apply |
inlinesetTo(a:Float, b:Float, c:Float, d:Float, tx:Float, ty:Float):Void
Sets the values of the current matrix
Parameters:
a | The new matrix a value |
---|---|
b | The new matrix b value |
c | The new matrix c value |
d | The new matrix d value |
tx | The new matrix tx value |
ty | The new matrix ty value |