DOMMatrixReadOnly: rotate() 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 rotate()-Methode des DOMMatrixReadOnly-Interfaces gibt eine neue DOMMatrix zurück, die durch Drehen der Quellmatrix um jede ihrer Achsen um die angegebene Anzahl von Grad erstellt wird. Die ursprüngliche Matrix wird nicht verändert.

Um die Matrix während des Drehens zu verändern, siehe DOMMatrix.rotateSelf().

Syntax

js
rotate()
rotate(rotX)
rotate(rotX, rotY)
rotate(rotX, rotY, rotZ)

Parameter

rotX

Eine Zahl; die x-Koordinate des Vektors, der die Rotationsachse angibt. Wenn ungleich null, ist is2D false.

rotY Optional

Eine Zahl; die y-Koordinate des Vektors, der die Rotationsachse angibt. Wenn ungleich null, ist is2D false.

rotZ Optional

Eine Zahl; die z-Koordinate des Vektors, der die Rotationsachse angibt.

Wenn nur rotX übergeben wird, wird rotX als Wert für die z-Koordinate verwendet, und die x- und y-Koordinaten werden beide auf null gesetzt.

Rückgabewert

Eine DOMMatrix.

Beispiele

js
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.toString());
// output: "matrix(1, 0, 0, 1, 0, 0)"

const rotated = matrix.rotate(30); // rotation and assignment
console.log(matrix.toString()); // original matrix is unchanged
// output: "matrix(1, 0, 0, 1, 0, 0)"
console.log(rotated.toString());
// output: "matrix(0.866, 0.5, -0.5, 0.866, 0, 0)"

Spezifikationen

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

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
rotate()

Legend

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

Full support
Full support

Siehe auch