2D transformation matrix object initialized with identity matrix.
The matrix can synchronize a canvas context by supplying the context as an argument, or later apply current absolute transform to an existing context.
Constructor
Variables
Methods
applyToArray (points:Int32Array):Int32Array
Apply current matrix to a typed array with point pairs. Although the input array may be an ordinary array, this method is intended for more performant use where typed arrays are used. The returned array is regardless always returned as a UInt16Array.
Parameters:
points | array with point pairs |
---|
Returns:
A new array with transformed points
inlineapplyToPoint (x:Float, y:Float):{y:Float, x:Float}
Apply current matrix to x and y point. Returns a point object.
Parameters:
x |
|
---|---|
y |
|
Returns:
A new transformed point object
applyToPoints (points:Array<FloatPoint>):Array<FloatPoint>
Apply current matrix to array with point objects or point pairs. Returns a new array with points in the same format as the input array.
A point object is an object literal:
{x: x, y: y}
so an array would contain either:
[{x: x1, y: y1} {x: x2, y: y2} ... {x: xn, y: yn}]
or [x1, y1, x2, y2, ... xn, yn]
Parameters:
points |
|
---|
Returns:
A new array with transformed points
interpolate (m2:AffineMatrix, t:Float):AffineMatrix
Interpolate this matrix with another and produce a new matrix. t is a value in the range [0.0, 1.0] where 0 is this instance and 1 is equal to the second matrix. The t value is not constrained.
Context from parent matrix is not applied to the returned matrix.
Parameters:
m2 |
|
---|---|
t |
|
Returns:
- new instance with the interpolated result
isIdentity ():Bool
Returns true if matrix is an identity matrix (no transforms applied).
Returns:
True if identity (not transformed)
rotate (angle:Float):Affine
Rotates current matrix accumulative by angle.
Parameters:
angle |
|
---|
rotateDeg (angle:Float):Affine
Helper method to make a rotation based on an angle in degrees.
Parameters:
angle |
|
---|
scale (sx:Float, sy:Float):Affine
Scales current matrix accumulative.
Parameters:
sx |
|
---|---|
sy |
|
scaleX (sx:Float):Affine
Scales current matrix on x axis accumulative.
Parameters:
sx |
|
---|
scaleY (sy:Float):Affine
Scales current matrix on y axis accumulative.
Parameters:
sy |
|
---|
skew (sx:Float, sy:Float):Affine
Apply skew to the current matrix accumulative.
Parameters:
sx |
|
---|---|
sy |
|
skewX (sx:Float):Affine
Apply skew for x to the current matrix accumulative.
Parameters:
sx |
|
---|
skewY (sy:Float):Affine
Apply skew for y to the current matrix accumulative.
Parameters:
sy |
|
---|
transformMatrix (a2:Float, b2:Float, c2:Float, d2:Float, e2:Float, f2:Float):Affine
Multiplies current matrix with new matrix values.
translate (tx:Float, ty:Float):Affine
Translate current matrix accumulative.
Parameters:
tx |
|
---|---|
ty |
|
translateX (tx:Float):Affine
Translate current matrix on x axis accumulative.
Parameters:
tx |
|
---|
translateY (ty:Float):Affine
Translate current matrix on y axis accumulative.
Parameters:
ty |
|
---|