このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

DOMMatrixReadOnly: multiply() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.

メモ: この機能はウェブワーカー内で利用可能です。

multiply()DOMMatrixReadOnly インターフェイスのメソッドで、指定された行列と otherMatrix 引数のドット積となる新しい行列を生成し、それを返します。otherMatrix が省略された場合、行列は右下隅と、その直上かつ左隣の要素(m33m34)を除き、すべての要素が 0 である行列と乗算されます。これらの要素はデフォルト値 1 を持ちます。元の行列は変更されません。

行列を乗算しつつ変化させるには、DOMMatrix.multiplySelf() を参照してください。

構文

js
multiply()
multiply(otherMatrix)

引数

otherMatrix 省略可

乗算する DOMMatrix です。

返値

DOMMatrix です。

js
const matrix = new DOMMatrixReadOnly().translate(13, 21);
const multipliedMatrix = matrix.multiply(matrix);
console.log(matrix.toString()); // 出力: matrix(1, 0, 0, 1, 13, 21)
console.log(multipliedMatrix.toString()); // 出力: matrix(1, 0, 0, 1, 26, 42)

仕様書

Specification
Geometry Interfaces Module Level 1
# dom-dommatrixreadonly-multiply

ブラウザーの互換性

関連情報