const matrix = DOMMatrixReadOnly.fromMatrix({
a: 1,
b: 0,
c: 0,
d: 1,
e: 50,
f: 50,
is2D: true,
});
console.log(matrix.toString());
// Output: matrix(1, 0, 0, 1, 50, 50)
console.log(matrix.is2D);
// Output: trueDOMMatrixReadOnly: fromMatrix() static method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const matrix1 = new DOMMatrixReadOnly([1, 0, 0, 1, 100, 100]);
const matrix2 = DOMMatrixReadOnly.fromMatrix(matrix1);
console.log(matrix2.toString());
// Output: matrix(1, 0, 0, 1, 100, 100)const identityMatrix = DOMMatrixReadOnly.fromMatrix();
console.log(identityMatrix.toString());
// Output: matrix(1, 0, 0, 1, 0, 0)
console.log(identityMatrix.isIdentity);
// Output: true