Web/API/DOMMatrix/DOMMatrix

From Get docs

The DOMMatrix constructor creates a new DOMMatrix object which represents 4x4 matrices, suitable for 2D and 3D operations..

Syntax

var domMatrix = new DOMMatrix([init])

Parameters

init Optional
A string containing a sequence of numbers or an array of numbers specifying the matrix you want to create, or a CSS transform string.

Example

This example creates a DOMMatrix to use as an argument for calling Point.matrixTransform().

var point = new DOMPoint(5, 4);
var scaleX = 2;
var scaleY = 3;
var translateX = 12;
var translateY = 8;
var angle = Math.PI / 2;
var matrix = new DOMMatrix([
  Math.sin(angle) * scaleX,
  Math.cos(angle) * scaleX,
  -Math.sin(angle) * scaleY,
  Math.cos(angle) * scaleY,
  translateX,
  translateY
]);
var transformedPoint = point.matrixTransform(matrix);

Specifications

Specification Status Comment
Geometry Interfaces Module Level 1The definition of 'DOMMatrix' in that specification. Candidate Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DOMMatrix() constructor Chrome

Full support 61

Edge

Full support 79

Firefox

Full support 33

IE

No support No

Opera

Full support 48

Safari

Full support 11

WebView Android

Full support 61

Chrome Android

Full support 61

Firefox Android

Full support 33

Opera Android

Full support 45

Safari iOS

Full support 11

Samsung Internet Android

Full support 8.0

Legend

Full support  
Full support
No support  
No support