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)
Static ReadonlyALPHA_A constant array used by the ColorMatrix class for alpha-to-brightness operations.
Static ReadonlyALPHA_A constant array used by the ColorMatrix class for inverse alpha-to-brightness operations.
Static ReadonlyBLACKA constant array used by the ColorMatrix class for black operations.
Static ReadonlyBLACK_A constant array used by the ColorMatrix class for black_white operations.
Static ReadonlyBRIGHTNESS_A constant array used by the ColorMatrix class for brightness-to-alpha operations.
Static ReadonlyBRIGHTNESS_A constant array used by the ColorMatrix class for inverse brightness-to-alpha operations.
Static ReadonlyBROWNA constant array used by the ColorMatrix class for brown operations.
Static ReadonlyDESATURATE_A constant array used by the ColorMatrix class for desaturated luminance operations.
Static ReadonlyKODACHROMEA constant array used by the ColorMatrix class for kodachrome operations.
Static ReadonlyLSDA constant array used by the ColorMatrix class for lsd operations.
Static ReadonlyNEGATIVEA constant array used by the ColorMatrix class for negative operations.
Static ReadonlyPOLAROIDA constant array used by the ColorMatrix class for polaroid shift operations.
Static ReadonlySEPIAA constant array used by the ColorMatrix class for sepia operations.
Static ReadonlySHIFT_A constant array used by the ColorMatrix class for shift BGR operations.
Static ReadonlyTECHNICOLORA constant array used by the ColorMatrix class for technicolor operations.
Static ReadonlyVINTAGEA 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.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
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.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Sets this ColorMatrix to be black, only preserving alpha. Useful for cases where you only want the alpha.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Sets this ColorMatrix to be black and white.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Changes the brightness of this ColorMatrix by the given amount.
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.
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.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
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.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a brown tone to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Change the contrast of this ColorMatrix by the amount given.
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.
This ColorMatrix instance.
Desaturates this ColorMatrix (removes color from it).
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Apply a desaturated luminance to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Gets the ColorMatrix as a Float32Array.
Can be used directly as a 1fv shader uniform value.undefined
The ColorMatrix as a Float32Array.
Sets this ColorMatrix to be grayscale.
Optionalvalue: number
The grayscale scale (0 is black). Default 1.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Rotates the hues of this ColorMatrix by the value given.
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.
This ColorMatrix instance.
Applies a kodachrome color effect to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a trippy color tone to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Multiplies the given matrix a against the current _matrix.
The 5x4 array to multiply with ColorMatrix._matrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Converts this ColorMatrix to have negative values.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a night vision tone to this ColorMatrix.
Optionalintensity: number
The intensity of this effect. Default 0.1.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a polaroid color effect to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Resets the ColorMatrix to default values and also resets
the alpha property back to 1.undefined
This ColorMatrix instance.
Changes the saturation of this ColorMatrix by the given amount.
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.
This ColorMatrix instance.
Applies a sepia tone to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Sets this ColorMatrix from the given array of color values.
The ColorMatrix values to set. Must have 20 elements.
This ColorMatrix instance.
Shifts the values of this ColorMatrix into BGR order.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a technicolor color effect to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
Applies a vintage pinhole color effect to this ColorMatrix.
Optionalmultiply: boolean
Multiply the resulting ColorMatrix (true), or set it (false) ? Default false.
This ColorMatrix instance.
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
getDatato 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).