DOMMatrixReadOnly:rotateFromVector() 方法
注意:此功能在 Web Workers 中可用。
DOMMatrixReadOnly 介面的 rotateFromVector() 方法會返回一個新的 DOMMatrix 物件,該物件由源矩陣圍繞指定向量與 (1, 0) 之間的角度進行旋轉而建立。旋轉角度由向量 (1,0)T 與 (x,y)T 之間順時針方向的角度確定,即 (+/-)arctan(y/x)。如果 x 和 y 都為 0,則角度指定為 0。原始矩陣不會被修改。
要修改矩陣,使其圍繞指定向量與 (1, 0) 之間的角度旋轉,請參閱 DOMMatrix.rotateFromVectorSelf()。
語法
js
rotateFromVector()
rotateFromVector(rotX)
rotateFromVector(rotX, rotY)
引數
返回值
一個 DOMMatrix。
示例
js
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)"
規範
| 規範 |
|---|
| Geometry Interfaces Module Level 1 # dom-dommatrixreadonly-rotatefromvector |
瀏覽器相容性
載入中…
另見
DOMMatrix.rotateFromVectorSelf()DOMMatrixReadOnly.rotate()DOMMatrixReadOnly.rotateAxisAngle()- CSS
transform屬性和rotate3d()函式 - CSS
rotate屬性 - CSS 變換模組
- SVG
transform屬性 CanvasRenderingContext2D介面和rotate()方法