ColorMatrix

EventDispatcher
ColorMatrix

The ‘ColorMatrix’ class presents a useful API for transforming color values using traditional methods such as brightness, contrast, hue, and saturation.  <p> The general mindset behind the calculations for a color matrix are as follows: <p> redResult = (a[0] * srcR) + (a[1] * srcG) + (a[2] * srcB) + (a[3] * srcA) + a[4] <br> greenResult = (a[5] * srcR) + (a[6] * srcG) + (a[7] * srcB) + (a[8] * srcA) + a[9] <br> blueResult = (a[10] * srcR) + (a[11] * srcG) + (a[12] * srcB) + (a[13] * srcA) + a[14] <br> alphaResult = (a[15] * srcR) + (a[16] * srcG) + (a[17] * srcB) + (a[18] * srcA) + a[19] <p> For more information on the formulas used in this class, see: <p> http://www.graficaobscura.com/matrix/index.html

Summary
ColorMatrixThe ‘ColorMatrix’ class presents a useful API for transforming color values using traditional methods such as brightness, contrast, hue, and saturation.
Constants
LUMINANCE_RConfiguration for the red portion of the luminance vector.
LUMINANCE_GConfiguration for the green portion of the luminance vector.
LUMINANCE_BConfiguration for the blue portion of the luminance vector.
IDENTITYThe default matrix for this object to begin at.
Variables
m_aMatrixStores the current matrix of values that this object represents.
m_nAlphaStores the current alpha setting.
m_nBrightnessStores the current brightness setting.
m_nContrastStores the current contrast setting.
m_nHueStores the current hue setting.
m_nSaturationStores the current saturation setting.
Functions
ColorMatrixConstructor.
valueOfReturns the raw array of color transform data that this object represents.
cloneCreates a new color matrix object that is a clone of this object.
resetResets this object back to it’s original state.
Properties
alphaGets the current alpha setting.
alphaSets the current alpha setting.
brightnessGets the current brightness setting.
brightnessSets the current brightness setting.
contrastGets the current contrast setting.
contrastSets the current contrast setting.
hueGets the current hue setting.
hueSets the current hue setting.
saturationGets the current saturation setting.
saturationSets the current saturation setting.
Functions
initInitializes this object.
setDefaultValuesApplies all default values to the corresponding properties.
multiplyMultiplies the specified matrix array against the one this object represents.

Constants

LUMINANCE_R

protected const LUMINANCE_R: Number

Configuration for the red portion of the luminance vector.

LUMINANCE_G

protected const LUMINANCE_G: Number

Configuration for the green portion of the luminance vector.

LUMINANCE_B

protected const LUMINANCE_B: Number

Configuration for the blue portion of the luminance vector.

IDENTITY

protected const IDENTITY: Array

The default matrix for this object to begin at.

Variables

m_aMatrix

protected var m_aMatrix: Array

Stores the current matrix of values that this object represents.

m_nAlpha

protected var m_nAlpha: Number

Stores the current alpha setting.

m_nBrightness

protected var m_nBrightness: Number

Stores the current brightness setting.

m_nContrast

protected var m_nContrast: Number

Stores the current contrast setting.

m_nHue

protected var m_nHue: Number

Stores the current hue setting.

m_nSaturation

protected var m_nSaturation: Number

Stores the current saturation setting.

Functions

ColorMatrix

public function ColorMatrix(aMatrix: Array = null)

Constructor.

Parameters

param aMatrix An array of 20 items for 4 x 5 color transform to initialize this object with. 

valueOf

public function valueOf():Array

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

Returns

A copy of the color transform matrix that this object represents. 

clone

public function clone():ColorMatrix

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

Returns

A new color matrix object. 

reset

public function reset():void

Resets this object back to it’s original state.

Properties

alpha

public function get alpha():Number

Gets the current alpha setting.

Returns

A value between 0 and 100 (0 being 0% alpha, 100 being 100% alpha). 

alpha

public function set alpha(nAlpha: Number):void

Sets the current alpha setting.

Parameters

param nAlpha A value between 0 and 100 (0 being 0% alpha, 100 being 100% alpha). 

brightness

public function get brightness():Number

Gets the current brightness setting.

Returns

A value between -100 and 100 (0 being ‘no changes’). 

brightness

public function set brightness(nBrightness: Number):void

Sets the current brightness setting.

Parameters

param nBrightness A value between -100 and 100 (0 being ‘no changes’). 

contrast

public function get contrast():Number

Gets the current contrast setting.

Returns

A value between -100 and 100 (0 being ‘no changes’). 

contrast

public function set contrast(nContrast: Number):void

Sets the current contrast setting.

Parameters

param nContrast A value between -100 and 100 (0 being ‘no changes’). 

hue

public function get hue():Number

Gets the current hue setting.

Returns

A value between -180 and 180 (0 being ‘no changes’). 

hue

public function set hue(nAngle: Number):void

Sets the current hue setting.

Parameters

param nAngle A value between -180 and 180 (0 being ‘no changes’). 

saturation

public function get saturation():Number

Gets the current saturation setting.

Returns

A value between -100 and 100 (0 being ‘no changes’). 

saturation

public function set saturation(nSaturation: Number):void

Sets the current saturation setting.

Parameters

param nSaturation A value between -100 and 100 (0 being ‘no changes’). 

Functions

init

protected function init(aMatrix: Array):void

Initializes this object.

Parameters

param aMatrix An array of 20 items for 4 x 5 color transform to initialize this object with. 

setDefaultValues

protected function setDefaultValues():void

Applies all default values to the corresponding properties.

multiply

protected function multiply(aMatrix: Array):void

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

Parameters

param aMatrix An array of 20 items for 4 x 5 color transform to multiply against this object’s matrix array. 
protected const LUMINANCE_R: Number
Configuration for the red portion of the luminance vector.
protected const LUMINANCE_G: Number
Configuration for the green portion of the luminance vector.
protected const LUMINANCE_B: Number
Configuration for the blue portion of the luminance vector.
protected const IDENTITY: Array
The default matrix for this object to begin at.
protected var m_aMatrix: Array
Stores the current matrix of values that this object represents.
protected var m_nAlpha: Number
Stores the current alpha setting.
protected var m_nBrightness: Number
Stores the current brightness setting.
protected var m_nContrast: Number
Stores the current contrast setting.
protected var m_nHue: Number
Stores the current hue setting.
protected var m_nSaturation: Number
Stores the current saturation setting.
public function ColorMatrix(aMatrix: Array = null)
Constructor.
public function valueOf():Array
Returns the raw array of color transform data that this object represents.
public function clone():ColorMatrix
Creates a new color matrix object that is a clone of this object.
public function reset():void
Resets this object back to it’s original state.
public function get alpha():Number
Gets the current alpha setting.
public function get brightness():Number
Gets the current brightness setting.
public function get contrast():Number
Gets the current contrast setting.
public function get hue():Number
Gets the current hue setting.
public function get saturation():Number
Gets the current saturation setting.
protected function init(aMatrix: Array):void
Initializes this object.
protected function setDefaultValues():void
Applies all default values to the corresponding properties.
protected function multiply(aMatrix: Array):void
Multiplies the specified matrix array against the one this object represents.
Close