22 static const Color White;
23 static const Color Black;
34 Color(
float r = 0,
float g = 0,
float b = 0,
float a = 1.0)
35 : r(r), g(g), b(b),
a(
a) {}
42 Color(
const unsigned char *arr);
45 inline Color operator+(
const Color &rhs)
const {
46 return Color(r + rhs.r, g + rhs.g, b + rhs.b,
a + rhs.a);
58 inline Color operator*(
const Color &rhs)
const {
59 return Color(r * rhs.r, g * rhs.g, b * rhs.b,
a * rhs.a);
71 inline Color operator*(
float s)
const {
72 return Color(r * s, g * s, b * s,
a * s);
75 inline Color &operator*=(
float s) {
84 inline bool operator==(
const Color &rhs)
const {
85 return r == rhs.r && g == rhs.g && b == rhs.b &&
a == rhs.a;
88 inline bool operator!=(
const Color &rhs)
const {
return !operator==(rhs); }
105 std::string
toHex()
const;
110 inline Color operator*(
float s,
const Color &c) {
return c * s; }
113 std::ostream &operator<<(std::ostream &os,
const Color &c);
float a
value of alpha chanel
Definition: color.h:20
static Color fromHex(const char *s)
Construct a Color object from a hexadecimal (8-bit per component) ASCII string.
Definition: color.cpp:24
float r
value of red chanel
Definition: color.h:17
float g
value of green chanel
Definition: color.h:18
std::string toHex() const
Returns a hexadecimal string rrggbb encoding this color.
Definition: color.cpp:55
float b
value of blue chanel
Definition: color.h:19
Encodes a color via additive red, green, and blue chanel values.
Definition: color.h:13
Color(float r=0, float g=0, float b=0, float a=1.0)
Constructor.
Definition: color.h:35