Packagecom.boostworthy.geom
Classpublic class ColorMatrix
InheritanceColorMatrix Inheritance flash.events.EventDispatcher

The 'ColorMatrix' class presents a useful API for transforming color values using traditional methods such as brightness, contrast, hue, and saturation.

The general mindset behind the calculations for a color matrix are as follows:

redResult = (a[0] srcR) + (a[1] srcG) + (a[2] srcB) + (a[3] srcA) + a[4]
greenResult = (a[5] srcR) + (a[6] srcG) + (a[7] srcB) + (a[8] srcA) + a[9]
blueResult = (a[10] srcR) + (a[11] srcG) + (a[12] srcB) + (a[13] srcA) + a[14]
alphaResult = (a[15] srcR) + (a[16] srcG) + (a[17] srcB) + (a[18] srcA) + a[19]

For more information on the formulas used in this class, see:

http://www.graficaobscura.com/matrix/index.html



Public Properties
 PropertyDefined by
  alpha : Number
Gets the current alpha setting.
ColorMatrix
  brightness : Number
Gets the current brightness setting.
ColorMatrix
  contrast : Number
Gets the current contrast setting.
ColorMatrix
  hue : Number
Gets the current hue setting.
ColorMatrix
  saturation : Number
Gets the current saturation setting.
ColorMatrix
Protected Properties
 PropertyDefined by
  m_aMatrix : Array
Stores the current matrix of values that this object represents.
ColorMatrix
  m_nAlpha : Number
Stores the current alpha setting.
ColorMatrix
  m_nBrightness : Number
Stores the current brightness setting.
ColorMatrix
  m_nContrast : Number
Stores the current contrast setting.
ColorMatrix
  m_nHue : Number
Stores the current hue setting.
ColorMatrix
  m_nSaturation : Number
Stores the current saturation setting.
ColorMatrix
Public Methods
 MethodDefined by
  
ColorMatrix(aMatrix:Array = null)
Constructor.
ColorMatrix
  
Creates a new color matrix object that is a clone of this object.
ColorMatrix
  
reset():void
Resets this object back to it's original state.
ColorMatrix
  
valueOf():Array
Returns the raw array of color transform data that this object represents.
ColorMatrix
Protected Methods
 MethodDefined by
  
init(aMatrix:Array):void
Initializes this object.
ColorMatrix
  
multiply(aMatrix:Array):void
Multiplies the specified matrix array against the one this object represents.
ColorMatrix
  
Applies all default values to the corresponding properties.
ColorMatrix
Events
 EventSummaryDefined by
   Dispatched when the value of this object changes.ColorMatrix
Protected Constants
 ConstantDefined by
  IDENTITY : Array
The default matrix for this object to begin at.
ColorMatrix
  LUMINANCE_B : Number = 0.072169
Configuration for the blue portion of the luminance vector.
ColorMatrix
  LUMINANCE_G : Number = 0.715160
Configuration for the green portion of the luminance vector.
ColorMatrix
  LUMINANCE_R : Number = 0.212671
Configuration for the red portion of the luminance vector.
ColorMatrix
Property detail
alphaproperty
alpha:Number  [read-write]

Gets the current alpha setting.

Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
brightnessproperty 
brightness:Number  [read-write]

Gets the current brightness setting.

Implementation
    public function get brightness():Number
    public function set brightness(value:Number):void
contrastproperty 
contrast:Number  [read-write]

Gets the current contrast setting.

Implementation
    public function get contrast():Number
    public function set contrast(value:Number):void
hueproperty 
hue:Number  [read-write]

Gets the current hue setting.

Implementation
    public function get hue():Number
    public function set hue(value:Number):void
m_aMatrixproperty 
protected var m_aMatrix:Array

Stores the current matrix of values that this object represents.

m_nAlphaproperty 
protected var m_nAlpha:Number

Stores the current alpha setting.

m_nBrightnessproperty 
protected var m_nBrightness:Number

Stores the current brightness setting.

m_nContrastproperty 
protected var m_nContrast:Number

Stores the current contrast setting.

m_nHueproperty 
protected var m_nHue:Number

Stores the current hue setting.

m_nSaturationproperty 
protected var m_nSaturation:Number

Stores the current saturation setting.

saturationproperty 
saturation:Number  [read-write]

Gets the current saturation setting.

Implementation
    public function get saturation():Number
    public function set saturation(value:Number):void
Constructor detail
ColorMatrix()constructor
public function ColorMatrix(aMatrix:Array = null)

Constructor.

Parameters
aMatrix:Array (default = null) — An array of 20 items for 4 x 5 color transform to initialize this object with.
Method detail
clone()method
public function clone():ColorMatrix

Creates a new color matrix object that is a clone of this object.

Returns
ColorMatrix — A new color matrix object.
init()method 
protected function init(aMatrix:Array):void

Initializes this object.

Parameters
aMatrix:Array — An array of 20 items for 4 x 5 color transform to initialize this object with.
multiply()method 
protected function multiply(aMatrix:Array):void

Multiplies the specified matrix array against the one this object represents.

Parameters
aMatrix:Array — An array of 20 items for 4 x 5 color transform to multiply against this object's matrix array.
reset()method 
public function reset():void

Resets this object back to it's original state.

setDefaultValues()method 
protected function setDefaultValues():void

Applies all default values to the corresponding properties.

valueOf()method 
public function valueOf():Array

Returns the raw array of color transform data that this object represents.

Returns
Array — A copy of the color transform matrix that this object represents.
Event detail
changeevent 
Event object type: flash.events.Event

Dispatched when the value of this object changes.

Constant detail
IDENTITYconstant
protected const IDENTITY:Array

The default matrix for this object to begin at.

LUMINANCE_Bconstant 
protected const LUMINANCE_B:Number = 0.072169

Configuration for the blue portion of the luminance vector.

LUMINANCE_Gconstant 
protected const LUMINANCE_G:Number = 0.715160

Configuration for the green portion of the luminance vector.

LUMINANCE_Rconstant 
protected const LUMINANCE_R:Number = 0.212671

Configuration for the red portion of the luminance vector.