Packagegraphics.colors
Classpublic class ColorMatrix
InheritanceColorMatrix Inheritance Object
Implements Cloneable, Serializable

The 5x4 matrix for transforming the color and alpha components of a display. The matrix is stored in a single array, and its treated as follows: [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ] When applied to a color [r, g, b, a], the resulting color is computed as (after clamping) R' = a + b + c + d + e; G' = f + g + h + i + j; B' = k + l + m + n + o; A' = p + q + r + s + t;



Public Properties
 PropertyDefined By
  brightness : Number
Determinates the brightness component of the color matrix.
ColorMatrix
  contrast : Number
Determinates the contrast component of the color matrix.
ColorMatrix
  matrix : Array
The matrix representation of all color components values.
ColorMatrix
  saturation : Number
Determinates the saturation component of the color matrix.
ColorMatrix
Public Methods
 MethodDefined By
  
ColorMatrix(factory:* = null)
Creates a new ColorMatrix instance.
ColorMatrix
  
clone():*
Returns the shallow copy of the object.
ColorMatrix
  
concat(mat:Array):Array
Concatenates the elements of a matrix specified in the parameter with the elements in an array and creates a new matrix
ColorMatrix
  
reset(init:Array = null):void
Reset and sets this colormatrix to identity: [ 1 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ];
ColorMatrix
  
rotate(axis:int, degrees:Number):void
Sets the rotation on a color axis by the specified values.
ColorMatrix
  
scale(r:Number, g:Number, b:Number, a:Number):void
Set this colormatrix to scale by the specified values.
ColorMatrix
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
ColorMatrix
  
toString():String
Returns the String representation of the object.
ColorMatrix
Public Constants
 ConstantDefined By
  B_AXIS : uint = 2
[static] Defines the blue axis value in the rotate method (2).
ColorMatrix
  G_AXIS : uint = 1
[static] Defines the green axis value in the rotate method (1).
ColorMatrix
  GRAYSCALE : Array
[static] The greyscale matrix representation to initialize the ColorMatrix.
ColorMatrix
  IDENTITY : Array
[static] The identity matrix representation to initialize the ColorMatrix.
ColorMatrix
  INVERT : Array
[static] The invert matrix representation to initialize the ColorMatrix.
ColorMatrix
  R_AXIS : uint = 0
[static] Defines the red axis value in the rotate method (0).
ColorMatrix
Protected Constants
 ConstantDefined By
  RAD : Number = 0.017453292519943295
[static] Value to convert a degree value in radian (Math.PI / 180).
ColorMatrix
Property Detail
brightnessproperty
brightness:Number

Determinates the brightness component of the color matrix.


Implementation
    public function get brightness():Number
    public function set brightness(value:Number):void
contrastproperty 
contrast:Number

Determinates the contrast component of the color matrix.


Implementation
    public function get contrast():Number
    public function set contrast(value:Number):void
matrixproperty 
public var matrix:Array

The matrix representation of all color components values.

saturationproperty 
saturation:Number

Determinates the saturation component of the color matrix. Info : The luminance vector where the red value is 0.3086, the green value is 0.6094, and the blue value is 0.0820. Notice here that we do not use the standard NTSC weights of 0.299, 0.587, and 0.114. The NTSC weights are only applicable to RGB colors in a gamma 2.2 color space. For linear RGB colors the values above are better.


Implementation
    public function get saturation():Number
    public function set saturation(value:Number):void

See also

Operations for Image Processing : http://www.graficaobscura.com/matrix/index.html
to RGB Conversion : http://www.fourcc.org/fccyvrgb.php
Constructor Detail
ColorMatrix()Constructor
public function ColorMatrix(factory:* = null)

Creates a new ColorMatrix instance.

Parameters
factory:* (default = null) — The Array or ColorMatrix optional argument to initialize the new ColorMatrix instance. If this argument is null the matrix is the identity 5x4 matrix.
Method Detail
clone()method
public function clone():*

Returns the shallow copy of the object.

Returns
* — the shallow copy of the object.
concat()method 
public function concat(mat:Array):Array

Concatenates the elements of a matrix specified in the parameter with the elements in an array and creates a new matrix

Parameters

mat:Array — The altered Matrix

Returns
Array
reset()method 
public function reset(init:Array = null):void

Reset and sets this colormatrix to identity:

         [ 
          1 , 0 , 0 , 0 , 0 ,
          0 , 1 , 0 , 0 , 0 ,
          0 , 0 , 1 , 0 , 0 ,
          0 , 0 , 0 , 1 , 0 
         ];
         

Parameters

init:Array (default = null)

rotate()method 
public function rotate(axis:int, degrees:Number):void

Sets the rotation on a color axis by the specified values.

Parameters

axis:int — The axis (red, green or blue axis) to rotate.
 
degrees:Number — The angle in degree of the rotation.
  • axis=0 correspond to a rotation around the RED color
  • axis=1 correspond to a rotation around the GREEN color
  • axis=2 correspond to a rotation around the BLUE color

  • Throws
    ArgumentError — if the axis argument is not valid with the value 0, 1 or 2.
    scale()method 
    public function scale(r:Number, g:Number, b:Number, a:Number):void

    Set this colormatrix to scale by the specified values.

    Parameters

    r:Number — The scale value to change the red component of the color.
     
    g:Number — The scale value to change the green component of the color.
     
    b:Number — The scale value to change the blue component of the color.
     
    a:Number — The scale value to change the alpha component of the color.

    toSource()method 
    public function toSource(indent:int = 0):String

    Returns the source code string representation of the object.

    Parameters

    indent:int (default = 0)

    Returns
    String — the source code string representation of the object.
    toString()method 
    public function toString():String

    Returns the String representation of the object.

    Returns
    String — the String representation of the object.
    Constant Detail
    B_AXISConstant
    public static const B_AXIS:uint = 2

    Defines the blue axis value in the rotate method (2).

    G_AXISConstant 
    public static const G_AXIS:uint = 1

    Defines the green axis value in the rotate method (1).

    GRAYSCALEConstant 
    public static const GRAYSCALE:Array

    The greyscale matrix representation to initialize the ColorMatrix.

    IDENTITYConstant 
    public static const IDENTITY:Array

    The identity matrix representation to initialize the ColorMatrix.

    INVERTConstant 
    public static const INVERT:Array

    The invert matrix representation to initialize the ColorMatrix.

    R_AXISConstant 
    public static const R_AXIS:uint = 0

    Defines the red axis value in the rotate method (0).

    RADConstant 
    protected static const RAD:Number = 0.017453292519943295

    Value to convert a degree value in radian (Math.PI / 180).