Class: RGBA

graphics.colors. RGBA


new RGBA( [r] [, g] [, b] [, a])

Encapsulates an rgba color.

The RGB class encapsulates an rgba 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.

a number <optional>
0

The alpha component, between 0 and 1.

Extends

Members


a :number

The alpha component, between 0 and 1.

Type:
  • number

b :number

The blue component, between 0 and 255.

Type:
  • number
Inherited From:

g :number

The green component, between 0 and 255.

Type:
  • number
Inherited From:

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
Inherited From:

r :number

The red component, between 0 and 255.

Type:
  • number
Inherited From:

Methods


<static> fromNumber(value)

Returns the RGBA 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 = RGBA.fromNumber( 0xFFEA6F51 ) ;
trace(rgb) ; // [RGB r:234 g:111 b:81 a:1 hex:0xFFEA6F51]

clone()

Creates and returns a shallow copy of the object.

Overrides:
Returns:

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


difference()

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

Overrides:

distance(rgb)

Calculates the distance between two rgb color values.

Parameters:
Name Type Description
rgb graphics.colors.RGB

The rgb target.

Inherited From:
Example
var rgb = RGB.fromNumber( 0xFFFFFF ) ;

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

rgb = 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.

Inherited From:
Overrides:
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.

Inherited From:
Overrides:

interpolate(to [, level])

Interpolates the color and returns a number rgba value.

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

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.

Overrides:
Returns:

The interpolate RGBA number value of the current color.


interpolate(to [, level])

Interpolate the color and returns a new RGBA object.

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

The RGBA reference used to interpolate the current RGBA object.

level number <optional>
1

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

Overrides:
Returns:

The interpolate RGBA reference of the current color.


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

Sets all tree components of a rgba 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.

a number <optional>
0

The alpha component, between 0 and 1.

Overrides:
Returns:

The current RGBA 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.

Overrides:
Returns:

the full String representation of the color.


toString()

Returns the String representation of the object.

Inherited From:
Overrides:
Returns:

the String representation of the object.