ColorTransformUtil (com.robertpenner.utils.ColorTransformUtil)

com.robertpenner.utils.ColorTransformUtil
class ColorTransformUtil

The ColorTransformUtil class includes a collection of utilities that allows for more intuitive color manipulation.

Availability:

ActionScript 2.0; Flash Player 8

Method summary

Method Description
setRGBStr(colorTrans:ColorTransform, hexStr:String) : Void

Specifies an RGB color for a ColorTransform object using a string hexadecimal value.

getRGBStr(colorTrans:ColorTransform) : String

Returns the R+G+B combination currently in use by the ColorTransform object as a string hexadecimal value.

setRGB2(colorTrans:ColorTransform, r:Number, g:Number, b:Number) : Void

Specifies an RGB color for a ColorTransform object using individual red, green, and blue values.

getRGB2(colorTrans:ColorTransform) : Object

Returns the R+G+B values currently in use by the ColorTransform object as individual red, green, and blue values.

reset(colorTrans:ColorTransform) : Void

Resets a ColorTransform object to its default values.

setBrightness(colorTrans:ColorTransform, bright:Number) : Void

Specifies the brightness of a ColorTransform object.

getBrightness(colorTrans:ColorTransform) : Number

Returns the brightness of a ColorTransform object.

setBrightOffset(colorTrans:ColorTransform, offset:Number) : Void

Pushes a ColorTransform object towards black or white by an absolute amount.

getBrightOffset(colorTrans:ColorTransform) : Number

Returns the brightness offset value of a ColorTransform object.

setTint(colorTrans:ColorTransform, r:Number, g:Number, b:Number, percent:Number) : Void

Tints a ColorTransform object with a color according to a certain percentage.

getTint(colorTrans:ColorTransform) : Object

Returns the tint of a ColorTransform object.

setTint2(colorTrans:ColorTransform, rgb:Number, percent:Number) : Void

Tints a ColorTransform object with a color according to a certain percentage.

getTint2(colorTrans:ColorTransform) : Object

Returns the tint of a ColorTransform object.

setTintOffset(colorTrans:ColorTransform, r:Number, g:Number, b:Number) : Void

Tints a ColorTransform object with a color according to red, green, and blue values.

getTintOffset(colorTrans:ColorTransform) : Object

Returns the tint offset of a ColorTransform object.

setTintOffset2(colorTrans:ColorTransform, rgb:Number) : Void

Tints a ColorTransform object with a color according to an rgb value.

getTintOffset2(colorTrans:ColorTransform) : Number

Returns the tint offset of a ColorTransform object.

invert(colorTrans:ColorTransform) : Void

Performs a straightforward color inversion.

setNegative(colorTrans:ColorTransform, percent:Number) : Void

Inverts a ColorTransform object by a certain percentage.

getNegative(colorTrans:ColorTransform) : Number

Returns the negative percentage of a ColorTransform object.

setRed(colorTrans:ColorTransform, amount:Number) : Void

Specifies a red color value for a ColorTransform object.

getRed(colorTrans:ColorTransform) : Number

Returns the red color value of a ColorTransform object.

setGreen(colorTrans:ColorTransform, amount:Number) : Void

Specifies a green color value for a ColorTransform object.

getGreen(colorTrans:ColorTransform) : Number

Returns the green color value of a ColorTransform object.

setBlue(colorTrans:ColorTransform, amount:Number) : Void

Specifies a blue color value for a ColorTransform object.

getBlue(colorTrans:ColorTransform) : Number

Returns the blue color value of a ColorTransform object.

setRedPercent(colorTrans:ColorTransform, percent:Number) : Void

Specifies a red percentage value for a ColorTransform object.

getRedPercent(colorTrans:ColorTransform) : Number

Returns the red percentage value of a ColorTransform object.

setGreenPercent(colorTrans:ColorTransform, percent:Number) : Void

Specifies a green percentage value for a ColorTransform object.

getGreenPercent(colorTrans:ColorTransform) : Number

Returns the green percentage value of a ColorTransform object.

