phaser - v3.90.0
    Preparing search index...

    A Matrix used for display transformations for rendering.

    It is represented like so:

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

    Constructors

    • 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

    Properties

    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.

    quad: Float32Array

    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.

    Methods

    • 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: Math.Vector2

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

      Returns Math.Vector2

    • 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

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

      Parameters

      Returns this

    • 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

    • 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[]

    • Copy the values from this Matrix to the given Canvas Rendering Context. This will use the Context.transform method.

      Parameters

      • ctx: CanvasRenderingContext2D

        The Canvas Rendering Context to copy the matrix values to.

      Returns CanvasRenderingContext2D

    • 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 -> scale

      Returns DecomposeMatrixResults

    • Destroys this Transform Matrix.

      Returns void

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

      Returns string

    • 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

    • 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

    • 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

    • 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

    • Invert the Matrix.

      Returns this

    • Reset the Matrix to an identity matrix.

      Returns this

    • 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

    • 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: offsetY * 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

    • Rotate the Matrix.

      Parameters

      • angle: number

        The angle of rotation in radians.

      Returns this

    • Scale the Matrix.

      Parameters

      • x: number

        The horizontal scale value.

      • y: number

        The vertical scale value.

      Returns this

    • Performs the 8 calculations required to create the vertices of a quad based on this matrix and the given x/y/xw/yh values.

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

      Parameters

      • x: number

        The x value.

      • y: number

        The y value.

      • xw: number

        The xw value.

      • yh: number

        The yh value.

      • OptionalroundPixels: boolean

        Pass the results via Math.round? Default false.

      • Optionalquad: Float32Array

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

      Returns Float32Array

    • Copy the values from this Matrix to the given Canvas Rendering Context. This will use the Context.setTransform method.

      Parameters

      • ctx: CanvasRenderingContext2D

        The Canvas Rendering Context to copy the matrix values to.

      Returns CanvasRenderingContext2D

    • 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

    • 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

    • 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

    • Translate the Matrix.

      Parameters

      • x: number

        The horizontal translation value.

      • y: number

        The vertical translation value.

      Returns this