Class: Matrix

Matrix

2D Transformation Matrix.

new Matrix()

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2584
2D transformation matrix object initialized with identity matrix.
Properties:
Name Type Description
`a` number scale x
`b` number shear y
`c` number shear x
`d` number scale y
`e` number translate x
`f` number translate y
Version:
• 2.7.5
Author:
• Epistemex

Methods

staticMatrix.from(a, b, c, d, e, f, context){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2632
Create and transform a new matrix based on given matrix values, or provide SVGMatrix or a (2D) DOMMatrix, WebKitCSSMatrix or another instance of a generic matrix.
Name Type Description
`a` * number representing a (scale x) in [a-f], or a Matrix object containing properties a-f.
`b` * optional b property (shear y) if a is not a matrix object, or optional canvas 2D context. If vector is input this will be pre-translate for x.
`c` number optional c property (shear x)
`d` number optional d property (scale y)
`e` number optional e property (translate x)
`f` number optional f property (translate y)
`context` CanvasRenderingContext2D optional optional canvas context to synchronize
Returns:
Type Description
Matrix - new Matrix instance
Example
``````var m = Matrix.from(1, 0.2, 0, 2, 120, 97);
var m = Matrix.from(domMatrix, ctx);
var m = Matrix.from(svgMatrix);
var m = Matrix.from(matrix);``````

applyToPoint(pt){Array.<number>}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2886
Apply current matrix to `x` and `y` of a point. Returns a point object.
Name Type Description
`pt` Array.<number> the point to transform ([x, y]).
If an optionnal Z value is provided, it will be kept without transformation.
Returns:
Type Description
Array.<number> A new transformed point [x, y]. If pt had a third value, it is returned too, as it was without transformation.

clone(noContext){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2949
Clones current instance and returning a new matrix.
Name Type Default Description
`noContext` boolean false optional don't clone context reference if true
Returns:
Type Description
Matrix - a new Matrix instance with identical transformations as this instance

decompose(){*}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2824
Decompose the current matrix into simple transforms using QR.
See:
Returns:
Type Description
* - an object containing current decomposed values (translate, rotation, scale, skew)

determinant(){number}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2874
Returns the determinant of the current matrix.
Type Description
number

inverse(cloneContext){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2799
Get an inverse matrix of current matrix. The method returns a new matrix with values you need to use to get to an identity matrix. Context from parent matrix is not applied to the returned matrix.
Name Type Default Description
`cloneContext` boolean false optional clone current context to resulting matrix
Throws:
Exception is input matrix is not invertible
Returns:
Type Description
Matrix - new Matrix instance

isEqual(m){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2930
Compares current matrix with another matrix. Returns true if equal (within epsilon tolerance).
Name Type Description
`m` Matrix | Matrix | DOMMatrix | SVGMatrix matrix to compare this matrix with
Type Description
boolean

isIdentity(){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2899
Returns true if matrix is an identity matrix (no transforms applied).
Type Description
boolean

isInvertible(){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2908
Returns true if matrix is invertible
Type Description
boolean

isValid(){boolean}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2920
The method is intended for situations where scale is accumulated via multiplications, to detect situations where scale becomes "trapped" with a value of zero. And in which case scale must be set explicitly to a non-zero value.
Type Description
boolean

multiply(m){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2786
Multiplies current matrix with source matrix.
Name Type Description
`m` Matrix | Matrix | DOMMatrix | SVGMatrix source matrix to multiply with.
Type Description
Matrix

reset(){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2654
Short-hand to reset current matrix to an identity matrix.
Type Description
Matrix

rotate(angle){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2663
Rotates current matrix by angle (accumulative).
Name Type Description
`angle` number angle in degrees
Type Description
Matrix

rotateFromVector(x, y){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2680
Converts a vector given as `x` and `y` to angle, and rotates (accumulative). x can instead contain an object with properties x and y and if so, y parameter will be ignored.
Name Type Description
`x` number | *
`y` number optional
Type Description
Matrix

scale(s){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2689
Scales current matrix accumulative.
Name Type Description
`s` Array.<number> scale factor [x, y]. 1 does nothing, any third value (Z) is ignored.
Type Description
Matrix

setTransform(a, b, c, d, e, f){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2724
Set current matrix to new absolute matrix.
Name Type Description
`a` number scale x
`b` number shear y
`c` number shear x
`d` number scale y
`e` number translate x
`f` number translate y
Type Description
Matrix

shear(sx, sy){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2699
Apply shear to the current matrix accumulative.
Name Type Description
`sx` number amount of shear for x
`sy` number amount of shear for y
Type Description
Matrix

skew(ax, ay){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2710
Apply skew to the current matrix accumulative. Angles in radians. Also see ``skewDeg()``.
Name Type Description
`ax` number angle of skew for x
`ay` number angle of skew for y
Type Description
Matrix

toCSS(){string}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2959
Generates a string that can be used with CSS `transform`.
Type Description
string
Example
``element.style.transform = m.toCSS();``

toCSS3D(){string}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2971
Generates a `matrix3d()` string that can be used with CSS `transform`. Although the matrix is for 2D use you may see performance benefits on some devices using a 3D CSS transform instead of a 2D.
Type Description
string
Example
``element.style.transform = m.toCSS3D();``

toJSON(){string}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2980
Returns a JSON compatible string of current matrix.
Type Description
string

transform(a2, b2, c2, d2, e2, f2){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2755
Multiplies current matrix with new matrix values. Also see ``multiply()``.
Name Type Description
`a2` number scale x
`b2` number skew y
`c2` number skew x
`d2` number scale y
`e2` number translate x
`f2` number translate y
Type Description
Matrix

translate(t){Matrix}

D:/DEV_SRC/RxOT/DuAEF/DuESF/tools/build/output/DuESF.jsxinc, line 2740
Translate current matrix accumulative.
Name Type Description
`t` Array.<number> translation [x, y]. Any third value (Z) is ignored.
Type Description
Matrix