PokéRogue
    Preparing search index...

    A TransformMatrix is a 3x3 affine transformation matrix used to encode the position, rotation, scale, and skew of a Game Object for rendering.

    It is used internally by Phaser during the render pipeline to accumulate parent-child transform chains and apply camera transformations. You will typically interact with it when writing custom renderers or working with the camera or display list transform pipeline.

    It is represented like so:

    | a | c | tx |
    | b | d | ty |
    | 0 | 0 | 1 |
    Index
    • Parameters

      • Optionala: number

        The Scale X value. Default 1.

      • Optionalb: number

        The Skew Y value. Default 0.

      • Optionalc: number

        The Skew X value. Default 0.

      • Optionald: number

        The Scale Y value. Default 1.

      • Optionaltx: number

        The Translate X value. Default 0.

      • Optionalty: number

        The Translate Y value. Default 0.

      Returns TransformMatrix

    a: number

    The Scale X value.

    b: number

    The Skew Y value.

    c: number

    The Skew X value.

    d: number

    The Scale Y value.

    decomposedMatrix: object

    The decomposed matrix.

    e: number

    The Translate X value.

    f: number

    The Translate Y value.

    matrix: Float32Array

    The matrix values.

    The temporary quad value cache.

    rotation: number

    The rotation of the Matrix. Value is in radians.

    rotationNormalized: number

    The rotation of the Matrix, normalized to be within the Phaser right-handed clockwise rotation space. Value is in radians.

    scaleX: number

    The decomposed horizontal scale of the Matrix. This value is always positive.

    scaleY: number

    The decomposed vertical scale of the Matrix. This value is always positive.

    tx: number

    The Translate X value.

    ty: number

    The Translate Y value.

    • Takes the x and y values and returns a new position in the output vector that is the inverse of the current matrix with its transformation applied.

      Can be used to translate points from world to local space.

      Parameters

      • x: number

        The x position to translate.

      • y: number

        The y position to translate.

      • Optionaloutput: Vector2

        A Vector2, or point-like object, to store the results in.

      Returns Vector2

      The coordinates, inverse-transformed through this matrix.

    • Apply the identity, translate, rotate and scale operations on the Matrix.

      Parameters

      • x: number

        The horizontal translation.

      • y: number

        The vertical translation.

      • rotation: number

        The angle of rotation in radians.

      • scaleX: number

        The horizontal scale.

      • scaleY: number

        The vertical scale.

      Returns this

      This TransformMatrix.

    • Set the values of this Matrix to copy those of the matrix given.

      Parameters

      Returns this

      This TransformMatrix.

    • Set the values of this Matrix to copy those of the array given. Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.

      Parameters

      • src: any[]

        The array of values to set into this matrix.

      Returns this

      This TransformMatrix.

    • Copy the values in this Matrix to the array given.

      Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.

      Parameters

      • Optionalout: any[]

        The array to copy the matrix values in to.

      Returns any[]

      An array where elements 0 to 5 contain the values from this matrix.

    • Set the values of this Matrix to copy those of the matrix given, combined with a camera scroll factor.

      This is used in many render functions.

      Parameters

      • src: TransformMatrix

        The source Matrix to copy from.

      • scrollX: number

        The horizontal scroll value to factor in.

      • scrollY: number

        The vertical scroll value to factor in.

      • scrollFactorX: number

        The horizontal scroll factor to apply.

      • scrollFactorY: number

        The vertical scroll factor to apply.

      Returns this

      This TransformMatrix.

    • Decompose this Matrix into its translation, scale and rotation values using QR decomposition.

      The result must be applied in the following order to reproduce the current matrix:

      translate -> rotate -> scaleundefined

      Returns DecomposeMatrixResults

      The decomposed Matrix.

    • Destroys this Transform Matrix.

      Returns void

    • Returns a string that can be used in a CSS Transform call as a matrix property.undefined

      Returns string

      A string containing the CSS Transform matrix values.

    • Returns the X component of this matrix multiplied by the given values. This is the same as x * a + y * c + e.

      Parameters

      • x: number

        The x value.

      • y: number

        The y value.

      Returns number

      The calculated x value.

    • Returns the X component of this matrix multiplied by the given values.

      This is the same as x * a + y * c + e, optionally passing via Math.round.

      Parameters

      • x: number

        The x value.

      • y: number

        The y value.

      • Optionalround: boolean

        Math.round the resulting value? Default false.

      Returns number

      The calculated x value.

    • Returns the Y component of this matrix multiplied by the given values. This is the same as x * b + y * d + f.

      Parameters

      • x: number

        The x value.

      • y: number

        The y value.

      Returns number

      The calculated y value.

    • Returns the Y component of this matrix multiplied by the given values.

      This is the same as x * b + y * d + f, optionally passing via Math.round.

      Parameters

      • x: number

        The x value.

      • y: number

        The y value.

      • Optionalround: boolean

        Math.round the resulting value? Default false.

      Returns number

      The calculated y value.

    • Invert the Matrix.undefined

      Returns this

      This TransformMatrix.

    • Reset the Matrix to an identity matrix.undefined

      Returns this

      This TransformMatrix.

    • Multiply this Matrix by the given Matrix.

      If an out Matrix is given then the results will be stored in it. If it is not given, this matrix will be updated in place instead. Use an out Matrix if you do not wish to mutate this matrix.

      Parameters

      Returns TransformMatrix

      Either this TransformMatrix, or the out Matrix, if given in the arguments.

    • Multiply this Matrix by the matrix given, including the offset.

      The offsetX is added to the tx value: offsetX * a + offsetY * c + tx. The offsetY is added to the ty value: offsetX * b + offsetY * d + ty.

      Parameters

      • src: TransformMatrix

        The source Matrix to copy from.

      • offsetX: number

        Horizontal offset to factor in to the multiplication.

      • offsetY: number

        Vertical offset to factor in to the multiplication.

      Returns this

      This TransformMatrix.

    • Rotate the Matrix.

      Parameters

      • angle: number

        The angle of rotation in radians.

      Returns this

      This TransformMatrix.

    • Scale the Matrix.

      Parameters

      • x: number

        The horizontal scale value.

      • y: number

        The vertical scale value.

      Returns this

      This TransformMatrix.

    • Performs the 8 calculations required to create the vertices of a quad based on this matrix and the given vertex coordinates.

      The result is stored in TransformMatrix.quad, which is returned from this method.

      Parameters

      • x: number

        The x value of the top-left vertex of the quad.

      • y: number

        The y value of the top-left vertex of the quad.

      • xw: number

        The x value of the bottom-right vertex of the quad. This is the x + width.

      • yh: number

        The y value of the bottom-right vertex of the quad. This is the y + height.

      • Optionalquad: Float32Array<ArrayBufferLike>

        Optional Float32Array to store the results in. Otherwise uses the local quad array.

      Returns Float32Array

      The quad Float32Array.

    • Set the values of this Matrix.

      Parameters

      • a: number

        The Scale X value.

      • b: number

        The Shear Y value.

      • c: number

        The Shear X value.

      • d: number

        The Scale Y value.

      • tx: number

        The Translate X value.

      • ty: number

        The Translate Y value.

      Returns this

      This TransformMatrix.

    • Transform the Matrix.

      Parameters

      • a: number

        The Scale X value.

      • b: number

        The Shear Y value.

      • c: number

        The Shear X value.

      • d: number

        The Scale Y value.

      • tx: number

        The Translate X value.

      • ty: number

        The Translate Y value.

      Returns this

      This TransformMatrix.

    • Transform a point in to the local space of this Matrix.

      Parameters

      • x: number

        The x coordinate of the point to transform.

      • y: number

        The y coordinate of the point to transform.

      • Optionalpoint: Vector2Like

        Optional Point object to store the transformed coordinates in.

      Returns Vector2Like

      The Point containing the transformed coordinates.

    • Translate the Matrix.

      Parameters

      • x: number

        The horizontal translation value.

      • y: number

        The vertical translation value.

      Returns this

      This TransformMatrix.