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

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 GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
invertSelf

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also