Instant constructors: color_hsl()
The instant constructor color_hsl() creates a color operand dynamically from HSL (Hue, Saturation, Luminance) values. Color operands store a color value composed of the red, green, blue and alpha components.
Declaration
color color_hsl( int32 aHue, int32 aSaturation, int32 aLuminance )
color color_hsl( int32 aHue, int32 aSaturation, int32 aLuminance, uint8 aAlpha )
Parameters
aHue
The hue component of the color expressed as an angle in range 0 .. 360 degrees, where 0° represents red, 120° represents green, 240° represents blue, and values in between represent intermediate hues on the color wheel.
aSaturation
The saturation component of the color expressed as a percentage value in range 0 .. 100, where 0 represents a completely desaturated color (gray) and 100 represents a fully saturated color.
aLuminance
The luminance component of the color expressed as a percentage value in range 0 .. 100, where 0 represents black, 100 represents white, and 50 represents the pure hue color.
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_hsl() constructor returns a fully opaque color value with the hue, saturation and luminance components specified in the corresponding parameters aHue, aSaturation and aLuminance. The constructor automatically converts the HSL values to the corresponding RGB components. For example:
var int32 h = 120; var int32 s = 100; var int32 l = 50; var color c = color_hsl( h, s, l ); // c = #00FF00FF (green, fully opaque)
The second version of the color_hsl() constructor returns a color value with the hue, saturation and luminance components and an additional alpha (opacity) value specified in the parameters aHue, aSaturation, aLuminance and aAlpha. Depending on the aAlpha parameter, the resulting color can be fully opaque, semitransparent or fully transparent. For example:
var int32 h = 240; var int32 s = 100; var int32 l = 50; var uint8 a = 127; var color c = color_hsl( h, s, l, a ); // c = #0000FF7F (blue, half transparent)
