41 #ifndef BPP_GRAPHICS_RGBCOLOR_H
42 #define BPP_GRAPHICS_RGBCOLOR_H
49 #include "../Text/TextTools.h"
50 #include "../Exceptions.h"
51 #include "../Clonable.h"
96 std::string hex =
"#";
108 if (i == 0)
return red_;
109 if (i == 1)
return green_;
110 if (i == 2)
return blue_;
119 if (i == 0)
return red_;
120 if (i == 1)
return green_;
121 if (i == 2)
return blue_;
136 std::string hexa =
"0123456789ABCDEF";
137 std::string hex =
"";
140 unsigned int tmp = dec -
static_cast<unsigned int>(floor(
static_cast<double>(dec) / 16.) * 16);
141 hex = hexa[tmp] + hex;
142 dec =
static_cast<unsigned int>(floor(
static_cast<double>(dec) / 16.));
144 hex = hexa[dec] + hex;
145 if (hex.size() == 1) hex =
"0" + hex;
The Clonable interface (allow an object to be cloned).
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
Describe a color according to its red, green and blue componants.
static std::string decToHex(unsigned int dec)
const unsigned int & operator[](unsigned int i) const
Access to each color componant: 0=red, 1=green, 2=blue.
std::string toHex() const
Get the HTML-like, hexadecimal description of this color.
bool operator<(const RGBColor &color) const
Comparison operator (for sorting purposes).
RGBColor * clone() const
Create a copy of this object and send a pointer to it.
bool operator==(const RGBColor &color) const
std::string toString() const
Get a string description of the color, e.g. [R255,G0,B255].
unsigned int & operator[](unsigned int i)
Access to each color componant: 0=red, 1=green, 2=blue.
RGBColor(unsigned int red, unsigned int green, unsigned int blue)
std::string toString(T t)
General template method to convert to a string.