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

new ()

Variables

a:Float

scale x

b:Float

skew y

c:Float

skew x

d:Float

scale y

e:Float

translate x

f:Float

translate y

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
  • value for x
y
  • value for 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
  • array with point objects or pairs

Returns:

A new array with transformed points

assign (m:AffineMatrix):Affine

Assign this affine to given matrix.

flipX ():Affine

Flips the horizontal values.

flipY ():Affine

Flips the vertical values.

getMatrix ():{f:Float, e:Float, d:Float, c:Float, b:Float, a:Float}

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
  • the matrix to interpolate with.
t
  • interpolation [0.0, 1.0]

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
  • angle in radians

rotateDeg (angle:Float):Affine

Helper method to make a rotation based on an angle in degrees.

Parameters:

angle
  • angle in degrees

scale (sx:Float, sy:Float):Affine

Scales current matrix accumulative.

Parameters:

sx
  • scale factor x (1 does nothing)
sy
  • scale factor y (1 does nothing)

scaleX (sx:Float):Affine

Scales current matrix on x axis accumulative.

Parameters:

sx
  • scale factor x (1 does nothing)

scaleY (sy:Float):Affine

Scales current matrix on y axis accumulative.

Parameters:

sy
  • scale factor y (1 does nothing)

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

Apply skew to the current matrix accumulative.

Parameters:

sx
  • amount of skew for x
sy
  • amount of skew for y

skewX (sx:Float):Affine

Apply skew for x to the current matrix accumulative.

Parameters:

sx
  • amount of skew for x

skewY (sy:Float):Affine

Apply skew for y to the current matrix accumulative.

Parameters:

sy
  • amount of skew for y

transform (o:AffineOptions):{bitmap:Null<Bitmap>, affine:Affine}

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
  • translation for x
ty
  • translation for y

translateX (tx:Float):Affine

Translate current matrix on x axis accumulative.

Parameters:

tx
  • translation for x

translateY (ty:Float):Affine

Translate current matrix on y axis accumulative.

Parameters:

ty
  • translation for y

Static methods

staticidentity ():{f:Float, e:Float, d:Float, c:Float, b:Float, a:Float}