The ColorUtil class includes a collection of utilities that allows for more intuitive color manipulation.
ActionScript 2.0; Flash Player 6
Method summary
Method | Description |
---|---|
setRGBStr(col:Color, hexStr:String) : Void |
Specifies an RGB color for a Color object using a string hexadecimal value. |
getRGBStr(col:Color) : String |
Returns the R+G+B combination currently in use by the Color object as a string hexadecimal value. |
setRGB2(col:Color, r:Number, g:Number, b:Number) : Void |
Specifies an RGB color for a Color object using individual red, green, and blue values. |
getRGB2(col:Color) : Object |
Returns the R+G+B values currently in use by the Color object as individual red, green, and blue values. |
reset(col:Color) : Void |
Sets the color transform for a Color object to its default values. |
setBrightness(col:Color, bright:Number) : Void |
Specifies the brightness of a Color object. |
getBrightness(col:Color) : Number |
Returns the brightness of a Color object. |
setBrightOffset(col:Color, offset:Number) : Void |
Pushes a Color object towards black or white by an absolute amount. |
getBrightOffset(col:Color) : Number |
Returns the brightness offset value of a Color object. |
setTint(col:Color, r:Number, g:Number, b:Number, percent:Number) : Void |
Tints a color object with a Color according to a certain percentage. |
getTint(col:Color) : Object |
Returns the tint of a Color object. |
setTint2(col:Color, rgb:Number, percent:Number) : Void |
Tints a color object with a Color according to a certain percentage. |
getTint2(col:Color) : Object |
Returns the tint of a Color object. |
setTintOffset(col:Color, r:Number, g:Number, b:Number) : Void |
Tints a Color object with a color according to red, green, and blue values. |
getTintOffset(col:Color) : Object |
Returns the tint offset of a Color object. |
setTintOffset2(col:Color, rgb:Number) : Void |
Tints a Color object with a color according to an rgb value. |
getTintOffset2(col:Color) : Number |
Returns the tint offset of a Color object. |
invert(col:Color) : Void |
Performs a straightforward color inversion. |
setNegative(col:Color, percent:Number) : Void |
Inverts a Color object by a certain percentage. |
getNegative(col:Color) : Number |
Returns the negative percentage of a Color object. |
setRed(col:Color, amount:Number) : Void |
Specifies a red color value for a Color object. |
getRed(col:Color) : Number |
Returns the red color value of a Color object. |
setGreen(col:Color, amount:Number) : Void |
Specifies a green color value for a Color object. |
getGreen(col:Color) : Number |
Returns the green color value of a Color object. |
setBlue(col:Color, amount:Number) : Void |
Specifies a blue color value for a Color object. |
getBlue(col:Color) : Number |
Returns the blue color value of a Color object. |
setRedPercent(col:Color, percent:Number) : Void |
Specifies a red percentage value for a Color object. |
getRedPercent(col:Color) : Number |
Returns the red percentage value of a Color object. |
setGreenPercent(col:Color, percent:Number) : Void |
Specifies a green percentage value for a Color object. |
getGreenPercent(col:Color) : Number |
Returns the green percentage value of a Color object. |
setBluePercent(col:Color, percent:Number) : Void |
Specifies a blue percentage value for a Color object. |
getBluePercent(col:Color) : Number |
Returns the blue percentage value of a Color object. |
setRedOffset(col:Color, offset:Number) : Void |
Specifies a red offset value for a Color object. |
getRedOffset(col:Color) : Number |
Returns the red offset value of a Color object. |
setGreenOffset(col:Color, offset:Number) : Void |
Specifies a green offset value for a Color object. |
getGreenOffset(col:Color) : Number |
Returns the green offset value of a Color object. |
setBlueOffset(col:Color, offset:Number) : Void |
Specifies a blue offset value for a Color object. |
getBlueOffset(col:Color) : Number |
Returns the blue offset value of a Color object. |
var my_color:Color = new Color(my_mc);
ColorUtil.setRGBStr(my_color, "#FFFF00");
col:Color
- The Color object to manipulate.
hexStr:String
- The string hexadecimal color to be set.
Nothing.
Specifies an RGB color for a Color object using a string hexadecimal value.
var my_color:Color = new Color(my_mc);
my_color.setRGB(0x0000FF);
trace (ColorUtil.getRGBStr(my_color));
col:Color
- The Color object from which to retrieve the value.
The string hexadecimal color.
Returns the R+G+B combination currently in use by the Color object as a string hexadecimal value.
var my_color:Color = new Color(my_mc);
ColorUtil.setRGB2(my_color, 255, 0, 255);
col:Color
- The Color object to manipulate.
r:Number
- The red color value.
g:Number
- The green color value.
b:Number
- The blue color value.
Nothing.
Specifies an RGB color for a Color object using individual red, green, and blue values.
var my_color:Color = new Color(my_mc);
ColorUtil.setRGB2(my_color, 255, 0, 255);
var rgb:Object = ColorUtil.getRGB2(my_color);
trace (rgb.r);
trace (rgb.g);
trace (rgb.b);
col:Color
- The Color object from which to retrieve the value.
The RBG value object with r, g, and b properties.
Returns the R+G+B values currently in use by the Color object as individual red, green, and blue values.
var my_color:Color = new Color(my_mc);
my_color.setRGB(0x0000FF);
ColorUtil.reset(my_color);
col:Color
- The Color object to manipulate.
Nothing.
Sets the color transform for a Color object to its default values.
var my_color:Color = new Color(my_mc);
ColorUtil.setBrightness(my_color, 50);
col:Color
- The Color object to manipulate.
bright:Number
- A percentage value between -100 and 100. Positive values brighten the color. and negative values darken it.
Nothing.
Specifies the brightness of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBrightness(my_color, 50);
trace (ColorUtil.getBrightness(my_color));
col:Color
- The Color object from which to retrieve the value.
The brightness value.
Returns the brightness of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBrightOffset(my_color, 140);
col:Color
- The Color object to manipulate.
offset:Number
- A number between -255 and 255. Positive values push colors towards white; negative values towards black.
Nothing.
Pushes a Color object towards black or white by an absolute amount.
var my_color:Color = new Color(my_mc);
ColorUtil.setBrightOffset(my_color, 140);
trace (ColorUtil.getBrightOffset(my_color));
col:Color
- The Color object from which to retrieve the value.
The brightness offset value.
Returns the brightness offset value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setTint(my_color, 0, 0, 128, 50);
col:Color
- The Color 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.
Nothing.
Tints a color object with a Color according to a certain percentage.
var my_color:Color = new Color(my_mc);
ColorUtil.setTint(my_color, 0, 0, 128, 50);
var tint:Object = ColorUtil.getTint(my_color);
trace (tint.r);
trace (tint.g);
trace (tint.b);
trace (tint.percent);
col:Color
- The Color object from which to retrieve the value.
The tint value object with r, g, b, and percent properties.
Returns the tint of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setTint2(my_color, 0x0000FF, 100);
col:Color
- The Color object to manipulate.
rgb:Number
- The rgb value.
percent:Number
- The tint percentage.
Nothing.
Tints a color object with a Color according to a certain percentage.
var my_color:Color = new Color(my_mc);
ColorUtil.setTint2(my_color, 0x0000FF, 100);
var tint:Object = ColorUtil.getTint2(my_color);
trace (tint.rgb);
trace (tint.percent);
col:Color
- The Color object from which to retrieve the value.
The tint value object with rgb and percent properties.
Returns the tint of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setTintOffset(my_color, 0, 0, 128);
col:Color
- The Color object to manipulate.
r:Number
- The red color value.
g:Number
- The green color value.
b:Number
- The blue color value.
Nothing.
Tints a Color object with a color according to red, green, and blue values.
var my_color:Color = new Color(my_mc);
ColorUtil.setTintOffset(my_color, 0, 0, 128);
var tint:Object = ColorUtil.getTintOffset(my_color);
trace (tint.r);
trace (tint.g);
trace (tint.b);
col:Color
- The Color object from which to retrieve the value.
The tint offset value object with r, g, and b properties.
Returns the tint offset of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setTintOffset2(my_color, 0x000080);
col:Color
- The Color object to manipulate.
rgb:Number
- The rgb value.
Nothing.
Tints a Color object with a color according to an rgb value.
var my_color:Color = new Color(my_mc);
ColorUtil.setTintOffset2(my_color, 0x000080);
trace (ColorUtil.getTintOffset2(my_color));
col:Color
- The Color object from which to retrieve the value.
The tint offset value object with an rgb properties.
Returns the tint offset of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.invert(my_color);
col:Color
- The Color object to manipulate.
Nothing.
Performs a straightforward color inversion.
var my_color:Color = new Color(my_mc);
ColorUtil.setNegative(my_color, 60);
col:Color
- The Color object to manipulate.
percent:Number
- The negative percentage.
Nothing.
Inverts a Color object by a certain percentage.
var my_color:Color = new Color(my_mc);
ColorUtil.setNegative(my_color, 60);
trace (ColorUtil.getNegative(my_color));
col:Color
- The Color object from which to retrieve the value.
The negative percentage.
Returns the negative percentage of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRed(my_color, 128);
col:Color
- The Color object to manipulate.
amount:Number
- The red color value.
Nothing.
Specifies a red color value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRed(my_color, 128);
trace (ColorUtil.getRed(my_color));
col:Color
- The Color object from which to retrieve the value.
The red color value.
Returns the red color value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreen(my_color, 128);
col:Color
- The Color object to manipulate.
amount:Number
- The green color value.
Nothing.
Specifies a green color value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreen(my_color, 128);
trace (ColorUtil.getGreen(my_color));
col:Color
- The Color object from which to retrieve the value.
The green color value.
Returns the green color value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBlue(my_color, 128);
col:Color
- The Color object to manipulate.
amount:Number
- The blue color value.
Nothing.
Specifies a blue color value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBlue(my_color, 128);
trace (ColorUtil.getBlue(my_color));
col:Color
- The Color object from which to retrieve the value.
The blue color value.
Returns the blue color value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRedPercent(my_color, 50);
col:Color
- The Color object to manipulate.
percent:Number
- The red percentage value.
Nothing.
Specifies a red percentage value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRedPercent(my_color, 50);
trace (ColorUtil.getRedPercent(my_color));
col:Color
- The Color object from which to retrieve the value.
The red percentage value.
Returns the red percentage value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreenPercent(my_color, 50);
col:Color
- The Color object to manipulate.
percent:Number
- The green percentage value.
Nothing.
Specifies a green percentage value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreenPercent(my_color, 50);
trace (ColorUtil.getGreenPercent(my_color));
col:Color
- The Color object from which to retrieve the value.
The green percentage value.
Returns the green percentage value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBluePercent(my_color, 50);
col:Color
- The Color object to manipulate.
percent:Number
- The blue percentage value.
Nothing.
Specifies a blue percentage value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBluePercent(my_color, 50);
trace (ColorUtil.getBluePercent(my_color));
col:Color
- The Color object from which to retrieve the value.
The blue percentage value.
Returns the blue percentage value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRedOffset(my_color, -128);
col:Color
- The Color object to manipulate.
percent:
- The red offset value.
Nothing.
Specifies a red offset value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setRedOffset(my_color, -128);
trace (ColorUtil.getRedOffset(my_color));
col:Color
- The Color object from which to retrieve the value.
The red offset value.
Returns the red offset value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreenOffset(my_color, -128);
col:Color
- The Color object to manipulate.
percent:
- The green offset value.
Nothing.
Specifies a green offset value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setGreenOffset(my_color, -128);
trace (ColorUtil.getGreenOffset(my_color));
col:Color
- The Color object from which to retrieve the value.
The green offset value.
Returns the green offset value of a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBlueOffset(my_color, -128);
col:Color
- The Color object to manipulate.
percent:
- The blue offset value.
Nothing.
Specifies a blue offset value for a Color object.
var my_color:Color = new Color(my_mc);
ColorUtil.setBlueOffset(my_color, -128);
trace (ColorUtil.getBlueOffset(my_color));
col:Color
- The Color object from which to retrieve the value.
The blue offset value.
Returns the blue offset value of a Color object.