DOMMatrixReadOnly: inverse() 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 inverse() Methode des DOMMatrixReadOnly-Interfaces erstellt eine neue Matrix, die das Inverse der ursprünglichen Matrix darstellt. 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. Die ursprüngliche Matrix bleibt unverändert.

Um die Matrix zu verändern, während Sie sie invertieren, siehe DOMMatrix.invertSelf().

Syntax

js
inverse()

Rückgabewert

Eine DOMMatrix.

Beispiele

js
const matrix = new DOMMatrixReadOnly().rotate(30);
const invertedMatrix = matrix.inverse();
console.log(matrix.toString());
// output: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)
console.log(invertedMatrix.toString());
// output: matrix(0.866, -0.5, 0.5, 0.866, 0, 0)

Spezifikationen

Specification
Geometry Interfaces Module Level 1
# dom-dommatrixreadonly-inverse

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch