Packagegraphics.colors
Classpublic class RGB
InheritanceRGB Inheritance Object
Implements ColorSpace
Subclasses RGBA

The RGB class encapsulates an rgb color.
     import graphics.colors.RGB ;
     
     trace("---- black") ;
     
     var black:RGB = new RGB() ;
     
     trace( "black : " + black ) ; // [RGB r:0 g:0 b:0 hex:0x000000]
     trace( "black.toHexString('#') : " + black.toHexString("#") ) ; // #000000
     
     black.difference() ;
     trace( "black difference : " + black ) ; // [RGB r:255 g:255 b:255 hex:0xFFFFFF]
     
     trace("---- red") ;
     
     var red:RGB = new RGB(255, 0, 0) ;
     trace( "red : " + red ) ; // [RGB r:255 g:0 b:0 hex:0xFF0000]
     trace( "red.toHexString('#') : " + red.toHexString("#") ) ; // #FF0000
     
     red.difference() ; 
     trace( "red difference : " + red ) ; // [RGB r:0 g:255 b:255 hex:0x00FFFF]
     
     trace("---- blue") ;
     
     var blue:RGB = new RGB(92, 160, 205) ;
     trace( "blue : " + blue ) ; // [RGB r:92 g:160 b:205 hex:0x5CA0CD]
     trace( "blue.toHexString('#') : " + blue.toHexString("#") ) ; // #5CA0CD
     
     blue.difference() ;
     trace( "blue difference       : " + blue ) ; // [RGB r:163 g:95 b:50 hex:0xA35F32]
     
     blue.fromNumber( 0x23516D ) ;
     trace( "blue                  : " + blue ) ; // [RGB r:35 g:81 b:109 hex:0x23516D]
     trace( "blue.r                : " + blue.r ) ; // 35
     trace( "blue.g                : " + blue.g ) ; // 81
     trace( "blue.b                : " + blue.b ) ; // 109
     



Public Properties
 PropertyDefined By
  b : uint
The blue component, between 0 and 255.
RGB
  g : uint
The green component, between 0 and 255.
RGB
  luminance : Number
Indicates the luminance of the color.
RGB
  r : uint
The red component, between 0 and 255.
RGB
Public Methods
 MethodDefined By
  
RGB(r:uint = 0, g:uint = 0, b:uint = 0)
Creates a new RGB instance.
RGB
  
clone():*
Creates and returns a shallow copy of the object.
RGB
  
difference():void
Transforms the red, green and blue components of the color in this difference color representation.
RGB
  
equals(o:*):Boolean
Compares the specified object with this object for equality.
RGB
  
fromNumber(value:Number):void
Sets the red, green and blue components with the specified number value.
RGB
  
fromNumber(value:Number):RGB
[static] Returns the RGB representation of the color number passed in argument.
RGB
  
interpolate(to:RGB, level:Number = 1):RGB
Interpolate the color and returns a new RGB object.
RGB
  
interpolateToNumber(to:RGB, level:Number = 1):Number
Interpolate the color and returns the number rgb value.
RGB
  
set(... args):void
Sets all tree components of a color.
RGB
  
toHexString(prefix:String = 0x):String
Returns the full String representation of the color.
RGB
  
toNumber(r:Number, g:Number, b:Number):Number
[static] Converts the basic red, green, blue passed-in arguments in a HTML number color (base 10).
RGB
  
toObject():Object
Converts an object to an equivalent Object value.
RGB
  
toSource(indent:int = 0):String
Returns the source code string representation of the object.
RGB
  
toString():String
Returns a String representation of the object.
RGB
  
valueOf():uint
Returns the real value of the object.
RGB
Protected Methods
 MethodDefined By
  
toHex(value:uint):String
Basic method use to convert the specified uint value in a hexadecimal String representation.
RGB
Property Detail
bproperty
b:uint

The blue component, between 0 and 255.


Implementation
    public function get b():uint
    public function set b(value:uint):void
gproperty 
g:uint

The green component, between 0 and 255.


Implementation
    public function get g():uint
    public function set g(value:uint):void
luminanceproperty 
luminance:Number

