Skip to content

Instantly share code, notes, and snippets.

@bilderbuchi
Created July 29, 2010 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilderbuchi/497958 to your computer and use it in GitHub Desktop.
Save bilderbuchi/497958 to your computer and use it in GitHub Desktop.
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