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):ColorMatrixFilter Changes the brightness. | ColorMatrixFilter | ||
adjustContrast(value:Number):ColorMatrixFilter Changes the contrast. | ColorMatrixFilter | ||
adjustHue(value:Number):ColorMatrixFilter Changes the hue of the image. | ColorMatrixFilter | ||
adjustSaturation(sat:Number):ColorMatrixFilter 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>):ColorMatrixFilter Concatenates the current matrix with another one. | ColorMatrixFilter | ||
dispose():void Disposes the filter (programs, buffers, textures). | FragmentFilter | ||
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 | ||
Changes the filter matrix back to the identity matrix. | ColorMatrixFilter | ||
tint(color:uint, amount:Number = 1.0):ColorMatrixFilter Tints the image in a certain color, analog to what can be done in Flash Pro. | 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):ColorMatrixFilter
Changes 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 |
ColorMatrixFilter |
adjustContrast | () | method |
public function adjustContrast(value:Number):ColorMatrixFilter
Changes 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 |
ColorMatrixFilter |
adjustHue | () | method |
public function adjustHue(value:Number):ColorMatrixFilter
Changes the hue of the image. Typical values are in the range (-1, 1).
Parameters
value:Number |
ColorMatrixFilter |
adjustSaturation | () | method |
public function adjustSaturation(sat:Number):ColorMatrixFilter
Changes 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 |
ColorMatrixFilter |
concat | () | method |
public function concat(matrix:Vector.<Number>):ColorMatrixFilter
Concatenates the current matrix with another one.
Parameters
matrix:Vector.<Number> |
ColorMatrixFilter |
invert | () | method |
public function invert():ColorMatrixFilter
Inverts the colors of the filtered objects.
ReturnsColorMatrixFilter |
reset | () | method |
public function reset():ColorMatrixFilter
Changes the filter matrix back to the identity matrix.
ReturnsColorMatrixFilter |
tint | () | method |
public function tint(color:uint, amount:Number = 1.0):ColorMatrixFilter
Tints the image in a certain color, analog to what can be done in Flash Pro.
Parameters
color:uint — the RGB color with which the image should be tinted.
| |
amount:Number (default = 1.0 ) — the intensity with which tinting should be applied. Range (0, 1). |
ColorMatrixFilter |