DOMMatrixReadOnly:multiply() 方法
注意:此功能在 Web Workers 中可用。
DOMMatrixReadOnly 接口的 multiply() 方法创建并返回一个新矩阵,该矩阵是当前矩阵与 otherMatrix 参数的点积。如果省略 otherMatrix,则当前矩阵将与一个矩阵相乘,该矩阵中除了右下角及其左上角的元素之外,所有元素均为 0。这些元素(m33 和 m34)的默认值为 1。原始矩阵不会被修改。
要在相乘时修改矩阵,请参阅 DOMMatrix.multiplySelf()。
语法
js
multiply()
multiply(otherMatrix)
参数
返回值
一个 DOMMatrix。
示例
js
const matrix = new DOMMatrixReadOnly().translate(13, 21);
const multipliedMatrix = matrix.multiply(matrix);
console.log(matrix.toString()); // output: matrix(1, 0, 0, 1, 13, 21)
console.log(multipliedMatrix.toString()); // output: matrix(1, 0, 0, 1, 26, 42)
规范
| 规范 |
|---|
| Geometry Interfaces Module Level 1 # dom-dommatrixreadonly-multiply |
浏览器兼容性
加载中…
另见
DOMMatrix.multiplySelf()DOMMatrix.preMultiplySelf()- CSS
matrix()函数 - CSS
matrix3d()函数