ColorMatrix Class
Provides helper functions for assembling a matrix for use with the ColorMatrixFilter, or can be used directly as the matrix for a 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
()
protected
Make sure values are within the specified range, hue has a limit of 180, brightness is 255, others are 100.
_fixMatrix
()
protected
Makes sure matrixes are 5x5 (25 long).
_multiplyMatrix
()
protected
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:
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:
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:
adjustHue
-
value
Adjusts the hue of the pixel color.
Parameters:
-
value
NumberA value between -180 & 180.
Returns:
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:
clone
()
ColorMatrix
Returns a clone of this ColorMatrix.
Returns:
concat
-
matrix
Concatenates (multiplies) the specified matrix with this one.
Parameters:
-
matrix
ArrayAn array or ColorMatrix instance.
Returns:
copyMatrix
-
matrix
Copy the specified matrix's values to this matrix.
Parameters:
-
matrix
ArrayAn array or ColorMatrix instance.
Returns:
initialize
()
protected
Initialization method.
reset
()
ColorMatrix
Resets the matrix to identity values.