Packagecom.whirled.contrib
Classpublic class ColorConversion

Various tools for converting between different color models and applying colors to Movie Clips.

The methods for changing the colors of Movie Clips change the entire Movie clip to that color, it is not a tint. This is useful for Movie Clips that have re-colorable childs to easily change their color. Examples include balloons, game tokens and furniture items.

Author: jdnx429



Public Methods
 MethodDefined by
  
changeColorCMY(mc:MovieClip, CMY:Array):void
[static] Changes the color of a Movie Clip using the CMY color model
ColorConversion
  
changeColorHSB(mc:MovieClip, HSB:Array):void
[static] Changes the color of a Movie Clip using the HSB color model
ColorConversion
  
changeColorRGB(mc:MovieClip, RGB:Array):void
[static] Changes the color of a Movie Clip using the RGB color model
ColorConversion
  
CMYtoHSB(cyan:Number, magenta:Number, yellow:Number):Array
[static] Converts a color from the CMY color model to HSB.
ColorConversion
  
CMYtoRGB(cyan:Number, magenta:Number, yellow:Number):Array
[static] Converts a color from the CMY color model to RGB.
ColorConversion
  
compareColorsCMY(cmy1:Array, cmy2:Array):Number
[static] Returns the color difference between two colors as defined by CIEDE2000.
ColorConversion
  
compareColorsRGB(rgb1:Array, rgb2:Array):Number
[static] Returns the color difference between two colors as defined by CIEDE2000.
ColorConversion
  
HSBtoCMY(hue:Number, sat:Number, bri:Number):Array
[static] Converts a color from the HSB color model to CMY.
ColorConversion
  
HSBtoRGB(hue:Number, sat:Number, bri:Number):Array
[static] Converts a color from the HSB color model to RGB.
ColorConversion
  
RGBtoCMY(r:Number, g:Number, b:Number):Array
[static] Converts a color from the RGB color model to CMY.
ColorConversion
  
RGBtoHSB(r:Number, g:Number, b:Number):Array
[static] Converts a color from the RGB color model to HSB.
ColorConversion
Protected Methods
 MethodDefined by
  
calcColorDiff(currColor:Array, goalColor:Array):Number
[static]
ColorConversion
  
CMYtoLCHab(cmyArray:Array):Array
[static]
ColorConversion
  
HSBtoRGBMultAlpha(hue:Number, sat:Number, bri:Number):Array
[static]
ColorConversion
Method detail
calcColorDiff()method
protected static function calcColorDiff(currColor:Array, goalColor:Array):NumberParameters
currColor:Array
 
goalColor:Array

Returns
Number
changeColorCMY()method 
public static function changeColorCMY(mc:MovieClip, CMY:Array):void

Changes the color of a Movie Clip using the CMY color model

Parameters
mc:MovieClip — the Movie Clip that is to be colored.
 
CMY:Array — an Array in the format of [cyan, magenta, yellow]. The range for each should be 0.0-1.0
changeColorHSB()method 
public static function changeColorHSB(mc:MovieClip, HSB:Array):void

Changes the color of a Movie Clip using the HSB color model

Parameters
mc:MovieClip — the Movie Clip that is to be colored..
 
HSB:Array — an Array in the format of [hue, saturation, brightness]. The range for hue is 0-360. The range for saturation and brightness is 0.0-1.0
changeColorRGB()method 
public static function changeColorRGB(mc:MovieClip, RGB:Array):void

Changes the color of a Movie Clip using the RGB color model

Parameters
mc:MovieClip — the Movie Clip that is to be colored.
 
RGB:Array — an Array in the format of [red, green, blue]. The range for each should be 0-255.
CMYtoHSB()method 
public static function CMYtoHSB(cyan:Number, magenta:Number, yellow:Number):Array

Converts a color from the CMY color model to HSB. The values for cyan, magenta, and yellow should be supplied in the range of 0.0 to 1.0.

Parameters
cyan:Number — the cyan value.
 
magenta:Number — the magenta value.
 
yellow:Number — the yellow value

Returns
Array — an Array in the format [hue, saturation, brightness]. The range for hue is 0-360. The range for saturation and brightness is 0.0-1.0
CMYtoLCHab()method 
protected static function CMYtoLCHab(cmyArray:Array):ArrayParameters
cmyArray:Array

Returns
Array
CMYtoRGB()method 
public static function CMYtoRGB(cyan:Number, magenta:Number, yellow:Number):Array

Converts a color from the CMY color model to RGB. The values for the arguments should be in the range of 0.0-1.0.

Parameters
cyan:Number
 
magenta:Number
 
yellow:Number

Returns
Array — an Array in the format [red, green, blue]. The range for all is 0-255.
compareColorsCMY()method 
public static function compareColorsCMY(cmy1:Array, cmy2:Array):Number

Returns the color difference between two colors as defined by CIEDE2000. The maximum color difference, that between black and white is 100.

The range of the arguments should be 0.0 to 1.0

Parameters
cmy1:Array — the first color to be compared in the format of [cyan, magenta, yellow]
 
cmy2:Array — the second color to be compared in the format of [cyan, magenta, yellow]

Returns
Number — the difference between two colors, in the range of 0-100.
compareColorsRGB()method 
public static function compareColorsRGB(rgb1:Array, rgb2:Array):Number

Returns the color difference between two colors as defined by CIEDE2000. The maximum color difference, that between black and white is 100.

The range of the arguments should be 0 to 255

Parameters
rgb1:Array — the first color to be compared in the format of [red, green, blue]
 
rgb2:Array — the second color to be compared in the format of [red, green, blue]

Returns
Number — the difference between two colors, in the range of 0-100.
HSBtoCMY()method 
public static function HSBtoCMY(hue:Number, sat:Number, bri:Number):Array

Converts a color from the HSB color model to CMY. The value for hue should be in the range of 0-360. Sat and bri should be in the range of 0.0 to 1.0

Parameters
hue:Number — the hue of the color.
 
sat:Number — the saturation value.
 
bri:Number — the brightness value.

Returns
Array — an Array in the format [cyan, magenta, yellow]. The range for all is 0.0 to 1.0
HSBtoRGB()method 
public static function HSBtoRGB(hue:Number, sat:Number, bri:Number):Array

Converts a color from the HSB color model to RGB. The value for hue should be in the range of 0-360. Sat and bri should be in the range of 0.0 to 1.0

Parameters
hue:Number — the hue of the color.
 
sat:Number — the saturation value.
 
bri:Number — the brightness value.

Returns
Array — an Array in the format [red, green, blue]. The range for all is 0-255.
HSBtoRGBMultAlpha()method 
protected static function HSBtoRGBMultAlpha(hue:Number, sat:Number, bri:Number):ArrayParameters
hue:Number
 
sat:Number
 
bri:Number

Returns
Array
RGBtoCMY()method 
public static function RGBtoCMY(r:Number, g:Number, b:Number):Array

Converts a color from the RGB color model to CMY. The values for the arguments should be in the range of 0-255.

Parameters
r:Number — the red value.
 
g:Number — the green value.
 
b:Number — the blue value.

Returns
Array — an Array in the format [cyan, magenta, yellow]. The range for all is 0-1.
RGBtoHSB()method 
public static function RGBtoHSB(r:Number, g:Number, b:Number):Array

Converts a color from the RGB color model to HSB. The values for the arguments should be supplied in the range of 0 to 255.

Parameters
r:Number — the red value.
 
g:Number — the green value.
 
b:Number — the blue value

Returns
Array — an Array in the format [hue, saturation, brightness]. The range for hue is 0-360. The range for saturation and brightness is 0.0-1.0