The DOMMatrix interface represents 4×4 matrices, suitable for 2D and 3D operations including rotation and translation.

MDN Reference

interface DOMMatrix {
    a: number;
    b: number;
    c: number;
    d: number;
    e: number;
    f: number;
    is2D: boolean;
    isIdentity: boolean;
    m11: number;
    m12: number;
    m13: number;
    m14: number;
    m21: number;
    m22: number;
    m23: number;
    m24: number;
    m31: number;
    m32: number;
    m33: number;
    m34: number;
    m41: number;
    m42: number;
    m43: number;
    m44: number;
    flipX(): DOMMatrix;
    flipY(): DOMMatrix;
    inverse(): DOMMatrix;
    invertSelf(): DOMMatrix;
    multiply(other?: DOMMatrixInit): DOMMatrix;
    multiplySelf(other?: DOMMatrixInit): DOMMatrix;
    preMultiplySelf(other?: DOMMatrixInit): DOMMatrix;
    rotate(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
    rotateAxisAngle(
        x?: number,
        y?: number,
        z?: number,
        angle?: number,
    ): DOMMatrix;
    rotateAxisAngleSelf(
        x?: number,
        y?: number,
        z?: number,
        angle?: number,
    ): DOMMatrix;
    rotateFromVector(x?: number, y?: number): DOMMatrix;
    rotateFromVectorSelf(x?: number, y?: number): DOMMatrix;
    rotateSelf(rotX?: number, rotY?: number, rotZ?: number): DOMMatrix;
    scale(
        scaleX?: number,
        scaleY?: number,
        scaleZ?: number,
        originX?: number,
        originY?: number,
        originZ?: number,
    ): DOMMatrix;
    scale3d(
        scale?: number,
        originX?: number,
        originY?: number,
        originZ?: number,
    ): DOMMatrix;
    scale3dSelf(
        scale?: number,
        originX?: number,
        originY?: number,
        originZ?: number,
    ): DOMMatrix;
    scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix;
    scaleSelf(
        scaleX?: number,
        scaleY?: number,
        scaleZ?: number,
        originX?: number,
        originY?: number,
        originZ?: number,
    ): DOMMatrix;
    setMatrixValue(transformList: string): DOMMatrix;
    skewX(sx?: number): DOMMatrix;
    skewXSelf(sx?: number): DOMMatrix;
    skewY(sy?: number): DOMMatrix;
    skewYSelf(sy?: number): DOMMatrix;
    toFloat32Array(): Float32Array<ArrayBuffer>;
    toFloat64Array(): Float64Array<ArrayBuffer>;
    toJSON(): any;
    toString(): string;
    transformPoint(point?: DOMPointInit): DOMPoint;
    translate(tx?: number, ty?: number, tz?: number): DOMMatrix;
    translateSelf(tx?: number, ty?: number, tz?: number): DOMMatrix;
}
Hierarchy
Index

Properties

a: number
b: number
c: number
d: number
e: number
f: number
is2D: boolean

The readonly is2D property of the DOMMatrixReadOnly interface is a Boolean flag that is true when the matrix is 2D.

MDN Reference

isIdentity: boolean

The readonly isIdentity property of the DOMMatrixReadOnly interface is a Boolean whose value is true if the matrix is the identity matrix.

MDN Reference

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

Methods

  • The flipX() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix flipped about the x-axis.

    MDN Reference

    Returns DOMMatrix

  • The flipY() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix flipped about the y-axis.

    MDN Reference

    Returns DOMMatrix

  • The invertSelf() method of the DOMMatrix interface inverts the original matrix.

    MDN Reference

    Returns DOMMatrix

  • The multiplySelf() method of the DOMMatrix interface multiplies a matrix by the otherMatrix parameter, computing the dot product of the original matrix and the specified matrix: A⋅B.

    MDN Reference

    Parameters

    Returns DOMMatrix

  • The preMultiplySelf() method of the DOMMatrix interface modifies the matrix by pre-multiplying it with the specified DOMMatrix.

    MDN Reference

    Parameters

    Returns DOMMatrix

  • The rotate() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by rotating the source matrix around each of its axes by the specified number of degrees.

    MDN Reference

    Parameters

    • OptionalrotX: number
    • OptionalrotY: number
    • OptionalrotZ: number

    Returns DOMMatrix

  • The rotateAxisAngle() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by rotating the source matrix by the given vector and angle.

    MDN Reference

    Parameters

    • Optionalx: number
    • Optionaly: number
    • Optionalz: number
    • Optionalangle: number

    Returns DOMMatrix

  • The rotateAxisAngleSelf() method of the DOMMatrix interface is a transformation method that rotates the source matrix by the given vector and angle, returning the altered matrix.

    MDN Reference

    Parameters

    • Optionalx: number
    • Optionaly: number
    • Optionalz: number
    • Optionalangle: number

    Returns DOMMatrix

  • The rotateFromVector() method of the DOMMatrixReadOnly interface is returns a new DOMMatrix created by rotating the source matrix by the angle between the specified vector and (1, 0).

    MDN Reference

    Parameters

    • Optionalx: number
    • Optionaly: number

    Returns DOMMatrix

  • The rotateFromVectorSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by rotating the matrix by the angle between the specified vector and (1, 0).

    MDN Reference

    Parameters

    • Optionalx: number
    • Optionaly: number

    Returns DOMMatrix

  • The rotateSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix.

    MDN Reference

    Parameters

    • OptionalrotX: number
    • OptionalrotY: number
    • OptionalrotZ: number

    Returns DOMMatrix

  • The scale() method of the original matrix with a scale transform applied.

    MDN Reference

    Parameters

    • OptionalscaleX: number
    • OptionalscaleY: number
    • OptionalscaleZ: number
    • OptionaloriginX: number
    • OptionaloriginY: number
    • OptionaloriginZ: number

    Returns DOMMatrix

  • The scale3d() method of the DOMMatrixReadOnly interface creates a new matrix which is the result of a 3D scale transform being applied to the matrix.

    MDN Reference

    Parameters

    • Optionalscale: number
    • OptionaloriginX: number
    • OptionaloriginY: number
    • OptionaloriginZ: number

    Returns DOMMatrix

  • The scale3dSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor to all three axes, centered on the given origin, with a default origin of (0, 0, 0), returning the 3D-scaled matrix.

    MDN Reference

    Parameters

    • Optionalscale: number
    • OptionaloriginX: number
    • OptionaloriginY: number
    • OptionaloriginZ: number

    Returns DOMMatrix

  • The scaleSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix by applying a specified scaling factor, centered on the given origin, with a default origin of (0, 0), returning the scaled matrix.

    MDN Reference

    Parameters

    • OptionalscaleX: number
    • OptionalscaleY: number
    • OptionalscaleZ: number
    • OptionaloriginX: number
    • OptionaloriginY: number
    • OptionaloriginZ: number

    Returns DOMMatrix

  • The setMatrixValue() method of the DOMMatrix interface replaces the contents of the matrix with the matrix described by the specified transform or transforms, returning itself.

    MDN Reference

    Parameters

    • transformList: string

    Returns DOMMatrix

  • The skewX() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its x-axis.

    MDN Reference

    Parameters

    • Optionalsx: number

    Returns DOMMatrix

  • The skewXSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix.

    MDN Reference

    Parameters

    • Optionalsx: number

    Returns DOMMatrix

  • The skewY() method of the DOMMatrixReadOnly interface returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its y-axis.

    MDN Reference

    Parameters

    • Optionalsy: number

    Returns DOMMatrix

  • The skewYSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix.

    MDN Reference

    Parameters

    • Optionalsy: number

    Returns DOMMatrix

  • The toFloat32Array() method of the DOMMatrixReadOnly interface returns a new Float32Array containing all 16 elements (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) which comprise the matrix.

    MDN Reference

    Returns Float32Array<ArrayBuffer>

  • The toFloat64Array() method of the DOMMatrixReadOnly interface returns a new Float64Array containing all 16 elements (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) which comprise the matrix.

    MDN Reference

    Returns Float64Array<ArrayBuffer>

  • The toJSON() method of the DOMMatrixReadOnly interface creates and returns a JSON object.

    MDN Reference

    Returns any

  • Returns string

  • The translate() method of the DOMMatrixReadOnly interface creates a new matrix being the result of the original matrix with a translation applied.

    MDN Reference

    Parameters

    • Optionaltx: number
    • Optionalty: number
    • Optionaltz: number

    Returns DOMMatrix

  • The translateSelf() method of the DOMMatrix interface is a mutable transformation method that modifies a matrix.

    MDN Reference

    Parameters

    • Optionaltx: number
    • Optionalty: number
    • Optionaltz: number

    Returns DOMMatrix