Color

Return to Introduction  Previous page  Next page

A basic class used to represent a color that can be created with the 'new' keyword.

 

Properties

 

r

Floating point value between 0 and 1 representing the red component.

g

Floating point value between 0 and 1 representing the green component.

b

Floating point value between 0 and 1 representing the blue component.

a

Floating point value between 0 and 1 representing the alpha component (may be ignored for some uses).

 

Examples

 

You can declare a Color either by it's # code...

 

new Color("#rrggbb")

 

var col = new Color("#ff0000"); // col is a Color type, set to bright red.

 

...or by it's floating point components...

 

new Color(r,g,b)

 

var col = new Color(1.0,0.0,0.0); // again col is a Color type, set to bright red.

 

You can also initialize an alpha value with....

 

new Color(r,g,b,a)

 

var transcol = new Color(1.0,0.0,0.0,0.5);  // transcol is bright red, but 50% transparent.

 

 



Copyright ©2004 Worldweaver Ltd. DX Studio Home