Core. ColorFilter

ColorFilter Color filter. Use ColorFilter The class can apply the 4 x 5 matrix transformation to the RGBA color and Alpha value of each pixel on the input image to generate a result with a new set of RGBA colors and Alpha values. This class allows saturation changes, hue rotation, brightness transfer, Alpha, and a variety of other effects. You can apply filters to any display object (that is, objects inherited from the Sprite class).

Note: for RGBA values, the highest significant byte represents the red channel value, and the subsequent valid bytes represent the green, blue, and Alpha channel values.

Constructor

new ColorFilter(matopt)

Create a ColorFilter Example。
Parameters:
Name Type Attributes Default Description
mat Array <optional>
null mat (optional) an array of 20 items (arranged in 4 x 5 matrices) used for color conversion.

Extends

Methods

adjustBrightness(brightness) → {ColorFilter}

adjust brightness
Parameters:
Name Type Description
brightness Number Brightness range: -100~100
Returns:
Type:
ColorFilter
This

adjustColor(brightness, contrast, saturation, hue) → {ColorFilter}

Adjust colors, including brightness, contrast, saturation, and hue
Parameters:
Name Type Description
brightness Number Brightness range: -100~100
contrast Number Contrast range: -100~100
saturation Number Saturation range: -100~100
hue Number Range of colors: -180~180
Returns:
Type:
ColorFilter
This

adjustContrast(contrast) → {ColorFilter}

Adjust contrast
Parameters:
Name Type Description
contrast Number Contrast range: -100~100
Returns:
Type:
ColorFilter
This

adjustHue(hue) → {ColorFilter}

Toning
Parameters:
Name Type Description
hue Number Range of colors: -180~180
Returns:
Type:
ColorFilter
This

adjustSaturation(saturation) → {ColorFilter}

desaturate
Parameters:
Name Type Description
saturation Number Saturation range: -100~100
Returns:
Type:
ColorFilter
This

color(redopt, greenopt, blueopt, alphaopt)

Set to color filter
Parameters:
Name Type Attributes Default Description
red Number <optional>
0 red Red increment, range: 0~255
green Number <optional>
0 green Green increment, range: 0~255
blue Number <optional>
0 blue Blue increment, range: 0~255
alpha Number <optional>
1 alpha Alpha, range: 0~1

gray()

Set to gray filter

reset()

Reset to unit matrix to remove filter effect

setByMatrix(matrix) → {ColorFilter}

Set matrix data
Parameters:
Name Type Description
matrix Array An array consisting of 20 items (arranged in 4 x 5 matrices)
Returns:
Type:
ColorFilter
This