hsl2rgb
Syntax
- int hsl2rgb (int h, int s, int l, int z)
Arguments
- h
- Hue value
- s
- Saturation value
- l
- Lightness value
- z
- Determines which value is returned. z=0 for Red, z=1 for Green, z=2 for Blue
Return
- Returns the red, green or blue value from 0 to 255 depending on the value of z
Description
- Lets you convert HSL values to RGB values.
Example
%ffp
ctl(0):"Adjust H",Range=(-255,255),val=0
ctl(1):"Adjust S",Range=(-255,255),val=0
ctl(2):"Adjust L",Range=(-255,255),val=0
ForEveryTile:{
int r,g,b,h,s,l;
for (y= y_start; y < y_end; y++){
if(updateProgress(y,y_end)) abort();
for (x = x_start; x < x_end; x++){
r = src(x,y,0);
g = src(x,y,1);
b = src(x,y,2);
h = rgb2hsl (r,g,b,0);
s = rgb2hsl (r,g,b,1);
l = rgb2hsl (r,g,b,2);
//Do the HSL adjustment
h = h + ctl(0);
s = s + ctl(1);
l = l + ctl(2);
pset( x, y, 0, hsl2rgb (h,s,l,0) );
pset( x, y, 1, hsl2rgb (h,s,l,1) );
pset( x, y, 2, hsl2rgb (h,s,l,2) );
}}
return true;
}
Also see
- rgb2hsl
Comments
- Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.