Indicates the luminance of the color. The value is normed and lies in the range between 0 (black) and 255 (white).


Implementation
    public function get luminance():Number
    public function set luminance(value:Number):void
rproperty 
r:uint

The red component, between 0 and 255.


Implementation
    public function get r():uint
    public function set r(value:uint):void
Constructor Detail
RGB()Constructor
public function RGB(r:uint = 0, g:uint = 0, b:uint = 0)

Creates a new RGB instance.

Parameters
r:uint (default = 0) — The red component, between 0 and 255 (default 0).
 
g:uint (default = 0) — The green component, between 0 and 255 (default 0).
 
b:uint (default = 0) — The blue component, between 0 and 255 (default 0).
Method Detail
clone()method
public function clone():*

Creates and returns a shallow copy of the object.

Returns
* — A new object that is a shallow copy of this instance.
difference()method 
public function difference():void

Transforms the red, green and blue components of the color in this difference color representation.

equals()method 
public function equals(o:*):Boolean

Compares the specified object with this object for equality.

Parameters

o:*

Returns
Booleantrue if the the specified object is equal with this object.
fromNumber()method 
public function fromNumber(value:Number):void

Sets the red, green and blue components with the specified number value.

Parameters

value:Number

fromNumber()method 
public static function fromNumber(value:Number):RGB

Returns the RGB representation of the color number passed in argument.

Example :

         import graphics.colors.RGB ;
         
         var rgb:RGB = RGB.fromNumber( 0xEA6F51 ) ; 
         trace(rgb) ; // [RGB r:234 g:111 b:81 hex:0xEA6F51]
         

Parameters

value:Number

Returns
RGB — the RGB representation of the color number passed in argument.
interpolate()method 
public function interpolate(to:RGB, level:Number = 1):RGB

Interpolate the color and returns a new RGB object.

Parameters

to:RGB — The RGB reference used to interpolate the current RGB object.
 
level:Number (default = 1) — The level of the interpolation as a decimal, where 0 is the start and 1 is the end.

Returns
RGB — The interpolate RGB reference of the current color.
interpolateToNumber()method 
public function interpolateToNumber(to:RGB, level:Number = 1):Number

Interpolate the color and returns the number rgb value.

Parameters

to:RGB — The RGB reference used to interpolate the current RGB object.
 
level:Number (default = 1) — The level of the interpolation as a decimal, where 0 is the start and 1 is the end.

Returns
Number — The interpolate Number value of the current color.
set()method 
public function set(... args):void

Sets all tree components of a color.

Parameters

... args

toHex()method 
protected function toHex(value:uint):String

Basic method use to convert the specified uint value in a hexadecimal String representation.

Parameters

value:uint

Returns
String — The String representation of the specified color.
toHexString()method 
public function toHexString(prefix:String = 0x):String

Returns the full String representation of the color.

Parameters

prefix:String (default = 0x)

Returns
String — the full String representation of the color.
toNumber()method 
public static function toNumber(r:Number, g:Number, b:Number):Number

Converts the basic red, green, blue passed-in arguments in a HTML number color (base 10).

Example :

         import graphics.colors.RGB ;
         
         var rgb:Number = RGB.toNumber(234,111,81) ; 
         trace( rgb ) ; // 0xEA6F51
         

Parameters

r:Number — The red component (between 0 and 0xFF)
 
g:Number — The green component (between 0 and 0xFF)
 
b:Number — The blue component (between 0 and 0xFF)

Returns
Number — The base 10 representation of the specified red, green, blue components.
toObject()method 
public function toObject():Object

Converts an object to an equivalent Object value.

Returns
Object — the Object representation of the instance.
toSource()method 
public function toSource(indent:int = 0):String

Returns the source code string representation of the object.

Parameters

indent:int (default = 0)

Returns
String — the source code string representation of the object.
toString()method 
public function toString():String

Returns a String representation of the object.

Returns
String — a String representation of the object.
valueOf()method 
public function valueOf():uint

Returns the real value of the object.

Returns
uint — the real value of the object.
Constant Detail
maximumConstant
hack const maximum:uint = 0xFF

The maximum value specified with a color component.