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;
}


> > Sure, hue is the first value of HSV, and I'am only using this one when
> > setting the top and bottom color, but the color isn't right either.
>
> Perhaps you aren't doing something right.  Show some code.
>
> Jeffrey "botman" Broome
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>

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

Reply via email to