setBluePercent(colorTrans:ColorTransform, percent:Number) : Void

Specifies a blue percentage value for a ColorTransform object.

getBluePercent(colorTrans:ColorTransform) : Number

Returns the blue percentage value of a ColorTransform object.

setRGBStr(colorTrans:ColorTransform, hexStr:String) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRGBStr(my_colorTrans, "#FFFF00");
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

hexStr:String - The string hexadecimal color to be set.

Returns

Nothing.

Description

Specifies an RGB color for a ColorTransform object using a string hexadecimal value.


getRGBStr(colorTrans:ColorTransform) : String

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
my_colorTrans.rgb = 0x0000FF;
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getRGBStr(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The string hexadecimal color.

Description

Returns the R+G+B combination currently in use by the ColorTransform object as a string hexadecimal value.


setRGB2(colorTrans:ColorTransform, r:Number, g:Number, b:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRGB2(my_colorTrans, 255, 0, 255);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

Returns

Nothing.

Description

Specifies an RGB color for a ColorTransform object using individual red, green, and blue values.


getRGB2(colorTrans:ColorTransform) : Object

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
var rgb:Object = ColorTransformUtil.getRGB2(my_colorTrans);
trace (rgb.r);
trace (rgb.g);
trace (rgb.b);

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The RBG value object with r, g, and b properties.

Description

Returns the R+G+B values currently in use by the ColorTransform object as individual red, green, and blue values.


reset(colorTrans:ColorTransform) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
my_colorTrans.rgb = 0x0000FF;
my_trans.colorTransform = my_colorTrans;
ColorTransformUtil.reset(my_colorTrans);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

Returns

Nothing.

Description

Resets a ColorTransform object to its default values.


setBrightness(colorTrans:ColorTransform, bright:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBrightness(my_colorTrans, -50);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

bright:Number - A percentage value between -100 and 100. Positive values brighten the color. and negative values darken it.

Returns

Nothing.

Description

Specifies the brightness of a ColorTransform object.


getBrightness(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBrightness(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getBrightness(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The brightness value.

Description

Returns the brightness of a ColorTransform object.


setBrightOffset(colorTrans:ColorTransform, offset:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBrightOffset(my_colorTrans, 140);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

offset:Number - A number between -255 and 255. Positive values push colors towards white; negative values towards black.

Returns

Nothing.

Description

Pushes a ColorTransform object towards black or white by an absolute amount.


getBrightOffset(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBrightOffset(my_colorTrans, 140);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getBrightOffset(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The brightness offset value.

Description

Returns the brightness offset value of a ColorTransform object.


setTint(colorTrans:ColorTransform, r:Number, g:Number, b:Number, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTint(my_colorTrans, 0, 0, 128, 50);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

percent:Number - The tint percentage.

Returns

Nothing.

Description

Tints a ColorTransform object with a color according to a certain percentage.


getTint(colorTrans:ColorTransform) : Object

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTint(my_colorTrans, 0, 0, 128, 50);
my_trans.colorTransform = my_colorTrans;
var tint:Object = ColorTransformUtil.getTint(my_colorTrans);
trace (tint.r);
trace (tint.g);
trace (tint.b);
trace (tint.percent);

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The tint value object with r, g, b, and percent properties.

Description

Returns the tint of a ColorTransform object.


setTint2(colorTrans:ColorTransform, rgb:Number, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTint2(my_colorTrans, 0x0000FF, 100);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

rgb:Number - The rgb value.

percent:Number - The tint percentage.

Returns

Nothing.

Description

Tints a ColorTransform object with a color according to a certain percentage.


getTint2(colorTrans:ColorTransform) : Object

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTint2(my_colorTrans, 0x0000FF, 100);
my_trans.colorTransform = my_colorTrans;
var tint:Object = ColorTransformUtil.getTint2(my_colorTrans);
trace (tint.rgb);
trace (tint.percent);

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The tint value object with rgb and percent properties.

Description

Returns the tint of a ColorTransform object.


setTintOffset(colorTrans:ColorTransform, r:Number, g:Number, b:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTintOffset(my_colorTrans, 0, 0, 128);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

r:Number - The red color value.

g:Number - The green color value.

b:Number - The blue color value.

Returns

Nothing.

Description

Tints a ColorTransform object with a color according to red, green, and blue values.


getTintOffset(colorTrans:ColorTransform) : Object

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTintOffset(my_colorTrans, 0, 0, 128);
my_trans.colorTransform = my_colorTrans;
var tint:Object = ColorTransformUtil.getTintOffset(my_colorTrans);
trace (tint.r);
trace (tint.g);
trace (tint.b);

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The tint offset value object with r, g, and b properties.

Description

Returns the tint offset of a ColorTransform object.


setTintOffset2(colorTrans:ColorTransform, rgb:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTintOffset2(my_colorTrans, 0x000080);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

rgb:Number - The rgb value.

Returns

Nothing.

Description

Tints a ColorTransform object with a color according to an rgb value.


getTintOffset2(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setTintOffset2(my_colorTrans, 0x000080);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getTintOffset2(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The tint offset value object with an rgb properties.

Description

Returns the tint offset of a ColorTransform object.


invert(colorTrans:ColorTransform) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.invert(my_colorTrans);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

Returns

Nothing.

Description

Performs a straightforward color inversion.


setNegative(colorTrans:ColorTransform, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setNegative(my_colorTrans, 60);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

percent:Number - The negative percentage.

Returns

Nothing.

Description

Inverts a ColorTransform object by a certain percentage.


getNegative(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setNegative(my_colorTrans, 60);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getNegative(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The negative percentage.

Description

Returns the negative percentage of a ColorTransform object.


setRed(colorTrans:ColorTransform, amount:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRed(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

amount:Number - The red color value.

Returns

Nothing.

Description

Specifies a red color value for a ColorTransform object.


getRed(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRed(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getRed(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The red color value.

Description

Returns the red color value of a ColorTransform object.


setGreen(colorTrans:ColorTransform, amount:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setGreen(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

amount:Number - The green color value.

Returns

Nothing.

Description

Specifies a green color value for a ColorTransform object.


getGreen(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setGreen(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getGreen(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The green color value.

Description

Returns the green color value of a ColorTransform object.


setBlue(colorTrans:ColorTransform, amount:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBlue(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

amount:Number - The blue color value.

Returns

Nothing.

Description

Specifies a blue color value for a ColorTransform object.


getBlue(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBlue(my_colorTrans, 128);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getBlue(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The blue color value.

Description

Returns the blue color value of a ColorTransform object.


setRedPercent(colorTrans:ColorTransform, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRedPercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

percent:Number - The red percentage value.

Returns

Nothing.

Description

Specifies a red percentage value for a ColorTransform object.


getRedPercent(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setRedPercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getRedPercent(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The red percentage value.

Description

Returns the red percentage value of a ColorTransform object.


setGreenPercent(colorTrans:ColorTransform, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setGreenPercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

percent:Number - The green percentage value.

Returns

Nothing.

Description

Specifies a green percentage value for a ColorTransform object.


getGreenPercent(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setGreenPercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getGreenPercent(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The green percentage value.

Description

Returns the green percentage value of a ColorTransform object.


setBluePercent(colorTrans:ColorTransform, percent:Number) : Void

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBluePercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;

Parameters

colorTrans:ColorTransform - The ColorTransform object to manipulate.

percent:Number - The blue percentage value.

Returns

Nothing.

Description

Specifies a blue percentage value for a ColorTransform object.


getBluePercent(colorTrans:ColorTransform) : Number

Usage


var my_colorTrans:ColorTransform = new ColorTransform();
var my_trans:Transform = new Transform(my_mc);
ColorTransformUtil.setBluePercent(my_colorTrans, 50);
my_trans.colorTransform = my_colorTrans;
trace (ColorTransformUtil.getBluePercent(my_colorTrans));

Parameters

colorTrans:ColorTransform - The ColorTransform object from which to retrieve the value.

Returns

The blue percentage value.

Description

Returns the blue percentage value of a ColorTransform object.