| Package | starling.filters |
| Class | public class ColorMatrixFilter |
| Inheritance | ColorMatrixFilter FragmentFilter Object |
The class contains several convenience methods for frequently used color adjustments. All those methods change the current matrix, which means you can easily combine them in one filter:
// create an inverted filter with 50% saturation and 180° hue rotation
var filter:ColorMatrixFilter = new ColorMatrixFilter();
filter.invert();
filter.adjustSaturation(-0.5);
filter.adjustHue(1.0);If you want to gradually animate one of the predefined color adjustments, either reset the matrix after each step, or use an identical adjustment value for each step; the changes will add up.
| Property | Defined By | ||
|---|---|---|---|
![]() | isCached : Boolean [read-only] Indicates if the filter is cached (via the "cache" method). | FragmentFilter | |
| matrix : Vector.<Number> A vector of 20 items arranged as a 4x5 matrix. | ColorMatrixFilter | ||
![]() | mode : String The filter mode, which is one of the constants defined in the "FragmentFilterMode"
class. | FragmentFilter | |
![]() | offsetX : Number Use the x-offset to move the filter output to the right or left. | FragmentFilter | |
![]() | offsetY : Number Use the y-offset to move the filter output to the top or bottom. | FragmentFilter | |
![]() | resolution : Number The resolution of the filter texture. | FragmentFilter | |
| Method | Defined By | ||
|---|---|---|---|
ColorMatrixFilter(matrix:Vector.<Number> = null) Creates a new ColorMatrixFilter instance with the specified matrix. | ColorMatrixFilter | ||
adjustBrightness(value:Number):void Changes the brightness. | ColorMatrixFilter | ||
adjustContrast(value:Number):void Changes the contrast. | ColorMatrixFilter | ||
adjustHue(value:Number):void Changes the hue of the image. | ColorMatrixFilter | ||
adjustSaturation(sat:Number):void Changes the saturation. | ColorMatrixFilter | ||
![]() | cache():void Caches the filter output into a texture. | FragmentFilter | |
![]() | clearCache():void Clears the cached output of the filter. | FragmentFilter | |
concat(matrix:Vector.<Number>):void Concatenates the current matrix with another one. | ColorMatrixFilter | ||
dispose():void [override] Disposes the filter (programs, buffers, textures). | ColorMatrixFilter | ||
invert():void Inverts the colors of the filtered objects. | ColorMatrixFilter | ||
![]() | Applies the filter on a certain display object, rendering the output into the current
render target. | FragmentFilter | |
reset():void Changes the filter matrix back to the identity matrix. | ColorMatrixFilter | ||
| matrix | property |
matrix:Vector.<Number>A vector of 20 items arranged as a 4x5 matrix.
public function get matrix():Vector.<Number> public function set matrix(value:Vector.<Number>):void| ColorMatrixFilter | () | Constructor |
public function ColorMatrixFilter(matrix:Vector.<Number> = null)Creates a new ColorMatrixFilter instance with the specified matrix.
Parametersmatrix:Vector.<Number> (default = null) — a vector of 20 items arranged as a 4x5 matrix.
|
| adjustBrightness | () | method |
public function adjustBrightness(value:Number):voidChanges the brightness. Typical values are in the range (-1, 1). Values above zero will make the image brighter, values below zero will make it darker.
Parameters
value:Number |
| adjustContrast | () | method |
public function adjustContrast(value:Number):voidChanges the contrast. Typical values are in the range (-1, 1). Values above zero will raise, values below zero will reduce the contrast.
Parameters
value:Number |
| adjustHue | () | method |
public function adjustHue(value:Number):voidChanges the hue of the image. Typical values are in the range (-1, 1).
Parameters
value:Number |
| adjustSaturation | () | method |
public function adjustSaturation(sat:Number):voidChanges the saturation. Typical values are in the range (-1, 1). Values above zero will raise, values below zero will reduce the saturation. '-1' will produce a grayscale image.
Parameters
sat:Number |
| concat | () | method |
public function concat(matrix:Vector.<Number>):voidConcatenates the current matrix with another one.
Parameters
matrix:Vector.<Number> |
| dispose | () | method |
override public function dispose():voidDisposes the filter (programs, buffers, textures).
| invert | () | method |
public function invert():voidInverts the colors of the filtered objects.
| reset | () | method |
public function reset():voidChanges the filter matrix back to the identity matrix.