phaser - v4.0.0-rc.4
    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 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

    • 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

    • 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

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

        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