Packagede.popforge.imageprocessing.geom
Classpublic final class Color

The Color class is a util that simplifies color math. A color in the RGB space is a vector of three dimensions. This class stores the color internal as such a vector.



Public Properties
 PropertyDefined by
  b : Number
The blue value of the color from 0 to 255.
Color
  g : Number
The green value of the color from 0 to 255.
Color
  r : Number
The red value of the color from 0 to 255.
Color
Public Methods
 MethodDefined by
  
Color(red:Number, green:Number, blue:Number)
Creates a Color object with the specific RGB values.
Color
  
add(color:Color):void
Adds a color vector to the current color vector.
Color
  
addBrightness(value:Number):void
Adds a value to the color vector.
Color
  
clamp():void
Clamps the color vector between 0 and 255.
Color
  
fromCMY(c:Number, m:Number, y:Number):Color
[static] Creates and returns a new Color object from given CMY values.
Color
  
fromHSL(h:Number, s:Number, l:Number):Color
[static] Creates and returns a new Color object from given HSL values.
Color
  
fromHSV(h:Number, s:Number, v:Number):Color
[static] Creates and returns a new Color object from given HSV values.
Color
  
fromInt(rgb:int):Color
[static] Creates and returns a new Color object from given integer.
Color
  
fromRGB(r:int = 0, g:int = 0, b:int = 0):Color
[static] Creates and returns a new Color object from given RGB values.
Color
  
getBrightness():Number
Calculates the length of the color vector.
Color
  
Calculates the luminance of a color.
Color
  
getMultiplied(value:Number):Color
Color
  
Calculates the saturation of a color.
Color
  
invert():void
Inverts the color vector.
Color
  
multiply(value:Number):void
Multiplies the color vector.
Color
  
normalize():void
Normalizes the color vector.
Color
  
substract(color:Color):void
Substracts a color vector from the current color vector.
Color
  
toInt():int
Creates the integer representation of the color.
Color
  
toString():String
Builds and returns a string that lists the values of the Color object.
Color
Property detail
bproperty
public var b:Number

The blue value of the color from 0 to 255.

gproperty 
public var g:Number

The green value of the color from 0 to 255.

rproperty 
public var r:Number

The red value of the color from 0 to 255.

Constructor detail
Color()constructor
public function Color(red:Number, green:Number, blue:Number)

Creates a Color object with the specific RGB values. The vector will be clamped automatically.

Parameters
red:Number — Red value from 0 to 255.
 
green:Number — Green value from 0 to 255.
 
blue:Number — Blue value from 0 to 255.
Method detail
add()method
public function add(color:Color):void

Adds a color vector to the current color vector. The vector will be clamped automatically.

Parameters
color:Color — The color you want to add.
addBrightness()method 
public function addBrightness(value:Number):void

Adds a value to the color vector. The vector will be clamped automatically.

Parameters
value:Number — The value you want to add.
clamp()method 
public function clamp():void

Clamps the color vector between 0 and 255.

fromCMY()method 
public static function fromCMY(c:Number, m:Number, y:Number):Color

Creates and returns a new Color object from given CMY values.

Parameters
c:Number — Cyan value from 0 to 1.
 
m:Number — Magenta value from 0 to 1.
 
y:Number — Yellow value form 0 to 1.

Returns
Color — A Color object based on the given values.
fromHSL()method 
public static function fromHSL(h:Number, s:Number, l:Number):Color

Creates and returns a new Color object from given HSL values. This function is based on the link below.

Parameters
h:Number — Hue value from 0 to 1.
 
s:Number — Saturation value from 0 to 1.
 
l:Number — Lightness value form 0 to 1.

Returns
Color — A Color object based on the given values.

See also

fromHSV()method 
public static function fromHSV(h:Number, s:Number, v:Number):Color

Creates and returns a new Color object from given HSV values. This function is based on the link below.

Parameters
h:Number — Hue value from 0 to 1.
 
s:Number — Saturation value from 0 to 1.
 
v:Number — Value value form 0 to 1.

Returns
Color — A Color object based on the given values.

See also

fromInt()method 
public static function fromInt(rgb:int):Color

Creates and returns a new Color object from given integer.

Parameters
rgb:int — 24-BIT integer in 0xRRGGBB order.

Returns
Color — A Color object based on the given values.
fromRGB()method 
public static function fromRGB(r:int = 0, g:int = 0, b:int = 0):Color

Creates and returns a new Color object from given RGB values.

Parameters
r:int (default = 0) — Red value from 0 to 255.
 
g:int (default = 0) — Green value from 0 to 255.
 
b:int (default = 0) — Blue value form 0 to 255.

Returns
Color — A Color object based on the given values.
getBrightness()method 
public function getBrightness():Number

Calculates the length of the color vector.

Returns
Number — The length of the color vector.
getLuminance()method 
public function getLuminance():int

Calculates the luminance of a color.

Returns
int — The luminance value from 0 to 255.
getMultiplied()method 
public function getMultiplied(value:Number):ColorParameters
value:Number

Returns
Color
getSaturation()method 
public function getSaturation():int

Calculates the saturation of a color.

Returns
int — The saturation value from 0 to 255.
invert()method 
public function invert():void

Inverts the color vector. The vector will be clamped automatically.

multiply()method 
public function multiply(value:Number):void

Multiplies the color vector. The vector will be clamped automatically.

Parameters
value:Number — Any value you want to multiply the color with.
normalize()method 
public function normalize():void

Normalizes the color vector. The vector will be clamped automatically.

substract()method 
public function substract(color:Color):void

Substracts a color vector from the current color vector. The vector will be clamped automatically.

Parameters
color:Color — The color you want to substract.
toInt()method 
public function toInt():int

Creates the integer representation of the color.

Returns
int — A 24-BIT integer in 0xRRGGBB order.
toString()method 
public function toString():String

Builds and returns a string that lists the values of the Color object.

Returns
String — A string listing the value of each of the following properties of the Color object: r, g, b