| Package | graphics.colors |
| Class | public class RGB |
| Inheritance | RGB Object |
| Implements | ColorSpace |
| Subclasses | RGBA |
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
| Property | Defined 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 | ||
| Method | Defined 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 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 | ||
| Method | Defined By | ||
|---|---|---|---|
toHex(value:uint):String
Basic method use to convert the specified uint value in a hexadecimal String representation. | RGB | ||
| b | property |
b:uintThe blue component, between 0 and 255.
public function get b():uint public function set b(value:uint):void| g | property |
g:uintThe green component, between 0 and 255.
public function get g():uint public function set g(value:uint):void| luminance | property |
luminance:NumberIndicates the luminance of the color. The value is normed and lies in the range between 0 (black) and 255 (white).
public function get luminance():Number public function set luminance(value:Number):void| r | property |
r:uintThe red component, between 0 and 255.
public function get r():uint public function set r(value:uint):void| RGB | () | Constructor |
public function RGB(r:uint = 0, g:uint = 0, b:uint = 0)Creates a new RGB instance.
Parametersr: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).
|
| 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():voidTransforms the red, green and blue components of the color in this difference color representation.
| equals | () | method |
public function equals(o:*):BooleanCompares the specified object with this object for equality.
Parameters
o:* |
Boolean — true if the the specified object is equal with this object.
|
| fromNumber | () | method |
public function fromNumber(value:Number):voidSets the red, green and blue components with the specified number value.
Parameters
value:Number |
| fromNumber | () | method |
public static function fromNumber(value:Number):RGBReturns 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 |
RGB — the RGB representation of the color number passed in argument.
|
| interpolate | () | method |
public function interpolate(to:RGB, level:Number = 1):RGBInterpolate 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.
|
RGB — The interpolate RGB reference of the current color.
|
| interpolateToNumber | () | method |
public function interpolateToNumber(to:RGB, level:Number = 1):NumberInterpolate 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.
|
Number — The interpolate Number value of the current color.
|
| set | () | method |
public function set(... args):voidSets all tree components of a color.
Parameters
... args |
| toHex | () | method |
protected function toHex(value:uint):StringBasic method use to convert the specified uint value in a hexadecimal String representation.
Parameters
value:uint |
String — The String representation of the specified color.
|
| toHexString | () | method |
public function toHexString(prefix:String = 0x):StringReturns the full String representation of the color.
Parameters
prefix:String (default = 0x) |
String — the full String representation of the color.
|
| toNumber | () | method |
public static function toNumber(r:Number, g:Number, b:Number):NumberConverts 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)
|
Number — The base 10 representation of the specified red, green, blue components.
|
| toObject | () | method |
public function toObject():ObjectConverts an object to an equivalent Object value.
ReturnsObject — the Object representation of the instance.
|
| toSource | () | method |
public function toSource(indent:int = 0):StringReturns the source code string representation of the object.
Parameters
indent:int (default = 0) |
String — the source code string representation of the object.
|
| toString | () | method |
public function toString():StringReturns a String representation of the object.
ReturnsString — a String representation of the object.
|
| valueOf | () | method |
public function valueOf():uintReturns the real value of the object.
Returnsuint — the real value of the object.
|
| maximum | Constant |
hack const maximum:uint = 0xFFThe maximum value specified with a color component.