rag
graphic 2d engine
Color.h
1 #ifndef Rag_Color_h
2 #define Rag_Color_h
3 
4 #include <string>
5 
6 namespace rag
7 {
8 
10 
11  class Color
12  {
13  public:
14 
16  Color(float r = 1, float g = 1, float b = 1, float a = 1);
17 
19 
20  Color(std::string color);
21 
23  unsigned int toRGBA() const;
24 
26  unsigned int toABGR() const;
27 
29  static unsigned int createRGBA(int r, int g, int b, int a);
30 
32  static unsigned int createABGR(int r, int g, int b, int a);
33 
34  Color& operator*=(const Color &rhs);
35  Color& operator*=(float value);
36  Color& operator/=(const Color &rhs);
37  Color& operator/=(float value);
38  Color& operator+=(const Color &rhs);
39 
40  const Color operator*(const Color &rhs) const;
41  const Color operator*(float value) const;
42  const Color operator/(const Color &rhs) const;
43  const Color operator/(float value) const;
44  const Color operator+(const Color &rhs) const;
45 
46  bool operator==(const Color &rhs);
47  bool operator!=(const Color &rhs);
48 
50  std::string toString();
51 
52  float r;
53  float g;
54  float b;
55  float a;
56 
57  const static Color black;
58  const static Color white;
59  };
60 
61 } // rag
62 
63 #endif
Definition: Bitmap.h:8
Color(float r=1, float g=1, float b=1, float a=1)
Construts a Color object default to white.
Definition: Color.cpp:14
static unsigned int createRGBA(int r, int g, int b, int a)
Returns an unsigned int from color values.
Definition: Color.cpp:157
std::string toString()
Returns a string representation of the Color object.
Definition: Color.cpp:137
static unsigned int createABGR(int r, int g, int b, int a)
Returns an unsigned int from color values.
Definition: Color.cpp:162
unsigned int toABGR() const
Writes the color in a single 32 bit int reversed.
Definition: Color.cpp:152
unsigned int toRGBA() const
Writes the color in a single 32 bit int.
Definition: Color.cpp:147
Represents RGBA color.
Definition: Color.h:11