DOMMatrixReadOnly:isIdentity 属性
注意:此功能在 Web Workers 中可用。
DOMMatrixReadOnly 接口的只读 isIdentity 属性是一个布尔值,如果矩阵是单位矩阵,则该属性值为 true。
单位矩阵是一种矩阵,其中所有值都为 0,除了从左上角到右下角的主对角线上的值(换句话说,每个方向上的偏移量都相等)。
值
一个布尔值。
示例
js
// Initialize a 2D matrix
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.isIdentity); // output: true
// Apply a transform that has no effect
console.log(matrix.translate(0).isIdentity); // output: true
// Apply a transform with effect: this rotates the matrix by 30deg
console.log(matrix.rotate(30).isIdentity); // output: false
规范
| 规范 |
|---|
| Geometry Interfaces Module Level 1 # dom-dommatrixreadonly-isidentity |
浏览器兼容性
加载中…
另见
DOMMatrix接口CSSMatrixComponent接口CanvasRenderingContext2D接口- CSS
matrix()函数 - CSS
transform属性 - CSS 变换模块
- SVG
transform属性