DOMMatrix:multiplySelf() 方法

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流浏览器均已支持。

注意:此功能在 Web Workers 中可用。

multiplySelf() 方法是 DOMMatrix 接口的一个方法,它将矩阵与 otherMatrix 参数相乘,计算原始矩阵与指定矩阵的点积:A⋅B。如果未指定乘数矩阵,则矩阵会乘以一个矩阵,该矩阵中除了右下角及其左上方和左侧紧邻的元素(m33m34)之外,所有元素均为 0。这些元素具有默认值 1

要相乘矩阵而不改变它,请参阅 DOMMatrixReadOnly.multiply()

语法

js
multiplySelf()
multiplySelf(otherMatrix)

参数

otherMatrix 可选

DOMMatrix 乘数。

返回值

返回自身;根据应用乘法的结果更新的 DOMMatrix

示例

js
const matrix = new DOMMatrix().rotate(30);

console.log(matrix.toString());
// output: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)

matrix.multiplySelf(matrix);

console.log(matrix.toString());
// output: matrix(0.5, 0.866, -0.866, 0.5, 0, 0) (a 60deg rotation)

规范

规范
Geometry Interfaces Module Level 1
# dom-dommatrix-multiplyself

浏览器兼容性

另见