DOMMatrix:rotateFromVectorSelf() 方法
注意:此功能在 Web Workers 中可用。
DOMMatrix 介面的 rotateFromVectorSelf() 方法是一個可變的變換方法,它透過將矩陣按指定向量與 (1, 0) 之間的角度進行旋轉來修改矩陣。旋轉角度由向量 (1,0)T 和 (x,y)T 之間順時針方向的角度確定,即 (+/-)arctan(y/x)。如果 x 和 y 都為 0,則角度指定為 0,矩陣不會被修改。
要從向量旋轉矩陣而不改變原矩陣,請參閱 DOMMatrixReadOnly.rotateFromVector(),它會建立一個新的旋轉後的矩陣,而保持原矩陣不變。
語法
js
rotateFromVectorSelf()
rotateFromVectorSelf(rotX)
rotateFromVectorSelf(rotX, rotY)
引數
返回值
返回自身;更新後的 DOMMatrix。
示例
js
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.rotateFromVectorSelf().toString());
// output: matrix(1, 0, 0, 1, 0, 0) (no rotation applied)
console.log(matrix.rotateFromVectorSelf(10, 20).toString());
// output: matrix(0.447, 0.894, -0.894, 0.447, 0, 0)
console.log(matrix.toString());
// output: matrix(0.447, 0.894, -0.894, 0.447, 0, 0) (same as above)
規範
| 規範 |
|---|
| Geometry Interfaces Module Level 1 # dom-dommatrix-rotatefromvectorself |
瀏覽器相容性
載入中…
另見
DOMMatrixReadOnly.rotateFromVector()DOMMatrix.rotateSelf()DOMMatrix.rotateAxisAngleSelf()- CSS
transform屬性和rotate3d()函式 - CSS
rotate屬性 - CSS 變換模組
- SVG
transform屬性 CanvasRenderingContext2D介面和rotate()方法