The DOMMatrixReadOnly interface represents a read-only 4×4 matrix, suitable for 2D and 3D operations. The DOMMatrix interrface—which is based upon DOMMatrixReadOnly—adds mutability, allowing you to alter the matrix after creating it. A 4×4 matrix is suitable to describe any rotation and translation in 3D.
This interface should be available inside web workers, though some implementations doesn't allow it yet.
Properties
This interface doesn't inherit any properties.
is2DRead only- A Boolean flag whose value is
trueif the matrix was initialized as a 2D matrix. Iffalse, the matrix is 3D. isIdentityRead only- A Boolean whose value is
trueif the matrix is the identity matrix. The identity matrix is one in which every value is0except those on the main diagonal from top-left to bottom-right corner (in other words, where the offsets in each direction are equal). m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44- Double-precision floating-point values representing each component of a 4×4 matrix, where
m11throughm14are the first column,m21throughm24are the second column, and so forth. a,b,c,d,e,f-
Double-precision floating-point values representing the components of a 4×4 matrix which are required in order to perform 2D rotations and translations. These are aliases for specific components of a 4×4 matrix, as shown below.
2D 3D equivalent am11bm12cm21dm22em41fm42
Methods
This interface doesn't inherit any methods. None of the following methods alter the original matrix.
DOMMatrixReadOnly.flipX()- Returns a new
DOMMatrixcreated by flipping the source matrix around its X-axis. This is equivalent to multiplying the matrix byDOMMatrix(-1, 0, 0, 1, 0, 0). The original matrix is not modified. DOMMatrixReadOnly.flipY()- Returns a new
DOMMatrixcreated by flipping the source matrix around its Y-axis. This is equivalent to multiplying the matrix byDOMMatrix(1, 0, 0, -1, 0, 0). The original matrix is not modified. DOMMatrixReadOnly.inverse()- Returns a new
DOMMatrixcreated by inverting the source matrix. If the matrix cannot be inverted, the new matrix's components are all set toNaNand itsis2Dproperty is set tofalse. The original matrix is not altered. DOMMatrixReadOnly.multiply()- Returns a new
DOMMatrixcreated by computing the dot product of the source 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 is0except the bottom-right corner and the element immediately above and to its left:m33andm34. These have the default value of1. The original matrix is not modified. DOMMatrixReadOnly.rotateAxisAngle()- Returns a new
DOMMatrixcreated by rotating the source matrix by the given angle around the specified vector. The original matrix is not modified. DOMMatrixReadOnly.rotate()- Returns a new
DOMMatrixcreated by rotating the source matrix around each of its axes by the specified number of degrees. The original matrix is not altered. DOMMatrixReadOnly.rotateFromVector()- Returns a new
DOMMatrixcreated by rotating the source matrix by the angle between the specified vector and(1, 0). The original matrix is not modified. DOMMatrixReadOnly.scale()- Returns a new
DOMMatrixcreated by scaling the source matrix by the amount specified for each axis, centered on the given origin. By default, the X and Z axes are scaled by1and the Y axis has no default scaling value. The default origin is(0, 0, 0). The original matrix is not modified. DOMMatrixReadOnly.scale3d()- Returns a new
DOMMatrixcreated by scaling the source 3D matrix by the given factor along all its axes, centered on the specified origin point. The default origin is(0, 0, 0). The original matrix is not modified. DOMMatrixReadOnly.scaleNonUniform()- Returns a new
DOMMatrixcreated by applying the specified scaling on the X, Y, and Z axes, centered at the given origin. By default, the Y and Z axes' scaling factors are both1, but the scaling factor for X must be specified. The default origin is(0, 0, 0). The original matrix is not changed. DOMMatrixReadOnly.skewX()- Returns a new
DOMMatrixcreated by applying the specified skew transformation to the source matrix along its X-axis. The original matrix is not modified. DOMMatrixReadOnly.skewY()- Returns a new
DOMMatrixcreated by applying the specified skew transformation to the source matrix along its Y-axis. The original matrix is not modified. DOMMatrixReadOnly.toFloat32Array()- Returns a new
Float32Arraycontaining 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.) DOMMatrixReadOnly.toFloat64Array()- Returns a new
Float64Arraycontaining 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 access or "colex") order. (In other words, down the first column from top to bottom, then the second column, and so forth.) DOMMatrixReadOnly.toJSON()- Returns a JSON representation of the
DOMMatrixReadOnlyobject. DOMMatrixReadOnly.toString()-
Creates and returns a
DOMStringobject which contains a string representation of the matrix in CSS matrix syntax, using the appropriate CSS matrix notation. See thematrix()CSS function for details on this syntax.For a 2D matrix, the elements
athroughfare listed, for a total of six values and the formmatrix(a, b, c, d, e, f).For a 3D matrix, the returned string contains all 16 elements and takes the form
matrix3d(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44). See the CSSmatrix3d()function for details on the 3D notation's syntax.Throws an
InvalidStateErrorexception if any of the elements in the matrix are non-finite (even if, in the case of a 2D matrix, the non-finite values are in elements not used by the 2D matrix representation). DOMMatrixReadOnly.transformPoint()- Transforms the specified point using the matrix, returning a new
DOMPointobject containing the transformed point. Neither the matrix nor the original point are altered. DOMMatrixReadOnly.translate()- Returns a new
DOMMatrixcontaining a matrix calculated by translating the source matrix using the specified vector. By default, the vector is(0, 0, 0). The original matrix is not changed.
Static methods
This interface inherits methods from DOMMatrixReadOnly.
fromFloat32Array()- Creates a new mutable
DOMMatrixobject given an array of single-precision (32-bit) floating-point values. If the array has six values, the result is a 2D matrix; if the array has 16 values, the result is a 3D matrix. Otherwise, aTypeErrorexception is thrown. fromFloat64Array()- Creates a new mutable
DOMMatrixobject given an array of double-precision (64-bit) floating-point values. If the array has six values, the result is a 2D matrix; if the array has 16 values, the result is a 3D matrix. Otherwise, aTypeErrorexception is thrown. fromMatrix()- Creates a new mutable
DOMMatrixobject given an existing matrix or aDOMMatrixInitdictionary which provides the values for its properties. If no matrix is specified, the matrix is initialized with every element set to0except the bottom-right corner and the element immediately above and to its left:m33andm34. These have the default value of1.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Geometry Interfaces Module Level 1 The definition of 'DOMMatrixReadOnly' in that specification. |
Candidate Recommendation | Initial definition |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
DOMMatrixReadOnly | Chrome
Full support
61
| Edge
Full support
79
| Firefox Full support 33 | IE No support No | Opera
Full support
48
| Safari Full support 11 | WebView Android Full support 61 | Chrome Android
Full support
61
| Firefox Android Full support 33 | Opera Android
Full support
48
| Safari iOS Full support 11 | Samsung Internet Android Full support 8.0 |
DOMMatrixReadOnly() constructor | Chrome Full support 57 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 57 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
a | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
b | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
c | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
d | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
e | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
f | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
flipX() | Chrome Full support 54 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 41 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 54 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
flipY() | Chrome Full support 54 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 41 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 54 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
fromMatrix() static function | Chrome Full support 55 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 42 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 55 | Firefox Android Full support 33 | Opera Android Full support 42 | Safari iOS Full support 11 | Samsung Internet Android Full support 8.0 |
inverse() | Chrome Full support 55 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 42 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 55 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
is2D | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
isIdentity | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m11 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m12 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m13 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m14 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m21 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m22 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m23 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m24 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m31 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m32 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m33 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m34 | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m41 | Chrome Full support 61 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m42 | Chrome Full support 61 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m43 | Chrome Full support 61 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
m44 | Chrome Full support 61 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 48 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
multiply() | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
rotate() | Chrome Full support 56 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 43 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
rotateAxisAngle() | Chrome Full support 56 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 43 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
rotateFromVector() | Chrome Full support 56 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 43 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
scale() | Chrome Full support 45 | Edge Full support 79 | Firefox
Full support
33
| IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android
Partial support
33
| Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
scale3d() | Chrome Full support 45 | Edge Full support 79 | Firefox
Full support
33
| IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android
Full support
33
| Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
scaleNonUniform() | Chrome No support 45 — 56 | Edge No support No | Firefox No support 33 — 69 | IE No support No | Opera No support 32 — 43 | Safari No support No | WebView Android No support No | Chrome Android No support 45 — 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS No support No | Samsung Internet Android No support No |
scaleNonUniformSelf() | Chrome No support 45 — 56 | Edge No support No | Firefox No support 33 — 69 | IE No support No | Opera No support 32 — 43 | Safari No support No | WebView Android No support No | Chrome Android No support 45 — 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS No support No | Samsung Internet Android No support No |
skewX() | Chrome Full support 54 | Edge Full support 79 | Firefox
Full support
33
| IE No support No | Opera Full support 41 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 54 | Firefox Android
Full support
33
| Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
skewY() | Chrome Full support 54 | Edge Full support 79 | Firefox
Full support
33
| IE No support No | Opera Full support 41 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 54 | Firefox Android
Full support
33
| Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
toFloat32Array() | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
toFloat64Array() | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
toJSON() | Chrome Full support 56 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 43 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
toString() | Chrome Full support 54 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 41 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 54 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
transform() | Chrome Full support 61 | Edge Full support 79 | Firefox
Full support
33
| IE No support No | Opera Full support 48 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 61 | Firefox Android
Full support
33
| Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
transformPoint() | Chrome Full support 56 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 43 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 56 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
translate() | Chrome Full support 45 | Edge Full support 79 | Firefox Full support 33 | IE No support No | Opera Full support 32 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 45 | Firefox Android Full support 33 | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
| Available in workers | Chrome Full support 57 | Edge Full support 79 | Firefox Full support 69 | IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 61 | Chrome Android Full support 57 | Firefox Android No support No | Opera Android Full support 45 | Safari iOS Full support 11.3 | Samsung Internet Android Full support 8.0 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
