> ok, here's my util function:
>
> void UTIL_RGBtoHSV(float r,float g,float b,float &h,float &s,float &v)
> {
>  float flmin, flmax, fldelta;
>  flmin = min( r, min (g, b ));
>  flmax = max( r, max (g, b ));
>
>  v = flmax;      // v
>  fldelta = flmax - flmin;
>  if( flmax != 0 )
>   s = fldelta / flmax;  // s
>  else       // r = g = b = 0
>  {
>   s = 0;      // s = 0, v is undefined
>   v = 0;
>   h = -1;
>   return;
>  }
>
>  if( r == flmax )
>   h = ( g - b ) / fldelta; // between yellow & magenta
>  else if( g == flmax )
>   h = 2 + ( b - r ) / fldelta;// between cyan & yellow
>  else
>   h = 4 + ( r - g ) / fldelta;// between magenta & cyan
>  h *= 60;      // degrees
>  if( h < 0 )
>   h += 360;
> }

I assume you got the code from here...

http://www.cs.rit.edu/~ncs/color/t_convert.html

...or somewhere similar.

Are you passing in RGB values from 0 to 1?  (i.e....

float r, g, b;
float h, s, v;

r = color.red / 255.0f;  // make float 0.0 - 1.0
g = color.green / 255.0f;
b = color.blue / 255.0f;

UTIL_RGBtoHSV(r, g, b, h, s, v);

...)???

Jeffrey "botman" Broome
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to