[4838] | 1 | /*! |
---|
[5009] | 2 | * @file color.h |
---|
| 3 | * @brief Definition of color-calculations |
---|
| 4 | * |
---|
| 5 | * code borrowed from: |
---|
| 6 | * http://www.easyrgb.com/math.php |
---|
[3245] | 7 | */ |
---|
[1853] | 8 | |
---|
[5009] | 9 | #ifndef _COLOR_H |
---|
| 10 | #define _COLOR_H |
---|
[1853] | 11 | |
---|
[7195] | 12 | #include "vector.h" |
---|
[1853] | 13 | |
---|
[5011] | 14 | //! a very abstract Class that helps transforming Colors into different Systems |
---|
[5009] | 15 | class Color |
---|
| 16 | { |
---|
[7195] | 17 | public: |
---|
[8145] | 18 | Color(float r, float g, float b, float a) :_r(r), _g(g), _b(b), _a(a) {}; |
---|
| 19 | Color(const Color& c) { _r = c._r; _g = c._g; _b = c._b; _a = c._a; }; |
---|
| 20 | |
---|
| 21 | float r() const { return _r; } |
---|
| 22 | float& r() { return _r; } |
---|
| 23 | float g() const { return _g; } |
---|
| 24 | float& g() { return _g; } |
---|
| 25 | float b() const { return _b; } |
---|
| 26 | float& b() { return _b; } |
---|
| 27 | float a() const { return _a; } |
---|
| 28 | float& a() { return _a; } |
---|
| 29 | |
---|
| 30 | public: |
---|
[5010] | 31 | static Vector RGBtoHSV (const Vector& RGB); |
---|
[7195] | 32 | static void RGBtoHSV (const Vector& RGB, Vector& HSV); |
---|
[5010] | 33 | static Vector HSVtoRGB (const Vector& HSV); |
---|
[7195] | 34 | static void HSVtoRGB (const Vector& HSV, Vector& RGB); |
---|
[5010] | 35 | |
---|
[7195] | 36 | private: |
---|
[5010] | 37 | static float minrgb(float r, float g, float b); |
---|
| 38 | static float maxrgb(float r, float g, float b); |
---|
[8145] | 39 | |
---|
| 40 | float _r; //!< Red Value. |
---|
| 41 | float _g; //!< Green Value. |
---|
| 42 | float _b; //!< Blue Value. |
---|
| 43 | float _a; //!< Alpha Value. |
---|
| 44 | |
---|
[1853] | 45 | }; |
---|
| 46 | |
---|
[5009] | 47 | #endif /* _COLOR_H */ |
---|