PokéRogue
    Preparing search index...

    The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics operations. It provides methods required to modify the color values, such as adjusting the brightness, setting a sepia tone, hue rotation and more.

    The matrix rows (indices 0, 1, 2, 3, 4 form the first row) are summed to create the red, green, blue, and alpha channels in order. The matrix columns (indices 0, 5, 10, 15 form the first column) describe contributions from the initial channels, typically in the range -1 to 1. The last column (4, 9, 14, 19) contains an addition, expected to be in the range 0-255 (although other values are valid). For example, to set the red channel to the contents of the green channel, the first row would be [0, 1, 0, 0, 0]. To set the red channel to full, regardless of current channels, the first row would be [0, 0, 0, 0, 255].

    These operations are the default use, but you can use ColorMatrix to conveniently store data for other purposes.

    Use the method getData to return a Float32Array containing the current color values. This shrinks the addition column from the range 0-255 to 0-1 (but does not clamp it).

    Index
    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)

    ALPHA_TO_BRIGHTNESS: number[]

    A constant array used by the ColorMatrix class for alpha-to-brightness operations.

    ALPHA_TO_BRIGHTNESS_INVERSE: number[]

    A constant array used by the ColorMatrix class for inverse alpha-to-brightness operations.

    BLACK: number[]

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

    BLACK_WHITE: number[]

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

    BRIGHTNESS_TO_ALPHA: number[]

    A constant array used by the ColorMatrix class for brightness-to-alpha operations.

    BRIGHTNESS_TO_ALPHA_INVERSE: number[]

    A constant array used by the ColorMatrix class for inverse brightness-to-alpha 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 desaturated 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.

    • Applies an alpha-to-brightness color effect to this ColorMatrix. This replaces the color with a grayscale depiction of the original alpha, where black represents transparency and white represents opacity, and sets the alpha to full.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Applies an alpha-to-brightness color effect to this ColorMatrix. This replaces the color with a grayscale depiction of the original alpha, where white represents transparency and black represents opacity, and sets the alpha to full.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Sets this ColorMatrix to be black, only preserving alpha. Useful for cases where you only want the alpha.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Sets this ColorMatrix to be black and white.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Applies a brightness-to-alpha color effect to this ColorMatrix. This preserves RGB, but replaces the alpha with the brightness of the color.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Applies a brightness-to-alpha color effect to this ColorMatrix. This preserves RGB, but replaces the alpha with the brightness of the color, inverted.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Applies a brown tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Desaturates this ColorMatrix (removes color from it).

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Apply a desaturated luminance to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Gets the ColorMatrix as a Float32Array.

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

      Returns Float32Array

      The ColorMatrix as a 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

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Applies a kodachrome color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Applies a trippy color tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • Multiplies the given matrix a against the current _matrix.

      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

      This ColorMatrix instance.

    • Converts this ColorMatrix to have negative values.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Applies a polaroid color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

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

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Applies a sepia tone to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

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

      Parameters

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.

    • Applies a technicolor color effect to this ColorMatrix.

      Parameters

      • Optionalmultiply: boolean

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

      Returns this

      This ColorMatrix instance.

    • 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

      This ColorMatrix instance.