phaser - v3.90.0
    Preparing search index...

    Class ColorMatrix

    The ColorMatrix FX Controller.

    This FX controller manages the color matrix effect for a Game Object.

    The color matrix effect is a visual technique that involves manipulating the colors of an image or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, allowing developers to create various stylistic appearances or mood settings within the game. Common applications include simulating different lighting conditions, applying color filters, or achieving a specific visual style.

    A ColorMatrix effect is added to a Game Object via the FX component:

    const sprite = this.add.sprite();

    sprite.preFX.addColorMatrix();
    sprite.postFX.addColorMatrix();

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    active: boolean

    Toggle this boolean to enable or disable this effect, without removing and adding it from the Game Object.

    alpha: number

    The value that determines how much of the original color is used when mixing the colors. A value between 0 (all original) and 1 (all final)

    gameObject: GameObject

    A reference to the Game Object that owns this effect.

    type: number

    The FX_CONST type of this effect.

    BLACK_WHITE: number[]

    A constant array used by the ColorMatrix class for black_white operations.

    BROWN: number[]

    A constant array used by the ColorMatrix class for brown operations.

    DESATURATE_LUMINANCE: number[]

    A constant array used by the ColorMatrix class for desatured luminance operations.

    KODACHROME: number[]

    A constant array used by the ColorMatrix class for kodachrome operations.

    LSD: number[]

    A constant array used by the ColorMatrix class for lsd operations.

    NEGATIVE: number[]

    A constant array used by the ColorMatrix class for negative operations.

    POLAROID: number[]

    A constant array used by the ColorMatrix class for polaroid shift operations.

    SEPIA: number[]

    A constant array used by the ColorMatrix class for sepia operations.

    SHIFT_BGR: number[]

    A constant array used by the ColorMatrix class for shift BGR operations.

    TECHNICOLOR: number[]

    A constant array used by the ColorMatrix class for technicolor operations.

    VINTAGE: number[]

    A constant array used by the ColorMatrix class for vintage pinhole operations.

    Methods

    • Sets this ColorMatrix to be black and white.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Changes the brightness of this ColorMatrix by the given amount.

      Parameters

      • Optionalvalue: number

        The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1. Default 0.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a brown tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Change the contrast of this ColorMatrix by the amount given.

      Parameters

      • Optionalvalue: number

        The amount of contrast to apply to this ColorMatrix. Default 0.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Apply a desaturated luminance to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Gets the ColorMatrix as a Float32Array.

      Can be used directly as a 1fv shader uniform value.

      Returns Float32Array

    • Sets this ColorMatrix to be grayscale.

      Parameters

      • Optionalvalue: number

        The grayscale scale (0 is black). Default 1.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Rotates the hues of this ColorMatrix by the value given.

      Parameters

      • Optionalrotation: number

        The amount of hue rotation to apply to this ColorMatrix, in degrees. Default 0.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a kodachrome color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a trippy color tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Multiplies the two given matrices.

      Parameters

      • a: number[]

        The 5x4 array to multiply with ColorMatrix._matrix.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Converts this ColorMatrix to have negative values.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a night vision tone to this ColorMatrix.

      Parameters

      • Optionalintensity: number

        The intensity of this effect. Default 0.1.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a polaroid color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Resets the ColorMatrix to default values and also resets the alpha property back to 1.

      Returns this

    • Changes the saturation of this ColorMatrix by the given amount.

      Parameters

      • Optionalvalue: number

        The amount of saturation to apply to this ColorMatrix. Default 0.

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Desaturates this ColorMatrix (removes color from it).

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a sepia tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Sets this ColorMatrix from the given array of color values.

      Parameters

      • value: number[] | Float32Array<ArrayBuffer>

        The ColorMatrix values to set. Must have 20 elements.

      Returns this

    • Shifts the values of this ColorMatrix into BGR order.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a technicolor color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this

    • Applies a vintage pinhole color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

        Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.

      Returns this