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
  DOMMatrix.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

BCD tables only load in the browser

See also