KrisLibrary  1.0.0
GLColor.h
1 #ifndef GL_COLOR_H
2 #define GL_COLOR_H
3 
4 namespace GLDraw {
5 
9 struct GLColor
10 {
11  GLColor(float r=1,float g=1,float b=1,float a=1);
12  GLColor(const float rgba[4]);
13  GLColor(const GLColor& col);
14 
15  inline operator float* () { return rgba; }
16  inline operator const float* () const { return rgba; }
17  const GLColor& operator = (const GLColor& col);
18  bool operator == (const GLColor& col) const;
19  bool operator != (const GLColor& col) const;
20  float& operator [] (int i) { return rgba[i]; }
21  const float& operator [] (int i) const { return rgba[i]; }
22  float& red() { return rgba[0]; }
23  float& green() { return rgba[1]; }
24  float& blue() { return rgba[2]; }
25  float& alpha() { return rgba[3]; }
26 
27  void set(float r,float g,float b,float a=1);
28  void set(const float rgba[4]);
29  void set(const GLColor& col);
30  inline void setBlack(float a=1) { set(0,0,0,a); }
31  inline void setWhite(float a=1) { set(1,1,1,a); }
32  inline void setGray(float c=1) { set(c,c,c); }
33  inline void setRed(float r=1) { set(r,0,0); }
34  inline void setGreen(float g=1) { set(0,g,0); }
35  inline void setBlue(float b=1) { set(0,0,b); }
36  inline void setCyan(float c=1) { set(0,c,c); }
37  inline void setMagenta(float c=1) { set(c,0,c); }
38  inline void setYellow(float c=1) { set(c,c,0); }
39  void setRandom();
40  void setHSV(float h,const float s,const float v);
41  float getLuminance() const;
42  void getHSV(float& h, float& s, float& v) const;
43 
44  void clamp(float min=0.f,float max=1.f);
45  void compose(const GLColor& a,const GLColor& b);
46  void scale(const GLColor& a,float c);
47  void add(const GLColor& a,const GLColor& b);
48  void blend(const GLColor& a,const GLColor& b,float t);
49 
50  void setCurrentGL() const;
51 
52  float rgba[4];
53 };
54 
55 } //namespace GLDraw
56 
57 #endif
Contains all definitions in the GLDraw package.
Definition: AnyGeometry.h:13
An rgba color.
Definition: GLColor.h:9