Class: RGB

graphics.colors. RGB


new RGB( [r] [, g] [, b])

Encapsulates an rgb color.

The RGB class encapsulates an rgb color.

Parameters:
Name Type Argument Default Description
r number <optional>
0

The red component, between 0 and 255.

g number <optional>
0

The green component, between 0 and 255.

b number <optional>
0

The blue component, between 0 and 255.

Members


<static, constant> maximum :number

The maximum value specified with a color component.

Type:
  • number
Default Value:
  • 0xFF

b :number

The blue component, between 0 and 255.

Type:
  • number

g :number

The green component, between 0 and 255.

Type:
  • number

luminance :number

Indicates the luminance of the color.

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

Type:
  • number

r :number

The red component, between 0 and 255.

Type:
  • number

Methods


<static> fromNumber(value)

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

Parameters:
Name Type Description
value number

The numeric value to create a new RGB instance.

Returns:

the RGB representation of the color number passed in argument.

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

clone()

Creates and returns a shallow copy of the object.

Returns:

A new object that is a shallow copy of this instance.


difference()

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


distance(rgb)

Calculates the distance between two rgb color values.

Parameters:
Name Type Description
rgb graphics.colors.RGB

The rgb target.

Example
var rgb = RGB.fromNumber( 0xFFFFFF ) ;trace( rgb.distance( RGB.fromNumber( 0x000000 ) ) ) ; // 195075trace( rgb.distance( RGB.fromNumber( 0xFFEEFF ) ) ) ; // 289trace( rgb.distance( RGB.fromNumber( 0xFFFFFF ) ) ) ; // 0rgb = RGB.fromNumber( 0xFF0000 ) ;trace( rgb.distance( RGB.fromNumber( 0xFF0000 ) ) ) ; // 0

equals(o)

Compares the specified object with this object for equality.

Parameters:
Name Type Description
o object

The object to evaluates.

Returns:

true if the the specified object is equal with this object.


equals(o)

Compares the specified object with this object for equality.

Parameters:
Name Type Description
o object

The object to evaluates.

Returns:

true if the the specified object is equal with this object.


fromNumber(value, The)

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

Parameters:
Name Type Description
value number

The hexadecimal value of the color.

The

current RGB reference.


fromNumber(value, The)

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

Parameters:
Name Type Description
value number

The hexadecimal value of the color.

The

current RGB reference.


interpolate(to [, level])

Interpolates the color and returns a number rgb value.

Parameters:
Name Type Argument Default Description
to graphics.colors.RGB

The RGB reference used to interpolate the current RGB object.

level number <optional>
1

The level of the interpolation as a decimal, where 0 is the start and 1 is the end.

Returns:

The interpolate RGB number value of the current color.


interpolate(to [, level])

Interpolate the color and returns a new RGB object.

Parameters:
Name Type Argument Default Description
to graphics.colors.RGB

The RGB reference used to interpolate the current RGB object.

level number <optional>
1

The level of the interpolation as a decimal, where 0 is the start and 1 is the end.

Returns:

The interpolate RGB reference of the current color.


setTo( [r] [, g] [, b])

Sets all tree components of a rgb color.

Parameters:
Name Type Argument Default Description
r number <optional>
0

The red component, between 0 and 255.

g number <optional>
0

The green component, between 0 and 255.

b number <optional>
0

The blue component, between 0 and 255.

Returns:

The current RGB reference.


toHexString( [prefix] [, upper])

Returns the full String representation of the color.

Parameters:
Name Type Argument Default Description
prefix string <optional>
#

The string prefix of the final expression (default #).

upper boolean <optional>
true

Indicates if the string result is uppercase.

Returns:

the full String representation of the color.


toString()

Returns the String representation of the object.

Returns:

the String representation of the object.


toString()

Returns the String representation of the object.

Returns:

the String representation of the object.