DOMMatrix: invertSelf() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
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
.
To invert a matrix without mutating it, see DOMMatrixReadOnly.inverse()
Syntax
js
invertSelf()
Return value
A DOMMatrix
.
Examples
In this example, we create a matrix with a rotation of 30deg. Then invert it, resulting in a rotation of -30deg.
js
const matrix = new DOMMatrix().rotate(30);
console.log(matrix.toString());
// output: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)
matrix.invertSelf();
console.log(matrix.toString());
// output: matrix(0.866, -0.5, 0.5, 0.866, 0, 0)
Specifications
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dommatrix-invertself |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
invertSelf |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.
See also
DOMMatrixReadOnly.inverse()
- CSS
matrix()
function - CSS
matrix3d()
function