Winamp Forums > AVS HSV to RGB

 16th November 2002, 13:14 #1 KeatonMill Junior Member   Join Date: Jul 2002 Posts: 32 HSV to RGB Hey guys, I'm working on some presets which I would like to use the HSV colorspace instead of RGB. However, AVS doesn't support HSV in the superscope code. I have searched on Google for an AVS-friendly algorithm, but I haven't been able to find one. Does anyone know of a (relatively) easy way to convert between colorspaces? Thanks
 16th November 2002, 14:57 #2 Montana Major Dude     Join Date: Dec 2001 Location: SÃ¶dertÃ¤lje, Sweden Posts: 1,058 i use this, it's a method that unconed posted here in the forums: hue=var; // (0..2PI) sat=var; // (0..1) lum=var; // use any value to light/darken the color, recomended value (-1..1) red=(sin(hue)+1)*sat*0.5+lum; green=(sin(hue+2.09)+1)*sat*0.5+lum; blue=(sin(hue+4.18)+1)*sat*0.5+lum; batman
 17th November 2002, 05:21 #3 dirkdeftly Forum King     Join Date: Jun 2001 Location: Cydonia, Mars Posts: 2,651 Assuming red, green, blue, hue, luminosity, and saturation are all values from 0 to 1: red=|sin hue*pi*2)|*saturation/2+luminosity; green=|sin hue*pi*2+pi/3)|*saturation/2+luminosity; blue=|sin hue*pi*2+pi/3*2)|*saturation/2+luminosity; Fast version for AVS: init: tpi=acos(-1)*2; pit=tpi/6; tpit=pit*2; pixel: sat2=sat/2; red=abs(sin(hue*tpi))*sat2+lum; green=abs(sin(hue*tpi+pit))*sat2+lum; blue=abs(sin(hue*tpi+tpit))*sat2+lum; "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings
 17th November 2002, 16:10 #4 jheriko Forum King     Join Date: Aug 2002 Location: a twist in the fabric of space Posts: 2,149 For a slightly faster version use sat2=sat*0.5; -- Jheriko 'Everything around us can be represented and understood through numbers'
 17th November 2002, 20:51 #5 dirkdeftly Forum King     Join Date: Jun 2001 Location: Cydonia, Mars Posts: 2,651 Oh, and hue2=hue*tpi; "guilt is the cause of more disauders than history's most obscene marorders" --E. E. Cummings
 18th November 2002, 09:12 #6 Zevensoft Major Dude     Join Date: Apr 2002 Location: Ballarat, Australia Posts: 529 Here's what I use (I don't think it's accurate, but it does the job). Init```code: pi=acos(-1);tt=2/3; ``` Point```code: red=((.5+sin((h+tt)*pi)*.5)*s+(.5+sin(h*pi)*.5)*(1-s)+(.5+sin((h-tt)*pi)*.5)*(1-s))*br; green=((.5+sin(h*pi)*.5)*s+(.5+sin((h+tt)*pi)*.5)*(1-s)+(.5+sin((h-tt)*pi)*.5)*(1-s))*br; blue=((.5+sin((h-tt)*pi)*.5)*s+(.5+sin(h*pi)*.5)*(1-s)+(.5+sin((h+tt)*pi)*.5)*(1-s))*br; ``` h = hue, s = saturation, br = brightness. Note: This can be optimized further by creating varibles for things like (h-tt)*pi. Also can be optimized if hue or saturation is fixed. 1 | 2 | 3 | 4 | 3W | 4WW
 Winamp Forums > AVS HSV to RGB