DOMMatrix: invertSelf() Methode

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.

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die invertSelf() Methode des DOMMatrix Interfaces invertiert die ursprüngliche Matrix. Wenn die Matrix nicht invertiert werden kann, werden die Komponenten der neuen Matrix alle auf NaN gesetzt und ihre is2D Eigenschaft wird auf false gesetzt.

Um eine Matrix zu invertieren, ohne sie zu verändern, siehe DOMMatrixReadOnly.inverse().

Syntax

js
invertSelf()

Rückgabewert

Eine DOMMatrix.

Beispiele

In diesem Beispiel erstellen wir eine Matrix mit einer Drehung von 30 Grad. Dann invertieren wir sie, was zu einer Drehung von -30 Grad führt.

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)

Spezifikationen

Specification
Geometry Interfaces Module Level 1
# dom-dommatrix-invertself

Browser-Kompatibilität

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

Siehe auch