DOMMatrix 构造函数创建新 DOMMatrix object which represents 4x4 matrices, suitable for 2D and 3D operations..

句法

var domMatrix = new DOMMatrix([init])
					

参数

init 可选

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

范例

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);
					

规范

规范 状态 注释
Geometry Interfaces Module Level 1
The definition of 'DOMMatrix' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DOMMatrix() 构造函数 Chrome 45 Edge 79 Firefox 33 IE No Opera 32 Safari 11 WebView Android 61 Chrome Android 45 Firefox Android 33 Opera Android 32 Safari iOS 11 Samsung Internet Android 8.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改:
  1. DOMMatrix
  2. 构造函数
    1. DOMMatrix()
  3. 继承:
    1. DOMMatrixReadOnly
  4. Related pages for Geometry Interfaces
    1. CSSMatrix
    2. DOMMatrixReadOnly