Instant constructors: color()
The instant constructor color() creates a color operand dynamically. Color operands store a color value composed of the red, green, blue and alpha components.
Declaration
color color( uint8 aRed, uint8 aGreen, uint8 aBlue )
color color( uint8 aRed, uint8 aGreen, uint8 aBlue, uint8 aAlpha )
color color()
Parameters
aRed
The red component of the color expressed in range 0 .. 255 with the value 255 representing its maximal intensity.
aGreen
The green component of the color expressed in range 0 .. 255 with the value 255 representing its maximal intensity.
aBlue
The blue component of the color expressed in range 0 .. 255 with the value 255 representing its maximal intensity.
aAlpha
The alpha component of the color expressed in range 0 .. 255 with the value 255 representing a fully opaque color. The value 0 represents a fully transparent color. All values lying in between represent a semitransparent color.
Discussion
The first version of the color() constructor returns a fully opaque color value with the red, green and blue color components specified in the corresponding parameters aRed, aGreen and aBlue. For example:
var uint8 r = 255; var uint8 g = 255; var uint8 b = 0; var color c = color( r, g, b ); // c = #FFFF00FF (yellow, fully opaque)
The second version of the color() constructor returns a color value with the red, green and blue color components and an additional alpha (opacity) value specified in the parameters aRed, aGreen, aBlue and aAlpha. Depending on the aAlpha parameter, the resulting color can be fully opaque, semitransparent or fully transparent. For example:
var uint8 r = 255; var uint8 g = 255; var uint8 b = 0; var uint8 a = 127; var color c = color( r, g, b, a ); // c = #FFFF007F (yellow, half transparent)
The third version of the color() constructor doesn't accept any arguments. It simply returns a fully transparent color value with its red, green, blue and alpha color components set to 0 (zero). The function of this constructor corresponds thus to the color literal #00000000.
var color c = color(); // c = #00000000 (fully transparent)