DOMMatrix: preMultiplySelf() メソッド
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月.
メモ: この機能はウェブワーカー内で利用可能です。
preMultiplySelf() は DOMMatrix インターフェイスのメソッドで、指定された DOMMatrix と行列を左から乗算することで行列を変更します。これは内積 B⋅A に相当し、ここで行列 A はソース行列、B はメソッドへの入力として指定された行列です。乗数として行列が指定されなかった場合、行列は右下隅と、その直上かつ左隣の要素(m33 と m34)を除き、すべての要素が 0 である行列と乗算されます。これらの要素はデフォルト値 1 を持ちます。
構文
js
preMultiplySelf()
preMultiplySelf(otherMatrix)
引数
otherMatrix省略可-
乗算する
DOMMatrixです。
返値
自分自身を返します。適用された乗算の結果に更新された DOMMatrix です。
例
js
const matrix = new DOMMatrix().translate(3, 22);
const otherMatrix = new DOMMatrix().translateSelf(15, 45);
console.log(matrix.toString()); // 出力: matrix(1, 0, 0, 1, 3, 22)
console.log(otherMatrix.toString()); // 出力: matrix(1, 0, 0, 1, 15, 45)
matrix.preMultiplySelf(otherMatrix);
console.log(matrix.toString()); // 出力: matrix(1, 0, 0, 1, 18, 67)
console.log(otherMatrix.toString()); // 出力: matrix(1, 0, 0, 1, 15, 45)
仕様書
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrix-premultiplyself> |
ブラウザーの互換性
関連情報
DOMMatrix.multiplySelf()DOMMatrixReadOnly.multiply()- CSS の
matrix()関数 - CSS の
matrix3d()関数