const transform = new CSSTransformValue([
new CSSTranslate(CSS.px(10), CSS.px(20)),
new CSSScale(2, 3),
]);
const matrix = transform.toMatrix();
console.log(matrix.a, matrix.d); // 2 3
console.log(matrix.e, matrix.f); // 10 20CSSTransformValue: toMatrix() method / notebook
CSSTransformValue: toMatrix() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const transform = new CSSTransformValue([
new CSSTranslate(CSS.percent(50), CSS.px(20)),
]);
try {
transform.toMatrix();
} catch (e) {
console.log(e); // TypeError
}