DOMMatrixReadOnly: rotateFromVector() 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 rotateFromVector()-Methode des DOMMatrixReadOnly-Interfaces gibt eine neue DOMMatrix zurück, die durch Drehen der Ursprungsmatrix um den Winkel zwischen dem angegebenen Vektor und (1, 0) erstellt wurde. Der Drehwinkel wird durch den Winkel zwischen dem Vektor (1,0)T und (x,y)T im Uhrzeigersinn bestimmt, oder (+/-)arctan(y/x). Wenn x und y beide 0 sind, wird der Winkel als 0 angegeben. Die ursprüngliche Matrix wird nicht verändert.
Um die Matrix zu verändern, während Sie sie um den Winkel zwischen dem angegebenen Vektor und (1, 0) drehen, siehe DOMMatrix.rotateFromVectorSelf().
Syntax
rotateFromVector()
rotateFromVector(rotX)
rotateFromVector(rotX, rotY)
Parameter
rotXOptional-
Eine Zahl; Die x-Koordinate des x,y-Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0verwendet. rotYOptional-
Eine Zahl; Die y-Koordinate des x,y-Vektors, der den Drehwinkel bestimmt. Wenn nicht definiert, wird
0verwendet.
Rückgabewert
Eine DOMMatrix.
Beispiele
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.toString()); // original value
// output: "matrix(1, 0, 0, 1, 0, 0)"
console.log(matrix.rotateFromVector().toString()); // defaults to `0`
// output: matrix(1, 0, 0, 1, 0, 0)
console.log(matrix.rotateFromVector(10, 20).toString());
// matrix(0.447, 0.894, -0.894, 0.447, 0, 0)
console.log(matrix.rotateFromVector(-5, 5).toString());
// matrix(-0.707, 0.707, -0.707, -0.707, 0, 0)
console.log(matrix.toString()); // matrix remains unchanged
// output: "matrix(1, 0, 0, 1, 0, 0)"
Spezifikationen
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrixreadonly-rotatefromvector> |
Browser-Kompatibilität
Siehe auch
DOMMatrix.rotateFromVectorSelf()DOMMatrixReadOnly.rotate()DOMMatrixReadOnly.rotateAxisAngle()- CSS
transformEigenschaft undrotate3d()Funktion - CSS
rotateEigenschaft - CSS-Transformationen Modul
- SVG
transformAttribut CanvasRenderingContext2DInterface undrotate()Methode