new Matrix()
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2856
2D transformation matrix object initialized with identity matrix.
- Version:
- 2.7.5
- Copyright:
- Epistemex.com 2014-2018
- License:
- MIT license (header required)
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 |
Methods
-
staticMatrix.from(a, b, c, d, e, f, context){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2904 -
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/DuPSF/tools/output/DuPSF.jsxinc, line 3158 -
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/DuPSF/tools/output/DuPSF.jsxinc, line 3221 -
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/DuPSF/tools/output/DuPSF.jsxinc, line 3096 -
Decompose the current matrix into simple transforms using QR.
Returns:
Type Description * - an object containing current decomposed values (translate, rotation, scale, skew) -
determinant(){number}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3146 -
Returns the determinant of the current matrix.
Returns:
Type Description number -
inverse(cloneContext){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3071 -
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 invertibleReturns:
Type Description Matrix - new Matrix instance -
isEqual(m){boolean}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3202 -
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 Returns:
Type Description boolean -
isIdentity(){boolean}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3171 -
Returns true if matrix is an identity matrix (no transforms applied).
Returns:
Type Description boolean -
isInvertible(){boolean}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3180 -
Returns true if matrix is invertible
Returns:
Type Description boolean -
isValid(){boolean}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3192 -
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.
Returns:
Type Description boolean -
multiply(m){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3058 -
Multiplies current matrix with source matrix.
Name Type Description m
Matrix | Matrix | DOMMatrix | SVGMatrix source matrix to multiply with. Returns:
Type Description Matrix -
reset(){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2926 -
Short-hand to reset current matrix to an identity matrix.
Returns:
Type Description Matrix -
rotate(angle){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2935 -
Rotates current matrix by angle (accumulative).
Name Type Description angle
number angle in degrees Returns:
Type Description Matrix -
rotateFromVector(x, y){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2952 -
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 Returns:
Type Description Matrix -
scale(s){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2961 -
Scales current matrix accumulative.
Name Type Description s
Array.<number> scale factor [x, y]. 1 does nothing, any third value (Z) is ignored. Returns:
Type Description Matrix -
setTransform(a, b, c, d, e, f){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2996 -
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 Returns:
Type Description Matrix -
shear(sx, sy){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2971 -
Apply shear to the current matrix accumulative.
Name Type Description sx
number amount of shear for x sy
number amount of shear for y Returns:
Type Description Matrix -
skew(ax, ay){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 2982 -
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 Returns:
Type Description Matrix -
toCSS(){string}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3231 -
Generates a string that can be used with CSS `transform`.
Returns:
Type Description string Example
element.style.transform = m.toCSS();
-
toCSS3D(){string}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3243 -
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.
Returns:
Type Description string Example
element.style.transform = m.toCSS3D();
-
toJSON(){string}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3252 -
Returns a JSON compatible string of current matrix.
Returns:
Type Description string -
transform(a2, b2, c2, d2, e2, f2){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3027 -
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 Returns:
Type Description Matrix -
translate(t){Matrix}
D:/DEV_SRC/RxOT/DuPSF/tools/output/DuPSF.jsxinc, line 3012 -
Translate current matrix accumulative.
Name Type Description t
Array.<number> translation [x, y]. Any third value (Z) is ignored. Returns:
Type Description Matrix