----------------------------------------------------------------------------- IPLColor container and helper class ! * Saves a RGB color and converts to and from HSL, HSV */
| 28 | * Saves a RGB color and converts to and from HSL, HSV |
| 29 | */ |
| 30 | class IPLColor { |
| 31 | private: |
| 32 | ipl_basetype r; |
| 33 | ipl_basetype g; |
| 34 | ipl_basetype b; |
| 35 | |
| 36 | public: |
| 37 | IPLColor() { |
| 38 | this->r = 0.0f; |
| 39 | this->g = 0.0f; |
| 40 | this->b = 0.0f; |
| 41 | } |
| 42 | |
| 43 | IPLColor(float r, float g, float b) |
| 44 | { |
| 45 | this->r = r; |
| 46 | this->g = g; |
| 47 | this->b = b; |
| 48 | } |
| 49 | |
| 50 | IPLColor(const IPLColor* other) { |
| 51 | this->r = other->r; |
| 52 | this->g = other->g; |
| 53 | this->b = other->b; |
| 54 | } |
| 55 | |
| 56 | IPLColor& operator=(const IPLColor& other) { |
| 57 | r = other.r; |
| 58 | g = other.g; |
| 59 | b = other.b; |
| 60 | return *this; |
| 61 | } |
| 62 | |
| 63 | static IPLColor fromRGB(float r, float g, float b) |
| 64 | { |
| 65 | return IPLColor(r, g, b); |
| 66 | } |
| 67 | |
| 68 | static IPLColor fromHSL(float h, float s, float l) |
| 69 | { |
| 70 | float rgb[3]; |
| 71 | hslToRgb(h, s, l, rgb); |
| 72 | |
| 73 | IPLColor color(rgb[0], rgb[1], rgb[2]); |
| 74 | return color; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | static IPLColor fromHSV(float h, float s, float v) |
| 79 | { |
| 80 | float rgb[3]; |
| 81 | hsvToRgb(h, s, v, rgb); |
| 82 | |
| 83 | IPLColor color(rgb[0], rgb[1], rgb[2]); |
| 84 | return color; |
| 85 | } |
| 86 | |
| 87 | float red() const |
no outgoing calls
no test coverage detected