View Single Post
Old 12th May 2003, 04:34   #87
sidd
Major Dude
 
sidd's Avatar
 
Join Date: May 2003
Location: Australia
Posts: 1,353
I came up with this a while back and have been usingit heaps, thought it might be useful to everyone out there.

This converts hue,sat,lum color mode to r,g,b. So you can have more control over your color coding in superscopes. all hue sat and lum values are between 0 and 1. Hue, follows red-> green-> blue in 1/3 sections.

For all those who dont know, hue is the color, sat is the intensity of that color, and lum is the amount of black(0) or white(1) in that colour.

As you can imagin, the code is VERY useful, but unfortunatly isnt as small as one would like, it takes up 11 variables!!, i might be able to make that 8 but its tricky.

code:
hue=1;
lum=0.5;
sat=t;
tm2=if(below(lum,0.5),lum*(1+sat),lum+sat-lum*sat);
tm1=2*lum-tm2;
tm3r=hue+1/3;
tm3g=hue;
tm3b=hue-1/3;
tm3r=if(above(tm3r,1),tm3r-1,if(below(tm3r,0),tm3r+1,tm3r));
tm3g=if(above(tm3g,1),tm3g-1,if(below(tm3g,0),tm3g+1,tm3g));
tm3b=if(above(tm3b,1),tm3b-1,if(below(tm3b,0),tm3b+1,tm3b));
rd=if(below(6*tm3r,1),tm1+(tm2-tm1)*6*tm3r,if(below(2*tm3r,1),
tm2,if(below(tm3r*3,2),tm1+(tm2-tm1)*((2/3)-tm3r)*6,tm1)));
gr=if(below(6*tm3g,1),tm1+(tm2-tm1)*6*tm3g,if(below(2*tm3g,1),
tm2,if(below(tm3g*3,2),tm1+(tm2-tm1)*((2/3)-tm3g)*6,tm1)));
bl=if(below(6*tm3b,1),tm1+(tm2-tm1)*6*tm3b,if(below(2*tm3b,1),
tm2,if(below(tm3b*3,2),tm1+(tm2-tm1)*((2/3)-tm3b)*6,tm1)));
green=if(sat,gr,lum);
blue=if(sat,bl,lum);
red=if(sat,rd,lum);

sidd is offline   Reply With Quote