25 static const Color White;
26 static const Color Black;
37 Color(
float r = 0,
float g = 0,
float b = 0,
float a = 1.0 )
38 : r( r ), g( g ), b( b ), a( a ) { }
45 Color(
const unsigned char* arr );
48 inline Color operator+(
const Color& rhs )
const {
49 return Color( r + rhs.
r, g + rhs.
g, b + rhs.
b, a + rhs.
a);
53 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);
63 r *= rhs.r; g *= rhs.g; b *= rhs.b; a *= rhs.a;
68 inline Color operator*(
float s )
const {
69 return Color( r * s, g * s, b * s, a * s );
72 inline Color& operator*=(
float s ) {
73 r *= s; g *= s; b *= s; a *= s;
78 inline bool operator==(
const Color& rhs )
const {
79 return r == rhs.r && g == rhs.g && b == rhs.b && a == rhs.a;
82 inline bool operator!=(
const Color& rhs )
const {
83 return !operator==( rhs );
101 std::string
toHex( )
const;
108 inline Color operator*(
float s,
const Color& c ) {
113 std::ostream& operator<<( std::ostream& os,
const Color& c );
float a
value of alpha chanel
Definition: color.h:22
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:19
float g
value of green chanel
Definition: color.h:20
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:21
Encodes a color via additive red, green, and blue chanel values.
Definition: color.h:15
Color(float r=0, float g=0, float b=0, float a=1.0)
Constructor.
Definition: color.h:37