DOMMatrix
The DOMMatrix interface represents 4×4 matrices, suitable for 2D and 3D operations including rotation and translation. It is a mutable version of the DOMMatrixReadOnly interface. The interface is available inside web workers.
Extends
Methods
flipX()
flipX(): DOMMatrix;
The flipX() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix flipped about the x-axis. This is equivalent to multiplying the matrix by DOMMatrix(-1, 0, 0, 1, 0, 0). The original matrix is not modified.
Returns
DOMMatrix
Inherited from
flipY()
flipY(): DOMMatrix;
The flipY() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix flipped about the y-axis. This is equivalent to multiplying the matrix by DOMMatrix(1, 0, 0, -1, 0, 0). The original matrix is not modified.
Returns
DOMMatrix
Inherited from
inverse()
inverse(): DOMMatrix;
The inverse() method of the DOMMatrixReadOnly interface creates a new matrix which is the inverse of the original matrix. If the matrix cannot be inverted, the new matrix's components are all set to NaN and its is2D property is set to false. The original matrix is not changed.
Returns
DOMMatrix
Inherited from
invertSelf()
invertSelf(): DOMMatrix;
The invertSelf() method of the DOMMatrix interface inverts the original matrix. If the matrix cannot be inverted, the new matrix's components are all set to NaN and its is2D property is set to false.
Returns
DOMMatrix
multiply()
multiply(other?): DOMMatrix;
The multiply() method of the DOMMatrixReadOnly interface creates and returns a new matrix which is the dot product of the matrix and the otherMatrix parameter. If otherMatrix is omitted, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immediately above and to its left: m33 and m34. These have the default value of 1. The original matrix is not modified.
Parameters
| Parameter | Type |
|---|---|
other? | DOMMatrixInit |
Returns
DOMMatrix
Inherited from
multiplySelf()
multiplySelf(other?): DOMMatrix;
The multiplySelf() method of the DOMMatrix interface multiplies a matrix by the otherMatrix parameter, computing the dot product of the original matrix and the specified matrix: A⋅B. If no matrix is specified as the multiplier, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immediately above and to its left: m33 and m34. These have the default value of 1.
Parameters
| Parameter | Type |
|---|---|
other? | DOMMatrixInit |
Returns
DOMMatrix
preMultiplySelf()
preMultiplySelf(other?): DOMMatrix;
The preMultiplySelf() method of the DOMMatrix interface modifies the matrix by pre-multiplying it with the specified DOMMatrix. This is equivalent to the dot product B⋅A, where matrix A is the source matrix and B is the matrix given as an input to the method. If no matrix is specified as the multiplier, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immediately above and to its left: m33 and m34. These have the default value of 1.
Parameters
| Parameter | Type |
|---|---|
other? | DOMMatrixInit |
Returns
DOMMatrix
rotate()
rotate(
rotX?,
rotY?,
rotZ?
): DOMMatrix;
The rotate() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by rotating the source matrix around each of its axes by the specified number of degrees. The original matrix is not altered.
Parameters
| Parameter | Type |
|---|---|
rotX? | number |
rotY? | number |
rotZ? | number |
Returns
DOMMatrix
Inherited from
rotateAxisAngle()
rotateAxisAngle(
x?,
y?,
z?,
angle?
): DOMMatrix;
The rotateAxisAngle() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by rotating the source matrix by the given vector and angle. The original matrix is not altered.
Parameters
| Parameter | Type |
|---|---|
x? | number |
y? | number |
z? | number |
angle? | number |
Returns
DOMMatrix
Inherited from
DOMMatrixReadOnly.rotateAxisAngle
rotateAxisAngleSelf()
rotateAxisAngleSelf(
x?,
y?,
z?,
angle?
): DOMMatrix;
The rotateAxisAngleSelf() method of the DOMMatrix interface is a transformation method that rotates the source matrix by the given vector and angle, returning the altered matrix.
Parameters
| Parameter | Type |
|---|---|
x? | number |
y? | number |
z? | number |
angle? | number |
Returns
DOMMatrix
rotateFromVector()
rotateFromVector(x?, y?): DOMMatrix;
The rotateFromVector() method of the DOMMatrixReadOnly interface is returns a new DOMMatrix created by rotating the source matrix by the angle between the specified vector and (1, 0). The rotation angle is determined by the angle between the vector (1,0)T and (x,y)T in the clockwise direction, or (+/-)arctan(y/x). If x and y are both 0, the angle is specified as 0. The original matrix is not altered.
Parameters
| Parameter | Type |
|---|---|
x? | number |
y? | number |
Returns
DOMMatrix
Inherited from
DOMMatrixReadOnly.rotateFromVector
rotateFromVectorSelf()
rotateFromVectorSelf(x?, y?): DOMMatrix;
The rotateFromVectorSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by rotating the matrix by the angle between the specified vector and (1, 0). The rotation angle is determined by the angle between the vector (1,0)T and (x,y)T in the clockwise direction, or (+/-)arctan(y/x). If x and y are both 0, the angle is specified as 0, and the matrix is not altered.
Parameters
| Parameter | Type |
|---|---|
x? | number |
y? | number |
Returns
DOMMatrix
rotateSelf()
rotateSelf(
rotX?,
rotY?,
rotZ?
): DOMMatrix;
The rotateSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix. It rotates the source matrix around each of its axes by the specified number of degrees and returns the rotated matrix.
Parameters
| Parameter | Type |
|---|---|
rotX? | number |
rotY? | number |
rotZ? | number |
Returns
DOMMatrix
scale()
scale(
scaleX?,
scaleY?,
scaleZ?,
originX?,
originY?,
originZ?
): DOMMatrix;
The scale() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix with a scale transform applied.
Parameters
| Parameter | Type |
|---|---|
scaleX? | number |
scaleY? | number |
scaleZ? | number |
originX? | number |
originY? | number |
originZ? | number |
Returns
DOMMatrix
Inherited from
scale3d()
scale3d(
scale?,
originX?,
originY?,
originZ?
): DOMMatrix;
The scale3d() method of the DOMMatrixReadOnly interface creates a new matrix which is the result of a 3D scale transform being applied to the matrix. It returns a new DOMMatrix created by scaling the source 3d matrix by the given scale factor centered on the origin point specified by the origin parameters, with a default origin of (0, 0, 0). The original matrix is not modified.
Parameters
| Parameter | Type |
|---|---|
scale? | number |
originX? | number |
originY? | number |
originZ? | number |
Returns
DOMMatrix
Inherited from
scale3dSelf()
scale3dSelf(
scale?,
originX?,
originY?,
originZ?
): DOMMatrix;
The scale3dSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor to all three axes, centered on the given origin, with a default origin of (0, 0, 0), returning the 3D-scaled matrix.
Parameters
| Parameter | Type |
|---|---|
scale? | number |
originX? | number |
originY? | number |
originZ? | number |
Returns
DOMMatrix
scaleNonUniform()
scaleNonUniform(scaleX?, scaleY?): DOMMatrix;
Parameters
| Parameter | Type |
|---|---|
scaleX? | number |
scaleY? | number |
Returns
DOMMatrix
Deprecated
Inherited from
DOMMatrixReadOnly.scaleNonUniform
scaleSelf()
scaleSelf(
scaleX?,
scaleY?,
scaleZ?,
originX?,
originY?,
originZ?
): DOMMatrix;
The scaleSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor, centered on the given origin, with a default origin of (0, 0), returning the scaled matrix.
Parameters
| Parameter | Type |
|---|---|
scaleX? | number |
scaleY? | number |
scaleZ? | number |
originX? | number |
originY? | number |
originZ? | number |
Returns
DOMMatrix
setMatrixValue()
setMatrixValue(transformList): DOMMatrix;
The setMatrixValue() method of the DOMMatrix interface replaces the contents of the matrix with the matrix described by the specified transform or transforms, returning itself.
Parameters
| Parameter | Type |
|---|---|
transformList | string |
Returns
DOMMatrix
skewX()
skewX(sx?): DOMMatrix;
The skewX() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its x-axis. The original matrix is not modified.
Parameters
| Parameter | Type |
|---|---|
sx? | number |
Returns
DOMMatrix
Inherited from
skewXSelf()
skewXSelf(sx?): DOMMatrix;
The skewXSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix. It skews the source matrix by applying the specified skew transformation along the X-axis and returns the skewed matrix.
Parameters
| Parameter | Type |
|---|---|
sx? | number |
Returns
DOMMatrix
skewY()
skewY(sy?): DOMMatrix;
The skewY() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its y-axis. The original matrix is not modified.
Parameters
| Parameter | Type |
|---|---|
sy? | number |
Returns
DOMMatrix
Inherited from
skewYSelf()
skewYSelf(sy?): DOMMatrix;
The skewYSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix. It skews the source matrix by applying the specified skew transformation along the Y-axis and returns the skewed matrix.
Parameters
| Parameter | Type |
|---|---|
sy? | number |
Returns
DOMMatrix
toFloat32Array()
toFloat32Array(): Float32Array<ArrayBuffer>;
The toFloat32Array() method of the DOMMatrixReadOnly interface returns a new Float32Array containing all 16 elements (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) which comprise the matrix. The elements are stored into the array as single-precision floating-point numbers in column-major (colexographical access, or "colex") order. (In other words, down the first column from top to bottom, then the second column, and so forth.)
Returns
Float32Array<ArrayBuffer>
Inherited from
DOMMatrixReadOnly.toFloat32Array
toFloat64Array()
toFloat64Array(): Float64Array<ArrayBuffer>;
The toFloat64Array() method of the DOMMatrixReadOnly interface returns a new Float64Array containing all 16 elements (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) which comprise the matrix. The elements are stored into the array as double-precision floating-point numbers in column-major (colexographical access, or "colex") order. (In other words, down the first column from top to bottom, then the second column, and so forth.)
Returns
Float64Array<ArrayBuffer>
Inherited from
DOMMatrixReadOnly.toFloat64Array
toJSON()
toJSON(): any;
The toJSON() method of the DOMMatrixReadOnly interface creates and returns a JSON object. The JSON object includes the 2D matrix elements a through f, the 16 elements of the 4X4 3D matrix, m[1-4][1-4], the boolean is2D property, and the boolean isIdentity property.
Returns
any
Inherited from
toString()
toString(): string;
Returns
string
Inherited from
transformPoint()
transformPoint(point?): DOMPoint;
The transformPoint method of the DOMMatrixReadOnly interface creates a new DOMPoint object, transforming a specified point by the matrix. Neither the matrix nor the original point are altered.
Parameters
| Parameter | Type |
|---|---|
point? | DOMPointInit |
Returns
Inherited from
DOMMatrixReadOnly.transformPoint
translate()
translate(
tx?,
ty?,
tz?
): DOMMatrix;
The translate() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix with a translation applied.
Parameters
| Parameter | Type |
|---|---|
tx? | number |
ty? | number |
tz? | number |
Returns
DOMMatrix
Inherited from
translateSelf()
translateSelf(
tx?,
ty?,
tz?
): DOMMatrix;
The translateSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix. It applies the specified vectors and returns the updated matrix. The default vector is [0, 0, 0].
Parameters
| Parameter | Type |
|---|---|
tx? | number |
ty? | number |
tz? | number |
Returns
DOMMatrix
Properties
a
a: number;
Overrides
b
b: number;
Overrides
c
c: number;
Overrides
d
d: number;
Overrides
e
e: number;
Overrides
f
f: number;
Overrides
is2D
readonly is2D: boolean;
The readonly is2D property of the DOMMatrixReadOnly interface is a Boolean flag that is true when the matrix is 2D. The value is true if the matrix was initialized as a 2D matrix and only 2D transformation operations were applied. Otherwise, the matrix is defined in 3D, and is2D is false.
Inherited from
isIdentity
readonly isIdentity: boolean;
The readonly isIdentity property of the DOMMatrixReadOnly interface is a Boolean whose value is true if the matrix is the identity matrix.
Inherited from
m11
m11: number;
Overrides
m12
m12: number;
Overrides
m13
m13: number;
Overrides
m14
m14: number;
Overrides
m21
m21: number;
Overrides
m22
m22: number;
Overrides
m23
m23: number;
Overrides
m24
m24: number;
Overrides
m31
m31: number;
Overrides
m32
m32: number;
Overrides
m33
m33: number;
Overrides
m34
m34: number;
Overrides
m41
m41: number;
Overrides
m42
m42: number;
Overrides
m43
m43: number;
Overrides
m44
m44: number;