HSL2RGB

Category: Arithmetics
Since engine version: 4.9.1.0 GWE

Description

Converts a 24 bit HSL value into the better known 32 bit RGB format.
The 24 bit HSL value can be created using RGB(hue, saturation, lightness).

Syntax

int HSL2RGB (int Val);

Parameter

Val:
24 bit HSL value

Remark

Since there is no floating point data type in Clonk, these values may contain slight rounding errors (usually not greater than +1 to +1).

Example

#strict
#appendto CLNK

func Initialize() {
  AddEffect("VariateHue",this(),200,1,this());
  return(_inherited());
}

func FxVariateHueTimer() {
  var rgb, hsl=RGB2HSL(GetColorDw());
  var hue, sat, light;
  SplitRGBaValue(hsl, hue, sat, light);
  hue+=2;
  if(hue>255) hue=0;
  rgb=HSL2RGB(RGB(hue,sat,light));
  SetColorDw(rgb);
}
Creates an effect which will colorize every clonk in the game, running through the colors of the rainbow.
See also: RGB, RGB2HSL, SetRGBaValue
Tyron, September 2004