DOMMatrixReadOnly: rotateFromVector() method
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.
Note: This feature is available in Web Workers.
Phương thức rotateFromVector() của giao diện DOMMatrixReadOnly trả về một DOMMatrix mới được tạo bằng cách xoay ma trận nguồn theo góc giữa vectơ được chỉ định và (1, 0). Góc xoay được xác định bởi góc giữa vectơ (1,0)T và (x,y)T theo chiều kim đồng hồ, hoặc (+/-)arctan(y/x). Nếu cả x và y đều là 0, góc được xác định là 0. Ma trận gốc không bị thay đổi.
Để thay đổi ma trận khi xoay theo góc giữa vectơ được chỉ định và (1, 0), hãy xem DOMMatrix.rotateFromVectorSelf().
Cú pháp
rotateFromVector()
rotateFromVector(rotX)
rotateFromVector(rotX, rotY)
Tham số
rotXOptional-
Một số; tọa độ x của vectơ x,y xác định góc xoay. Nếu không được xác định,
0được sử dụng. rotYOptional-
Một số; tọa độ y của vectơ x,y xác định góc xoay. Nếu không được xác định,
0được sử dụng.
Giá trị trả về
Một DOMMatrix.
Ví dụ
const matrix = new DOMMatrix(); // tạo một ma trận
console.log(matrix.toString()); // giá trị gốc
// output: "matrix(1, 0, 0, 1, 0, 0)"
console.log(matrix.rotateFromVector().toString()); // mặc định là `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()); // ma trận không thay đổi
// output: "matrix(1, 0, 0, 1, 0, 0)"
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrixreadonly-rotatefromvector> |
Tương thích trình duyệt
Xem thêm
DOMMatrix.rotateFromVectorSelf()DOMMatrixReadOnly.rotate()DOMMatrixReadOnly.rotateAxisAngle()- CSS
transformproperty androtate3d()function - CSS
rotateproperty - CSS transforms module
- SVG
transformattribute CanvasRenderingContext2Dinterface androtate()method