An affine 2D 2x3 matrix.

Matrix properties are as follows:

[a, c, x]
[b, d, y]

Constructor

inlinenew()

Create a new identity Matrix.

Variables

a:Float

b:Float

c:Float

d:Float

x:Float

y:Float

Methods

clone():Matrix

Returns a copy of this Matrix.

inlinegetDeterminant():Float

Returns the determinant of the Matrix a, b, c and d values.

inlinegetPosition(?p:Point):Null<Point>

Returns a Point with x and y of the Matrix.

Parameters:

p

Optional Point instance to use. Otherwise returns new instance.

inlinegetScale():Point

Returns a Point with a total scaling applied by the Matrix.

Parameters:

p

Optional Point instance. If provided, sets values of given Point and returns it. Otherwise returns new Point instance.

inlineidentity():Void

Sets the matrix values to ones that would perform no transformation.

[1, 0, 0]
[0, 1, 0]

inlineinitRotate(angle:Float):Void

Sets the matrix values to ones that would only rotate the transformed position by given angle.

[cos(angle), -sin(angle), 0]
[sin(angle),  cos(angle), 0]

inlineinitScale(sx:Float, sy:Float):Void

Sets the matrix values to ones that would only scale the transformed positions by given sx and sy.

[sx, 0, 0]
[0, sy, 0]

inlineinitSkew(sx:Float, sy:Float):Void

Sets the matrix values to ones that would only skew the transformed position by given sx and sy.

[1, tan(sx), 0]
[tan(sy), 1, 0]

inlineinitTranslate(x:Float, y:Float):Void

Sets the matrix values to ones that would only move the transformed positions by given x and y.

[1, 0, x]
[0, 1, y]

inverse(m:Matrix):Void

Sets this Matrix value to be the inverse of the given Matrix m.

invert():Void

Inverts the matrix to perform the opposite transformation. Can be used to undo the previously applied transformation.

See also:

multiply(a:Matrix, b:Matrix):Void

Concatenates Matrix a and b and stores the result in this Matrix. Matrix can be the target of of it's own multiply. Keep in mind that order of matrixes matter in concatenation.

inlineprependTranslate(x:Float, y:Float):Void

Transforms given x and y with current Matrix values (excluding translation) and applies translation transform to Matrix by resulting x and y.

inlineprependTranslateX(x:Float):Void

Transforms given x with current Matrix values (excluding translation) and applies translation transform on X-axis to Matrix by resulting x and y. Equivalent of matrix.x += matrix.a * x.

inlineprependTranslateY(y:Float):Void

Transforms given y with current Matrix values (excluding translation) and applies translation transform on Y-axis to Matrix by resulting y. Equivalent of matrix.y += matrix.d * y.

rotate(angle:Float):Void

Applies rotation transform to the Matrix by given angle.

inlinescale(sx:Float, sy:Float):Void

Multiplies the a, c and x by given sx and b, d and y by sy.

inlinescaleX(sx:Float):Void

Multiplies the a, c and x by given sx.

inlinescaleY(sy:Float):Void

Multiplies the b, d and y by sy.

skew(sx:Float, sy:Float):Void

Applies skewing transform to the Matrix by given sx and sy.

skewX(sx:Float):Void

Applies skewing transform on X-axis to the Matrix by given sx.

skewY(sy:Float):Void

Applies skewing transform on Y-axis to the Matrix by given sy.

inlinetransform(pt:Point):Point

Returns a new Point that is a result of transforming Point pt by this Matrix.

inlinetranslate(x:Float, y:Float):Void

Applies translation transform to Matrix by given x and y.

inlinetranslateX(x:Float):Void

Applies translation transform on X-axis to Matrix by given x. Equivalent of matrix.x += x.

inlinetranslateY(y:Float):Void

Applies translation transform on Y-axis to Matrix by given y. Equivalent of matrix.y += y.