Created
July 29, 2010 12:14
-
-
Save bilderbuchi/497958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ofColorHSVA{ | |
public: | |
ofColorHSVA(){ | |
h = 255; | |
s = 255; | |
v = 255; | |
a = 255; | |
} | |
virtual ~ofColorHSVA(){} | |
float h, s, v, a; //hue in interval 0-1, not 0-360°! | |
float & operator[]( int n ){ | |
switch( n ){ | |
case 0: | |
return h; | |
case 1: | |
return s; | |
case 2: | |
return v; | |
case 3: | |
return a; | |
default: | |
return h; | |
break; | |
} | |
} | |
// color conversion according to wikipedia | |
// http://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB | |
ofColor toRGBA(){ | |
ofColor rgba; | |
float c=v*s; //chroma | |
float hd=h/255*360; //to make it easier to convert the formulae | |
float hprime=hd/60.0; | |
//full calculation goes here | |
rgba.r= 127; //dummy values for now | |
rgba.g= 127; | |
rgba.b= 127; | |
rgba.a= 127; | |
return rgba; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment