Module org.htmlunit

Class DOMMatrixReadOnly

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.dom.DOMMatrixReadOnly
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
Direct Known Subclasses:
DOMMatrix

public class DOMMatrixReadOnly extends HtmlUnitScriptable
A JavaScript object for DOMMatrixReadOnly.
Author:
Ahmed Ashour, Ronald Brill
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction
  • Field Summary

    Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, LEGACY_CONST, PERMANENT, READONLY, STRICTLY_READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ctor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected DOMMatrix
    Creates a new DOMMatrix with the values of this matrix.
    Returns a new matrix being the result of the original matrix flipped about the x-axis.
    Returns a new matrix being the result of the original matrix flipped about the y-axis.
    fromFloat32ArrayReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
    Creates a new DOMMatrixReadOnly from the given Float32Array with 6 (2D) or 16 (3D) values.
    fromFloat64ArrayReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
    Creates a new DOMMatrixReadOnly from the given Float64Array with 6 (2D) or 16 (3D) values.
    fromMatrixReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
    Creates a new DOMMatrixReadOnly from the given matrix or matrix properties.
    protected static DOMMatrixReadOnly
    fromTypedArray(Object[] args, Class<? extends org.htmlunit.corejs.javascript.typedarrays.NativeTypedArrayView<?>> type, String methodName, String className)
    Converts the first argument (a typed array of the given type with 6 or 16 values) into a matrix.
    double
    Returns the a property.
    double
    Returns the b property.
    double
    Returns the c property.
    double
    Returns the d property.
    Returns the JavaScript default value of this object.
    double
    Returns the e property.
    double
    Returns the f property.
    boolean
    Returns whether this matrix is the identity matrix.
    double
    Returns the m11 property.
    double
    Returns the m12 property.
    double
    Returns the m13 property.
    double
    Returns the m14 property.
    double
    Returns the m21 property.
    double
    Returns the m22 property.
    double
    Returns the m23 property.
    double
    Returns the m24 property.
    double
    Returns the m31 property.
    double
    Returns the m32 property.
    double
    Returns the m33 property.
    double
    Returns the m34 property.
    double
    Returns the m41 property.
    double
    Returns the m42 property.
    double
    Returns the m43 property.
    double
    Returns the m44 property.
    protected double[]
    Returns the values of this matrix in column-major order (m11, m12, m13, m14, m21, ..., m44).
    protected void
    init(Object[] args, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Function ctorObj)
    Initializes this matrix from the constructor arguments.
    Returns a new matrix which is the inverse of the original matrix.
    protected void
    Inverts this matrix.
    boolean
    Returns the is2D property.
    Returns the values of the matrix as a CSS transform function string.
    jsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr)
    JavaScript constructor.
    Returns a new matrix which is the dot product of the matrix and the given matrix.
    protected void
    Post-multiplies this matrix with the given one (this = this * other).
    protected static <T extends DOMMatrixReadOnly>
    T
    newInstance(T matrix, org.htmlunit.corejs.javascript.VarScope scope, String className, DOMMatrixReadOnly values)
    Initializes the given new matrix object with the scope, the prototype and the values.
    protected void
    Pre-multiplies this matrix with the given one (this = other * this).
    rotate(Object rotX, Object rotY, Object rotZ)
    Returns a new matrix rotated by the specified angles.
    Returns a new matrix rotated by a given angle around the specified axis.
    protected void
    rotateAxisAngleSelfInternal(double x, double y, double z, double angle)
    Rotates this matrix by the given angle around the specified axis.
    Returns a new matrix rotated by the angle between the specified vector and (1, 0).
    protected void
    rotateFromVectorSelfInternal(double x, double y)
    Rotates this matrix by the angle between the specified vector and (1, 0).
    protected void
    rotateSelfInternal(double rotX, double rotY, double rotZ)
    Rotates this matrix around the z-axis, then around the y-axis and finally around the x-axis.
    protected void
    rotateSelfInternal(Object rotXObj, Object rotYObj, Object rotZObj)
    Applies the rotation of rotate(Object, Object, Object) to this matrix.
    scale(Object scaleX, Object scaleY, Object scaleZ, Object originX, Object originY, Object originZ)
    Returns a new matrix scaled by the given factors, centered on the given origin.
    scale3d(Object scale, Object originX, Object originY, Object originZ)
    Returns a new matrix scaled by the given factor for all three axes, centered on the given origin.
    protected void
    scale3dSelfInternal(double scale, double originX, double originY, double originZ)
    Applies a uniform scaling of all three axes centered on the given origin to this matrix.
    scaleNonUniform(Object scaleX, Object scaleY)
    Returns a new matrix scaled by the given factors for the x- and the y-axis.
    protected void
    scaleSelfInternal(double scaleX, double scaleY, double scaleZ, double originX, double originY, double originZ)
    Applies a scaling centered on the given origin to this matrix.
    void
    setIs2D(boolean is2D)
    Sets the is2D property.
    void
    setM11(double m11)
    Sets the m11 property.
    void
    setM12(double m12)
    Sets the m12 property.
    void
    setM13(double m13)
    Sets the m13 property.
    void
    setM14(double m14)
    Sets the m14 property.
    void
    setM21(double m21)
    Sets the m21 property.
    void
    setM22(double m22)
    Sets the m22 property.
    void
    setM23(double m23)
    Sets the m23 property.
    void
    setM24(double m24)
    Sets the m24 property.
    void
    setM31(double m31)
    Sets the m31 property.
    void
    setM32(double m32)
    Sets the m32 property.
    void
    setM33(double m33)
    Sets the m33 property.
    void
    setM34(double m34)
    Sets the m34 property.
    void
    setM41(double m41)
    Sets the m41 property.
    void
    setM42(double m42)
    Sets the m42 property.
    void
    setM43(double m43)
    Sets the m43 property.
    void
    setM44(double m44)
    Sets the m44 property.
    protected void
    setTransformList(String transformList)
    Parses the given CSS transform list and replaces the values of this matrix with the result.
    protected void
    setValues(double[] values, boolean is2D)
    Sets all values of this matrix.
    protected void
    setValues2D(double a, double b, double c, double d, double e, double f)
    Sets this to the 2D matrix [a, b, c, d, e, f]; all other values are set to the values of the identity matrix.
    Returns a new matrix skewed along the x-axis by the specified angle.
    protected void
    skewXSelfInternal(double sx)
    Skews this matrix along the x-axis.
    Returns a new matrix skewed along the y-axis by the specified angle.
    protected void
    skewYSelfInternal(double sy)
    Skews this matrix along the y-axis.
    protected static double
    toDouble(Object value, double defaultValue)
    Converts the given JavaScript value into a double; undefined (or a missing argument) is converted to the given default value.
    org.htmlunit.corejs.javascript.typedarrays.NativeFloat32Array
    Returns a new Float32Array containing all 16 elements of the matrix.
    org.htmlunit.corejs.javascript.typedarrays.NativeFloat64Array
    Returns a new Float64Array containing all 16 elements of the matrix.
    org.htmlunit.corejs.javascript.Scriptable
    Returns a JSON representation of the DOMMatrixReadOnly object.
    Transforms the given point with this matrix.
    translate(Object tx, Object ty, Object tz)
    Creates a new matrix being the result of the original matrix with a translation applied.
    protected void
    translateSelfInternal(double tx, double ty, double tz)
    Applies a translation to this matrix.

    Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject

    applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size

    Methods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • DOMMatrixReadOnly

      public DOMMatrixReadOnly()
      Ctor.
  • Method Details

    • jsConstructor

      public static DOMMatrixReadOnly jsConstructor(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, Object[] args, org.htmlunit.corejs.javascript.Function ctorObj, boolean inNewExpr)
      JavaScript constructor.
      Parameters:
      cx - the current context
      scope - the scope
      args - the arguments to the DOMMatrixReadOnly constructor
      ctorObj - the function object
      inNewExpr - true if invoked with the new operator
      Returns:
      the Java object that JavaScript can access
    • init

      protected void init(Object[] args, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Function ctorObj)
      Initializes this matrix from the constructor arguments.
      • no argument or undefined: the identity matrix
      • an iterable object (e.g. an array or a typed array): a sequence of 6 (2D) or 16 (3D) numbers
      • everything else is converted to a string and parsed as CSS transform list; this is only supported in a window, workers throw a TypeError
      Parameters:
      args - the constructor arguments
      scope - the scope
      ctorObj - the constructor function
    • setTransformList

      protected void setTransformList(String transformList)
      Parses the given CSS transform list and replaces the values of this matrix with the result.
      Parameters:
      transformList - the CSS transform list
    • getM11

      public double getM11()
      Returns the m11 property.
      Returns:
      the m11 property
    • setM11

      public void setM11(double m11)
      Sets the m11 property.
      Parameters:
      m11 - the new value
    • getA

      public double getA()
      Returns the a property.
      Returns:
      the a property
    • getM12

      public double getM12()
      Returns the m12 property.
      Returns:
      the m12 property
    • setM12

      public void setM12(double m12)
      Sets the m12 property.
      Parameters:
      m12 - the new value
    • getB

      public double getB()
      Returns the b property.
      Returns:
      the b property
    • getM13

      public double getM13()
      Returns the m13 property.
      Returns:
      the m13 property
    • setM13

      public void setM13(double m13)
      Sets the m13 property.
      Parameters:
      m13 - the new value
    • getM14

      public double getM14()
      Returns the m14 property.
      Returns:
      the m14 property
    • setM14

      public void setM14(double m14)
      Sets the m14 property.
      Parameters:
      m14 - the new value
    • getM21

      public double getM21()
      Returns the m21 property.
      Returns:
      the m21 property
    • setM21

      public void setM21(double m21)
      Sets the m21 property.
      Parameters:
      m21 - the new value
    • getC

      public double getC()
      Returns the c property.
      Returns:
      the c property
    • getM22

      public double getM22()
      Returns the m22 property.
      Returns:
      the m22 property
    • setM22

      public void setM22(double m22)
      Sets the m22 property.
      Parameters:
      m22 - the new value
    • getD

      public double getD()
      Returns the d property.
      Returns:
      the d property
    • getM23

      public double getM23()
      Returns the m23 property.
      Returns:
      the m23 property
    • setM23

      public void setM23(double m23)
      Sets the m23 property.
      Parameters:
      m23 - the new value
    • getM24

      public double getM24()
      Returns the m24 property.
      Returns:
      the m24 property
    • setM24

      public void setM24(double m24)
      Sets the m24 property.
      Parameters:
      m24 - the new value
    • getM31

      public double getM31()
      Returns the m31 property.
      Returns:
      the m31 property
    • setM31

      public void setM31(double m31)
      Sets the m31 property.
      Parameters:
      m31 - the new value
    • getM32

      public double getM32()
      Returns the m32 property.
      Returns:
      the m32 property
    • setM32

      public void setM32(double m32)
      Sets the m32 property.
      Parameters:
      m32 - the new value
    • getM33

      public double getM33()
      Returns the m33 property.
      Returns:
      the m33 property
    • setM33

      public void setM33(double m33)
      Sets the m33 property.
      Parameters:
      m33 - the new value
    • getM34

      public double getM34()
      Returns the m34 property.
      Returns:
      the m34 property
    • setM34

      public void setM34(double m34)
      Sets the m34 property.
      Parameters:
      m34 - the new value
    • getM41

      public double getM41()
      Returns the m41 property.
      Returns:
      the m41 property
    • setM41

      public void setM41(double m41)
      Sets the m41 property.
      Parameters:
      m41 - the new value
    • getE

      public double getE()
      Returns the e property.
      Returns:
      the e property
    • getM42

      public double getM42()
      Returns the m42 property.
      Returns:
      the m42 property
    • setM42

      public void setM42(double m42)
      Sets the m42 property.
      Parameters:
      m42 - the new value
    • getF

      public double getF()
      Returns the f property.
      Returns:
      the f property
    • getM43

      public double getM43()
      Returns the m43 property.
      Returns:
      the m43 property
    • setM43

      public void setM43(double m43)
      Sets the m43 property.
      Parameters:
      m43 - the new value
    • getM44

      public double getM44()
      Returns the m44 property.
      Returns:
      the m44 property
    • setM44

      public void setM44(double m44)
      Sets the m44 property.
      Parameters:
      m44 - the new value
    • isIs2D

      public boolean isIs2D()
      Returns the is2D property.
      Returns:
      the is2D property
    • setIs2D

      public void setIs2D(boolean is2D)
      Sets the is2D property.
      Parameters:
      is2D - the new value
    • getIsIdentity

      public boolean getIsIdentity()
      Returns whether this matrix is the identity matrix.
      Returns:
      true if m12 element, m13 element, m14 element, m21 element, m23 element, m24 element, m31 element, m32 element, m34 element, m41 element, m42 element, m43 element are 0 or -0 and m11 element, m22 element, m33 element, m44 element are 1. Otherwise it returns false.
    • flipX

      public DOMMatrix flipX()
      Returns a new matrix being the result of the original matrix flipped about the x-axis.
      Returns:
      a new matrix being the result of the original matrix flipped about the x-axis. This is equivalent to multiplying the matrix by DOMMatrix(-1, 0, 0, 1, 0, 0). The original matrix is not modified.
    • flipY

      public DOMMatrix flipY()
      Returns a new matrix being the result of the original matrix flipped about the y-axis.
      Returns:
      a new matrix being the result of the original matrix flipped about the y-axis. This is equivalent to multiplying the matrix by DOMMatrix(1, 0, 0, -1, 0, 0). The original matrix is not modified.
    • inverse

      public DOMMatrix inverse()
      Returns a new matrix which is the inverse of the original matrix.
      Returns:
      new matrix which is the inverse of the original matrix. If the matrix cannot be inverted, the new matrix's components are all set to NaN and its is2D property is set to false. The original matrix is not changed.
    • multiply

      public DOMMatrix multiply(Object other)
      Returns a new matrix which is the dot product of the matrix and the given matrix.
      Parameters:
      other - the matrix to multiply with this matrix; this can be a matrix or an object with matrix properties (DOMMatrixInit); null and undefined are treated as identity matrix
      Returns:
      a new matrix which is the dot product of the matrix and the other matrix. The original matrix is not modified.
    • rotate

      public DOMMatrix rotate(Object rotX, Object rotY, Object rotZ)
      Returns a new matrix rotated by the specified angles. If only one argument is given, this is the rotation angle around the z-axis (a 2D rotation), otherwise the matrix is rotated around the z-axis, then around the y-axis and finally around the x-axis.
      Parameters:
      rotX - the rotation angle around the x-axis in degrees (or the rotation angle around the z-axis if this is the only argument)
      rotY - the rotation angle around the y-axis in degrees
      rotZ - the rotation angle around the z-axis in degrees
      Returns:
      a new matrix which is the result of the original matrix rotated by the specified angles. The original matrix is not modified.
    • rotateFromVector

      public DOMMatrix rotateFromVector(Object x, Object y)
      Returns a new matrix rotated by the angle between the specified vector and (1, 0).
      Parameters:
      x - the x component of the vector
      y - the y component of the vector
      Returns:
      a new matrix which is the result of the original matrix rotated by the angle of the vector. The original matrix is not modified.
    • rotateAxisAngle

      public DOMMatrix rotateAxisAngle(Object x, Object y, Object z, Object angle)
      Returns a new matrix rotated by a given angle around the specified axis.
      Parameters:
      x - the x component of the axis
      y - the y component of the axis
      z - the z component of the axis
      angle - the rotation angle in degrees
      Returns:
      a new matrix which is the result of the original matrix rotated around the axis. The original matrix is not modified.
    • scale

      public DOMMatrix scale(Object scaleX, Object scaleY, Object scaleZ, Object originX, Object originY, Object originZ)
      Returns a new matrix scaled by the given factors, centered on the given origin.
      Parameters:
      scaleX - the scale factor for the x-axis (default 1)
      scaleY - the scale factor for the y-axis (default scaleX)
      scaleZ - the scale factor for the z-axis (default 1)
      originX - the x-coordinate of the origin (default 0)
      originY - the y-coordinate of the origin (default 0)
      originZ - the z-coordinate of the origin (default 0)
      Returns:
      a new matrix which is the result of the original matrix scaled. The original matrix is not modified.
    • scale3d

      public DOMMatrix scale3d(Object scale, Object originX, Object originY, Object originZ)
      Returns a new matrix scaled by the given factor for all three axes, centered on the given origin.
      Parameters:
      scale - the scale factor (default 1)
      originX - the x-coordinate of the origin (default 0)
      originY - the y-coordinate of the origin (default 0)
      originZ - the z-coordinate of the origin (default 0)
      Returns:
      a new matrix which is the result of the original matrix scaled. The original matrix is not modified.
    • scaleNonUniform

      public DOMMatrix scaleNonUniform(Object scaleX, Object scaleY)
      Returns a new matrix scaled by the given factors for the x- and the y-axis. This method is deprecated; use scale(Object, Object, Object, Object, Object, Object).
      Parameters:
      scaleX - the scale factor for the x-axis (default 1)
      scaleY - the scale factor for the y-axis (default 1)
      Returns:
      a new matrix which is the result of the original matrix scaled. The original matrix is not modified.
    • skewX

      public DOMMatrix skewX(Object sx)
      Returns a new matrix skewed along the x-axis by the specified angle.
      Parameters:
      sx - the angle, in degrees, by which to skew the matrix along the x-axis
      Returns:
      returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its x-axis. The original matrix is not modified.
    • skewY

      public DOMMatrix skewY(Object sy)
      Returns a new matrix skewed along the y-axis by the specified angle.
      Parameters:
      sy - the angle, in degrees, by which to skew the matrix along the y-axis
      Returns:
      returns a new DOMMatrix created by applying the specified skew transformation to the source matrix along its y-axis. The original matrix is not modified.
    • translate

      public DOMMatrix translate(Object tx, Object ty, Object tz)
      Creates a new matrix being the result of the original matrix with a translation applied.
      Parameters:
      tx - the x component of the translating vector (default 0)
      ty - the y component of the translating vector (default 0)
      tz - the z component of the translating vector (default 0); if this is anything other than 0, the resulting matrix will be 3D
      Returns:
      a new matrix being the result of the matrix being translated by the given vector. The original matrix is not modified.
    • transformPoint

      public DOMPoint transformPoint(Object point)
      Transforms the given point with this matrix.
      Parameters:
      point - the point to transform; this can be a point or an object with point properties (DOMPointInit: x, y, z (default 0) and w (default 1)); null and undefined are treated as the point (0, 0, 0, 1)
      Returns:
      a new DOMPoint with the transformed coordinates
    • multiplySelfInternal

      protected void multiplySelfInternal(DOMMatrixReadOnly other)
      Post-multiplies this matrix with the given one (this = this * other). The result is 2D if both matrices are 2D.
      Parameters:
      other - the matrix to multiply with
    • preMultiplySelfInternal

      protected void preMultiplySelfInternal(DOMMatrixReadOnly other)
      Pre-multiplies this matrix with the given one (this = other * this). The result is 2D if both matrices are 2D.
      Parameters:
      other - the matrix to multiply with
    • translateSelfInternal

      protected void translateSelfInternal(double tx, double ty, double tz)
      Applies a translation to this matrix.
      Parameters:
      tx - the x component of the translating vector
      ty - the y component of the translating vector
      tz - the z component of the translating vector
    • scaleSelfInternal

      protected void scaleSelfInternal(double scaleX, double scaleY, double scaleZ, double originX, double originY, double originZ)
      Applies a scaling centered on the given origin to this matrix.
      Parameters:
      scaleX - the scale factor for the x-axis
      scaleY - the scale factor for the y-axis
      scaleZ - the scale factor for the z-axis
      originX - the x-coordinate of the origin
      originY - the y-coordinate of the origin
      originZ - the z-coordinate of the origin
    • scale3dSelfInternal

      protected void scale3dSelfInternal(double scale, double originX, double originY, double originZ)
      Applies a uniform scaling of all three axes centered on the given origin to this matrix.
      Parameters:
      scale - the scale factor
      originX - the x-coordinate of the origin
      originY - the y-coordinate of the origin
      originZ - the z-coordinate of the origin
    • rotateSelfInternal

      protected void rotateSelfInternal(Object rotXObj, Object rotYObj, Object rotZObj)
      Applies the rotation of rotate(Object, Object, Object) to this matrix.
      Parameters:
      rotXObj - the rotation angle around the x-axis in degrees (or the rotation angle around the z-axis if this is the only argument)
      rotYObj - the rotation angle around the y-axis in degrees
      rotZObj - the rotation angle around the z-axis in degrees
    • rotateSelfInternal

      protected void rotateSelfInternal(double rotX, double rotY, double rotZ)
      Rotates this matrix around the z-axis, then around the y-axis and finally around the x-axis.
      Parameters:
      rotX - the rotation angle around the x-axis in degrees
      rotY - the rotation angle around the y-axis in degrees
      rotZ - the rotation angle around the z-axis in degrees
    • rotateFromVectorSelfInternal

      protected void rotateFromVectorSelfInternal(double x, double y)
      Rotates this matrix by the angle between the specified vector and (1, 0).
      Parameters:
      x - the x component of the vector
      y - the y component of the vector
    • rotateAxisAngleSelfInternal

      protected void rotateAxisAngleSelfInternal(double x, double y, double z, double angle)
      Rotates this matrix by the given angle around the specified axis. An axis of (0, 0, 0) does not change the matrix.
      Parameters:
      x - the x component of the axis
      y - the y component of the axis
      z - the z component of the axis
      angle - the rotation angle in degrees
    • skewXSelfInternal

      protected void skewXSelfInternal(double sx)
      Skews this matrix along the x-axis.
      Parameters:
      sx - the angle in degrees
    • skewYSelfInternal

      protected void skewYSelfInternal(double sy)
      Skews this matrix along the y-axis.
      Parameters:
      sy - the angle in degrees
    • invertSelfInternal

      protected void invertSelfInternal()
      Inverts this matrix. If the matrix cannot be inverted, all values are set to NaN and the matrix is no longer 2D.
    • copyToDOMMatrix

      protected DOMMatrix copyToDOMMatrix()
      Creates a new DOMMatrix with the values of this matrix.
      Returns:
      the new matrix
    • getValues

      protected double[] getValues()
      Returns the values of this matrix in column-major order (m11, m12, m13, m14, m21, ..., m44).
      Returns:
      a new array with the 16 values
    • setValues

      protected void setValues(double[] values, boolean is2D)
      Sets all values of this matrix.
      Parameters:
      values - the 16 values in column-major order (m11, m12, m13, m14, m21, ..., m44)
      is2D - the new value of the is2D flag
    • setValues2D

      protected void setValues2D(double a, double b, double c, double d, double e, double f)
      Sets this to the 2D matrix [a, b, c, d, e, f]; all other values are set to the values of the identity matrix.
      Parameters:
      a - the a (m11) value
      b - the b (m12) value
      c - the c (m21) value
      d - the d (m22) value
      e - the e (m41) value
      f - the f (m42) value
    • toDouble

      protected static double toDouble(Object value, double defaultValue)
      Converts the given JavaScript value into a double; undefined (or a missing argument) is converted to the given default value.
      Parameters:
      value - the value
      defaultValue - the default value
      Returns:
      the double value
    • toFloat32Array

      public org.htmlunit.corejs.javascript.typedarrays.NativeFloat32Array toFloat32Array()
      Returns a new Float32Array containing all 16 elements of the matrix.
      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. The elements are stored into the array as single-precision floating-point numbers in column-major (colexographical access, or "colex") order. (In other words, down the first column from top to bottom, then the second column, and so forth.)
    • toFloat64Array

      public org.htmlunit.corejs.javascript.typedarrays.NativeFloat64Array toFloat64Array()
      Returns a new Float64Array containing all 16 elements of the matrix.
      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. The elements are stored into the array as single-precision floating-point numbers in column-major (colexographical access, or "colex") order. (In other words, down the first column from top to bottom, then the second column, and so forth.)
    • js_toString

      public String js_toString()
      Returns the values of the matrix as a CSS transform function string.
      Returns:
      the values of the list separated by commas, within matrix() or matrix3d() function syntax.
    • getDefaultValue

      public Object getDefaultValue(Class<?> hint)
      Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java. The string representation (also used for the conversion of a matrix into a string, e.g. when passing a matrix to the constructor) is the CSS transform function.
      Specified by:
      getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      getDefaultValue in class HtmlUnitScriptable
      Parameters:
      hint - a hint as to the format of the default value (ignored in this case)
      Returns:
      the default value
    • toJSON

      public org.htmlunit.corejs.javascript.Scriptable toJSON()
      Returns a JSON representation of the DOMMatrixReadOnly object.
      Returns:
      a JSON representation of the DOMMatrixReadOnly object
    • fromMatrixReadOnly

      public static DOMMatrixReadOnly fromMatrixReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
      Creates a new DOMMatrixReadOnly from the given matrix or matrix properties.
      Parameters:
      cx - the current context
      scope - the scope
      thisObj - the scriptable this object
      args - the arguments; the first one is the matrix or an object with matrix properties (DOMMatrixInit)
      funObj - the function object
      Returns:
      the new matrix
    • fromFloat32ArrayReadOnly

      public static DOMMatrixReadOnly fromFloat32ArrayReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
      Creates a new DOMMatrixReadOnly from the given Float32Array with 6 (2D) or 16 (3D) values.
      Parameters:
      cx - the current context
      scope - the scope
      thisObj - the scriptable this object
      args - the arguments; the first one is the Float32Array
      funObj - the function object
      Returns:
      the new matrix
    • fromFloat64ArrayReadOnly

      public static DOMMatrixReadOnly fromFloat64ArrayReadOnly(org.htmlunit.corejs.javascript.Context cx, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function funObj)
      Creates a new DOMMatrixReadOnly from the given Float64Array with 6 (2D) or 16 (3D) values.
      Parameters:
      cx - the current context
      scope - the scope
      thisObj - the scriptable this object
      args - the arguments; the first one is the Float64Array
      funObj - the function object
      Returns:
      the new matrix
    • newInstance

      protected static <T extends DOMMatrixReadOnly> T newInstance(T matrix, org.htmlunit.corejs.javascript.VarScope scope, String className, DOMMatrixReadOnly values)
      Initializes the given new matrix object with the scope, the prototype and the values.
      Type Parameters:
      T - the matrix type
      Parameters:
      matrix - the new matrix object
      scope - the scope
      className - the JavaScript class name used to find the prototype
      values - the matrix to copy the values from
      Returns:
      the given matrix
    • fromTypedArray

      protected static DOMMatrixReadOnly fromTypedArray(Object[] args, Class<? extends org.htmlunit.corejs.javascript.typedarrays.NativeTypedArrayView<?>> type, String methodName, String className)
      Converts the first argument (a typed array of the given type with 6 or 16 values) into a matrix.
      Parameters:
      args - the arguments
      type - the expected typed array type
      methodName - the name of the calling method for the error message
      className - the name of the calling class for the error message
      Returns:
      a new matrix (without scope)