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 der DOMMatrixReadOnly
-Schnittstelle gibt eine neue DOMMatrix
zurück, die durch das Drehen der Ursprungsmatrix um jede ihrer Achsen um die angegebene Anzahl von Grad erstellt wurde. 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. Ist dieser Wert ungleich null, ist
is2D
falsch. rotY
Optional-
Eine Zahl; die y-Koordinate des Vektors, der die Rotationsachse angibt. Ist dieser Wert ungleich null, ist
is2D
falsch. 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
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
transform
-Eigenschaft undrotate3d()
-Funktion - CSS
rotate
-Eigenschaft - CSS-Transformationen Modul
- SVG
transform
Attribut CanvasRenderingContext2D
Schnittstelle undrotate()
Methode