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()方法