ColorMatrix Class
Provides helper functions for assembling a matrix for use with the ColorMatrixFilter. Most methods return the instance to facilitate chained calls.
Example
myColorMatrix.adjustHue(20).adjustBrightness(50);
See Filter for an example of how to apply filters, or ColorMatrixFilter for an example of how to use ColorMatrix to change a DisplayObject's color.
Constructor
Methods
_cleanValue
-
value
-
limit
Make sure values are within the specified range, hue has a limit of 180, brightness is 255, others are 100.
adjustBrightness
-
value
Adjusts the brightness of pixel color by adding the specified value to the red, green and blue channels. Positive values will make the image brighter, negative values will make it darker.
Parameters:
-
value
NumberA value between -255 & 255 that will be added to the RGB channels.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
adjustColor
-
brightness
-
contrast
-
saturation
-
hue
Shortcut method to adjust brightness, contrast, saturation and hue. Equivalent to calling adjustHue(hue), adjustContrast(contrast), adjustBrightness(brightness), adjustSaturation(saturation), in that order.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
adjustContrast
-
value
Adjusts the contrast of pixel color. Positive values will increase contrast, negative values will decrease contrast.
Parameters:
-
value
NumberA value between -100 & 100.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
adjustHue
-
value
Adjusts the hue of the pixel color.
Parameters:
-
value
NumberA value between -180 & 180.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
adjustSaturation
-
value
Adjusts the color saturation of the pixel. Positive values will increase saturation, negative values will decrease saturation (trend towards greyscale).
Parameters:
-
value
NumberA value between -100 & 100.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
clone
()
ColorMatrix
Returns a clone of this ColorMatrix.
Returns:
A clone of this ColorMatrix.
concat
-
matrix
Concatenates (multiplies) the specified matrix with this one.
Parameters:
-
matrix
ArrayAn array or ColorMatrix instance.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
copy
-
matrix
Copy the specified matrix's values to this matrix.
Parameters:
-
matrix
ArrayAn array or ColorMatrix instance.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
reset
()
ColorMatrix
chainable
Resets the matrix to identity values.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)
setColor
-
brightness
-
contrast
-
saturation
-
hue
Resets the instance with the specified values.
Returns:
The ColorMatrix instance the method is called on (useful for chaining calls.)