Convert HSV color tu RBG
#1

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

PHP код:
stock Float:flomod(Float:aFloat:b)
{
    while(
b)
        
-= b;
    return 
a;
}
stock HSBtoRBG(H,Float:S,Float:V)
{
    new 
R,G,B;
    new 
Float:r,Float:g,Float:b;
    new 
Float:floatmul(V,S);
    new 
Float:fH 60;
    new 
Float:floatmul(C,(floatabs(flomod(fH,2.0) - 1)));
    
    if(
fH 1C,X,0.0;
    else if(
fH 2X,C,0.0;
    else if(
fH 30,C,X;
    else if(
fH 40,X,C;
    else if(
fH 5X,0.0,C;
    else if(
fH 6X,0.0,C;
    else 
0.0,0.0,0.0;
    new 
Float:;
    
r+m;
    
g+m;
    
b+m;
    
printf("%f,%f,%f",r,g,b);

why dont' return RBG values
Reply
#2

Not sure if relevant: http://www.cs.rit.edu/~ncs/color/t_convert.html
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)