DOMMatrixReadOnly: multiply() method
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
Phương thức multiply() của giao diện DOMMatrixReadOnly tạo và trả về một ma trận mới là tích vô hướng của ma trận và tham số otherMatrix. Nếu otherMatrix bị bỏ qua, ma trận sẽ được nhân với một ma trận trong đó mọi phần tử đều là 0 ngoại trừ góc dưới bên phải và phần tử ngay phía trên bên trái của nó: m33 và m34. Các giá trị mặc định của chúng là 1. Ma trận gốc không bị thay đổi.
Để thay đổi ma trận khi nhân, hãy xem DOMMatrix.multiplySelf().
Cú pháp
js
multiply()
multiply(otherMatrix)
Tham số
otherMatrixOptional-
Ma trận thừa số
DOMMatrix.
Giá trị trả về
Một DOMMatrix.
Ví dụ
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)
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrixreadonly-multiply> |
Tương thích trình duyệt
Xem thêm
DOMMatrix.multiplySelf()DOMMatrix.preMultiplySelf()- CSS
matrix()function - CSS
matrix3d()function