DOMMatrixReadOnly: inverse() メソッド
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2020年1月以降、すべてのブラウザーで利用可能です。
メモ: この機能はウェブワーカー内で利用可能です。
inverse() は DOMMatrixReadOnly インターフェイスのメソッドで、元の行列の逆行列となる新しい行列を作成します。行列が逆行列化できない場合、新しい行列の要素はすべて NaN に設定され、その is2D プロパティは false に設定されます。元の行列は変更されません。
行列を変更して逆行列を作成する場合は、DOMMatrix.invertSelf() を参照してください。
構文
js
inverse()
引数
なし。
返値
DOMMatrix です。
例
js
const matrix = new DOMMatrixReadOnly().rotate(30);
const invertedMatrix = matrix.inverse();
console.log(matrix.toString());
// 出力: matrix(0.866, 0.5, -0.5, 0.866, 0, 0)
console.log(invertedMatrix.toString());
// 出力: matrix(0.866, -0.5, 0.5, 0.866, 0, 0)
仕様書
| 仕様書 |
|---|
| Geometry Interfaces Module Level 1> # dom-dommatrixreadonly-inverse> |