23 static const Color White;
24 static const Color Black;
35 Color(
float r = 0,
float g = 0,
float b = 0,
float a = 1.0 )
36 : r( r ), g( g ), b( b ), a( a ) { }
43 Color(
const unsigned char* arr );
46 inline Color operator+(
const Color& rhs )
const {
47 return Color( r + rhs.
r, g + rhs.
g, b + rhs.
b, a + rhs.
a);
51 r += rhs.r; g += rhs.g; b += rhs.b; a += rhs.a;
56 inline Color operator*(
const Color& rhs )
const {
57 return Color( r * rhs.r, g * rhs.g, b * rhs.b, a * rhs.a);
61 r *= rhs.r; g *= rhs.g; b *= rhs.b; a *= rhs.a;
66 inline Color operator*(
float s )
const {
67 return Color( r * s, g * s, b * s, a * s );
70 inline Color& operator*=(
float s ) {
71 r *= s; g *= s; b *= s; a *= s;
76 inline bool operator==(
const Color& rhs )
const {
77 return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
80 inline bool operator!=(
const Color& rhs )
const {
81 return !operator==( rhs );
99 std::string
toHex( )
const;
106 inline Color operator*(
float s,
const Color& c ) {
111 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