Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. DOMMatrixReadOnly

DOMMatrixReadOnly

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨January 2020⁩.

Note: This feature is available inWeb Workers.

TheDOMMatrixReadOnly interface represents a read-only 4×4 matrix, suitable for 2D and 3D operations. TheDOMMatrix interface — which is based uponDOMMatrixReadOnly—addsmutability, allowing you to alter the matrix after creating it.

This interface should be available insideweb workers, though some implementations doesn't allow it yet.

Constructor

DOMMatrixReadOnly()

Creates a newDOMMatrixReadOnly object.

Instance properties

This interface doesn't inherit any properties.

DOMMatrixReadOnly.is2DRead only

A Boolean flag whose value istrue if the matrix was initialized as a 2D matrix. Iffalse, the matrix is 3D.

DOMMatrixReadOnly.isIdentityRead only

A Boolean whose value istrue if the matrix is anidentity matrix.

m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44

Double-precision floating-point values representing each component of a 4×4 matrix, wherem11 throughm14 are the first column,m21 throughm24 are the second column, and so forth.

a,b,c,d,e,f

Double-precision floating-point values representing the components of a 4×4 matrix which are required in order to perform 2D rotations and translations. These are aliases for specific components of a 4×4 matrix, as shown below.

2D3D equivalent
am11
bm12
cm21
dm22
em41
fm42

Instance methods

This interface doesn't inherit any methods. None of the following methods alter the original matrix.

DOMMatrixReadOnly.flipX()

Returns a newDOMMatrix created by flipping the source matrix around its X-axis. This is equivalent to multiplying the matrix byDOMMatrix(-1, 0, 0, 1, 0, 0). The original matrix is not modified.

DOMMatrixReadOnly.flipY()

Returns a newDOMMatrix created by flipping the source matrix around its Y-axis. This is equivalent to multiplying the matrix byDOMMatrix(1, 0, 0, -1, 0, 0). The original matrix is not modified.

DOMMatrixReadOnly.inverse()

Returns a newDOMMatrix created by inverting the source matrix. The original matrix is not altered.

DOMMatrixReadOnly.multiply()

Returns a newDOMMatrix created by computing the dot product of the source matrix and the specified matrix. The original matrix is not

DOMMatrixReadOnly.rotateAxisAngle()

Returns a newDOMMatrix created by rotating the source matrix by the given angle around the specified vector. The original matrix is not modified.

DOMMatrixReadOnly.rotate()

Returns a newDOMMatrix created by rotating the source matrix around each of its axes by the specified number of degrees. The original matrix is not altered.

DOMMatrixReadOnly.rotateFromVector()

Returns a newDOMMatrix created by rotating the source matrix by the angle between the specified vector and(1, 0). The original matrix is not modified.

DOMMatrixReadOnly.scale()

Returns a newDOMMatrix created by scaling the source matrix by the amount specified for each axis, centered on the given origin. By default, the X and Z axes are scaled by1 and the Y axis has no default scaling value. The default origin is(0, 0, 0). The original matrix is not modified.

DOMMatrixReadOnly.scale3d()

Returns a newDOMMatrix created by scaling the source 3D matrix by the given factor along all its axes, centered on the specified origin point. The default origin is(0, 0, 0). The original matrix is not modified.

DOMMatrixReadOnly.scaleNonUniform()Deprecated

Returns a newDOMMatrix created by applying the specified scaling on the X, Y, and Z axes, centered at the given origin. By default, the Y and Z axes' scaling factors are both1, but the scaling factor for X must be specified. The default origin is(0, 0, 0). The original matrix is not changed.

DOMMatrixReadOnly.skewX()

Returns a newDOMMatrix created by applying the specified skew transformation to the source matrix along its X-axis. The original matrix is not modified.

DOMMatrixReadOnly.skewY()

Returns a newDOMMatrix created by applying the specified skew transformation to the source matrix along its Y-axis. The original matrix is not modified.

DOMMatrixReadOnly.toFloat32Array()

Returns a newFloat32Array of single-precision floating-point numbers, containing all 16 elements which comprise the matrix.

DOMMatrixReadOnly.toFloat64Array()

Returns a newFloat64Array of double-precision floating-point numbers, containing all 16 elements which comprise the matrix.

DOMMatrixReadOnly.toJSON()

Returns a JSON representation of theDOMMatrixReadOnly object.

DOMMatrixReadOnly.toString()

Creates and returns a string representation of the matrix in CSS matrix syntax, using the appropriate CSS matrix notation.

DOMMatrixReadOnly.transformPoint()

Transforms the specified point using the matrix, returning a newDOMPoint object containing the transformed point. Neither the matrix nor the original point are altered.

DOMMatrixReadOnly.translate()

Returns a newDOMMatrix containing a matrix calculated by translating the source matrix using the specified vector. By default, the vector is(0, 0, 0). The original matrix is not changed.

Static methods

fromFloat32Array()

Creates a newDOMMatrixReadOnly object given aFloat32Array of 6 or 16 single-precision (32-bit) floating-point values.

fromFloat64Array()

Creates a newDOMMatrixReadOnly object given aFloat64Array of 6 or 16 double-precision (64-bit) floating-point values.

fromMatrix()

Creates a newDOMMatrixReadOnly object given an existing matrix or an object which provides the values for its properties.

Specifications

Specification
Geometry Interfaces Module Level 1
# DOMMatrix

Browser compatibility

See also

  • The mutable matrix type,DOMMatrix, which is based on this one.
  • The CSSmatrix() andmatrix3d() functional notation that can be generated from this interface to be used in a CSStransform.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp