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()函式