# RGB2HSL

Arithmetics
5.1 OC
int
int Val 32 bit color value
Converts a 32 bit color value into hue, saturation, and lightness values as know in paint programs.
The HSL value is returned as int and can be processed using GetRGBaValue or SplitRGBaValue.
All values range from 0-255.
Since there is no floating point data type in Clonk, these values may contain slight rounding errors (usually not greater than +1 to +1).
#appendto Clonk

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

func FxVariateHueTimer() { var hsl = RGB2HSL(GetColor()); var hsla_array = SplitRGBaValue(hsl); hsla_array[0] += 2; if(hsla_array[0] > 255) hue = 0; var rgb = HSL2RGB(RGB(hsla_array[0],hsla_array[1],hsla_array[2])); SetColor(rgb); }
Creates an effect which will colorize every clonk in the game, running through the colors of the rainbow.
To test this effects, best copy this function into a script contained in a scenario local System.ocg group.
The hue value is deliberately increased by 2 in this sample, else rounding errors might cause nothing to happen.
HSL2RGB
SetRGBaValue
RGB
Tyron
2004-09