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 Januar 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die rotate()-Methode des DOMMatrixReadOnly-Interfaces gibt eine neue DOMMatrix zurück, die durch das 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 beim Drehen zu ändern, siehe DOMMatrix.rotateSelf().
Syntax
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
is2Dfalse. rotYOptional-
Eine Zahl; die y-Koordinate des Vektors, der die Rotationsachse angibt. Wenn ungleich null, ist
is2Dfalse. rotZOptional-
Eine Zahl; die z-Koordinate des Vektors, der die Rotationsachse angibt.
Wenn nur rotX übergeben wird, dann 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
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
Siehe auch
DOMMatrix.rotateSelf()DOMMatrixReadOnly.rotateAxisAngle()DOMMatrixReadOnly.rotateFromVector()- CSS
transformEigenschaft undrotate3d()Funktion - CSS
rotateEigenschaft - CSS-Transformationen Modul
- SVG
transformAttribut CanvasRenderingContext2DInterface undrotate()Methode