Packagesandy.math
Classpublic class ColorMath

Math functions for colors.



Public Methods
 MethodDefined by
  
calculateLitColour(col:Number, lightStrength:Number):Number
[static] Calculate the colour for a particular lighting strength.
ColorMath
  
changeAlpha(c:uint, a:Number):uint
[static] Returns the color with altered alpha value.
ColorMath
  
hex2rgb(hex:Number):Object
[static] Converts a hexadecimal color value to rgb components
ColorMath
  
hex2rgbn(hex:Number):Object
[static] Converts hexadecimal color value to normalized rgb components ( 0 - 1 ).
ColorMath
  
rgb2hex(r:Number, g:Number, b:Number):Number
[static] Converts color component values ( rgb ) to one hexadecimal value.
ColorMath
Method detail
calculateLitColour()method
public static function calculateLitColour(col:Number, lightStrength:Number):Number

Calculate the colour for a particular lighting strength. This converts the supplied pre-multiplied RGB colour into HSL then modifies the L according to the light strength. The result is then mapped back into the RGB space.

Parameters
col:Number
 
lightStrength:Number

Returns
Number
changeAlpha()method 
public static function changeAlpha(c:uint, a:Number):uint

Returns the color with altered alpha value.

Parameters
c:uint — 32-bit color.
 
a:Number — New alpha. ( 0 - 1 )

Returns
uint — The hexadecimal value
hex2rgb()method 
public static function hex2rgb(hex:Number):Object

Converts a hexadecimal color value to rgb components

Parameters
hex:Number — hexadecimal color.

Returns
Object — The rgb color of the hexadecimal given.
hex2rgbn()method 
public static function hex2rgbn(hex:Number):Object

Converts hexadecimal color value to normalized rgb components ( 0 - 1 ).

Parameters
hex:Number — hexadecimal color value.

Returns
Object — The normalized rgb components ( 0 - 1.0 )
rgb2hex()method 
public static function rgb2hex(r:Number, g:Number, b:Number):Number

Converts color component values ( rgb ) to one hexadecimal value.

Parameters
r:Number — Red Color. ( 0 - 255 )
 
g:Number — Green Color. ( 0 - 255 )
 
b:Number — Blue Color. ( 0 - 255 )

Returns
Number — The hexadecimal value