Go Back   Winamp Forums > Visualizations > AVS

Reply
Thread Tools Search this Thread Display Modes
Old 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
KeatonMill is offline   Reply With Quote
Old 16th November 2002, 14:57   #2
Montana
Major Dude
 
Montana's Avatar
 
Join Date: Dec 2001
Location: Södertälje, Sweden
Posts: 1,058
Send a message via ICQ to Montana Send a message via AIM to Montana Send a message via Yahoo to Montana
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
Montana is offline   Reply With Quote
Old 17th November 2002, 05:21   #3
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
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
dirkdeftly is offline   Reply With Quote
Old 17th November 2002, 16:10   #4
jheriko
Forum King
 
jheriko's Avatar
 
Join Date: Aug 2002
Location: a twist in the fabric of space
Posts: 2,149
Send a message via ICQ to jheriko
For a slightly faster version use sat2=sat*0.5;

-- Jheriko

'Everything around us can be represented and understood through numbers'
jheriko is offline   Reply With Quote
Old 17th November 2002, 20:51   #5
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
Oh, and hue2=hue*tpi;

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 18th November 2002, 09:12   #6
Zevensoft
Major Dude
 
Zevensoft's Avatar
 
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
Zevensoft is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump