DOMMatrix: preMultiplySelf() 方法
注意:此功能在 Web Workers 中可用。
preMultiplySelf() 方法是 DOMMatrix 接口的一个方法,它通过将当前矩阵与指定的 DOMMatrix 进行前乘来修改当前矩阵。这等价于点积 B⋅A,其中矩阵 A 是源矩阵,B 是作为输入传递给该方法的矩阵。如果没有指定乘数矩阵,则当前矩阵将与一个除了右下角及其左上角元素(即 m33 和 m34)之外所有元素都为 0 的矩阵相乘。这些元素默认值为 1。
语法
js
preMultiplySelf()
preMultiplySelf(otherMatrix)
参数
返回值
返回自身;一个已更新为应用乘法结果的 DOMMatrix。
示例
js
const matrix = new DOMMatrix().translate(3, 22);
const otherMatrix = new DOMMatrix().translateSelf(15, 45);
console.log(matrix.toString()); // output: matrix(1, 0, 0, 1, 3, 22)
console.log(otherMatrix.toString()); // output: matrix(1, 0, 0, 1, 15, 45)
matrix.preMultiplySelf(otherMatrix);
console.log(matrix.toString()); // output: matrix(1, 0, 0, 1, 18, 67)
console.log(otherMatrix.toString()); // output: matrix(1, 0, 0, 1, 15, 45)
规范
| 规范 |
|---|
| Geometry Interfaces Module Level 1 # dom-dommatrix-premultiplyself |
浏览器兼容性
加载中…
另见
DOMMatrix.multiplySelf()DOMMatrixReadOnly.multiply()- CSS
matrix()函数 - CSS
matrix3d()函数