The DOMMatrix interface represents 4x4 matrices, suitable for 2D and 3D operations.
A 4x4 matrix is suitable to describe any rotation and translation in 3D.
This interface should be available inside Web workers, though some implementations don't allow it yet.
Constructor
DOMMatrix()- Creates a new DOMMatrix object.
Properties
This interface inherits properties from DOMMatrixReadOnly, though some are modified not to be read-only.
is2DRead only- A
booleanflag set to true if current matrix was initialized as a 2D matrix isIdentityRead only- A
booleanflag returning true if the current matrix is identity. m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44- Are
doublerepresenting each component of a 4x4 matrix. a,b,c,d,e,f- Are
doublerepresenting each component of a 4x4 matrix needed for 2D rotations and translations. They are aliases for some components of the 4x4 matrix:2D3D equivalentam11bm12cm21dm22em41fm42
Methods
This interface inherits methods from DOMMatrixReadOnly.
DOMMatrixReadOnly.multiplySelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being multiplied by the givenDOMMatrix. DOMMatrixReadOnly.preMultiplySelf()- Returns itself, a
DOMMatrix, with its new content being the result of the givenDOMMatrixbeing multiplied by the original matrix. DOMMatrix.translateSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the matrix being translated by the given vector. DOMMatrix.scaleSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the matrix x and y dimensions being scaled by the given factor, centered on the origin given. DOMMatrix.scale3dSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the matrix x, y and z dimension being scaled by the given factor, centered on the origin given. DOMMatrix.scaleNonUniformSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the matrix x, y and z dimension being scaled by the given factor for each dimension, centered on the origin given. DOMMatrix.rotateSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being rotated by the given angle, with the rotation centered on the origin given. DOMMatrix.rotateFromVectorSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being rotated by the angle between the given vector and (1,0), centered on the origin given. DOMMatrix.rotateAxisAngleSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being rotated by the given angle and the give vector. DOMMatrix.skewXSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being skewed along the x-axis by the given factor. DOMMatrix.skewYSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being skewed along the y-axis by the given factor. DOMMatrix.invertSelf()- Returns itself, a
DOMMatrix, with its new content being the result of the original matrix being inverted. If the matrix cannot be inverted, all its components are set toNaNandis2D()returnsfalse. DOMMatrix.setMatrixValue()- Returns itself, a
DOMMatrix, with its describing the matrix representing the same transformation as the CSStransformfunctions given in parameter.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Geometry Interfaces Module Level 1 The definition of 'DOMMatrix' in that specification. |
Candidate Recommendation | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Basic support | Chrome Full support 61 | Edge No support No | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari No support No | WebView Android Full support 61 | Chrome Android Full support 61 | Edge Mobile No support No | Firefox Android Full support 33 | Opera Android Full support 48 | Safari iOS No support No | Samsung Internet Android ? |
| Support in web workers | Chrome Full support 61 | Edge No support No | Firefox No support No | IE No support No | Opera Full support 48 | Safari No support No | WebView Android Full support 61 | Chrome Android Full support 61 | Edge Mobile No support No | Firefox Android No support No | Opera Android Full support 48 | Safari iOS No support No | Samsung Internet Android ? |
DOMMatrix() constructor | Chrome Full support 61 | Edge No support No | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari No support No | WebView Android Full support 61 | Chrome Android Full support 61 | Edge Mobile No support No | Firefox Android Full support 33 | Opera Android Full support 48 | Safari iOS No support No | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
- Its non-modifiable part,
DOMMatrixReadOnly SVGMatrix, the SVG matrix intended to be superseded byDOMMatrix

