18.07.2012, 21:50
i try to do this by follow this http://en.wikipedia.org/wiki/HSL_color_space#From_HSV
but for exemple if i insert H = 100, S 0.9, V = 0.5;
it's return 0.500000,0.500000,0.050000
or if I insert H = 10, S 0.4, V = 0.1;
it's return 0.100000,0.059999,0.059999
why dont' return RBG values
but for exemple if i insert H = 100, S 0.9, V = 0.5;
it's return 0.500000,0.500000,0.050000
or if I insert H = 10, S 0.4, V = 0.1;
it's return 0.100000,0.059999,0.059999
PHP код:
stock Float:flomod(Float:a, Float:b)
{
while(a > b)
a -= b;
return a;
}
stock HSBtoRBG(H,Float:S,Float:V)
{
new R,G,B;
new Float:r,Float:g,Float:b;
new Float:C = floatmul(V,S);
new Float:fH = H / 60;
new Float:X = floatmul(C,(1 - floatabs(flomod(fH,2.0) - 1)));
if(fH < 1) r = C,g = X,b = 0.0;
else if(fH < 2) r = X,g = C,b = 0.0;
else if(fH < 3) r = 0,g = C,b = X;
else if(fH < 4) r = 0,g = X,b = C;
else if(fH < 5) r = X,g = 0.0,b = C;
else if(fH < 6) r = X,g = 0.0,b = C;
else r = 0.0,g = 0.0,b = 0.0;
new Float:m = V - C ;
r = r+m;
g = g+m;
b = b+m;
printf("%f,%f,%f",r,g,b);
}