DOMMatrix: invertSelf() 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 invertSelf() của giao diện DOMMatrix nghịch đảo ma trận gốc. Nếu ma trận không thể nghịch đảo, tất cả các thành phần của ma trận mới sẽ được đặt thành NaN và thuộc tính is2D của nó được đặt thành false.
Để nghịch đảo ma trận mà không làm thay đổi nó, hãy xem DOMMatrixReadOnly.inverse()
Cú pháp
js
invertSelf()
Tham số
Không có.
Giá trị trả về
Một DOMMatrix.
Ví dụ
Trong ví dụ này, chúng ta tạo một ma trận với góc xoay 30 độ. Sau đó nghịch đảo nó, kết quả là góc xoay -30 độ.
js
const matrix = new DOMMatrix().rotate(30);
console.log(matrix.toString());
// output: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)
matrix.invertSelf();
console.log(matrix.toString());
// output: matrix(0.866, -0.5, 0.5, 0.866, 0, 0)
Thông số kỹ thuật
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrix-invertself> |
Tương thích trình duyệt
Xem thêm
DOMMatrixReadOnly.inverse()- CSS
matrix()function - CSS
matrix3d()function