31 : _r(
r), _g(
g), _b(
b), _a(
a), _valid(
true) {}
91 return Color(255 - _r, 255 - _g, 255 - _b, _a);
100 return (0.2126 * _r + 0.7152 * _g + 0.0722 * _b) / 255.0;
111 :
Color(255, 255, 255, _a);
130 return !(*
this ==
other);
134 static const Color Black;
135 static const Color White;
136 static const Color Red;
137 static const Color Green;
138 static const Color Blue;
139 static const Color Yellow;
140 static const Color Cyan;
141 static const Color Magenta;
142 static const Color DarkGray;
143 static const Color LightGray;
144 static const Color Orange;
145 static const Color Transparent;
146 static const Color Ignored;
General-purpose RGBA color.
Definition color.h:24
bool operator!=(const Color &other) const
Inequality operator.
Definition color.h:129
void setA(uint8_t val)
Sets the alpha component.
Definition color.h:58
uint8_t b() const
Returns the blue component.
Definition color.h:43
static Color fromHex(const String &hex)
Creates a Color from a hex string.
Color contrastingBW() const
Returns black or white, whichever contrasts best.
Definition color.h:108
bool isValid() const
Returns true if this color was explicitly constructed.
Definition color.h:34
String toHex(bool includeAlpha=false) const
Converts this color to a hex string.
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Constructs a color from RGBA components.
Definition color.h:30
uint8_t r() const
Returns the red component.
Definition color.h:37
Color lerp(const Color &other, double t) const
Linearly interpolates between this color and another.
Color complementary() const
Returns the complementary color (hue rotated 180 degrees).
uint8_t g() const
Returns the green component.
Definition color.h:40
Color()=default
Default constructor. Creates an invalid (all-zero) color.
double luminance() const
Returns the perceptual luminance (0.0 to 1.0).
Definition color.h:99
void setR(uint8_t val)
Sets the red component.
Definition color.h:49
uint8_t a() const
Returns the alpha component.
Definition color.h:46
void setB(uint8_t val)
Sets the blue component.
Definition color.h:55
Color inverted() const
Returns the RGB-inverted color (255 - each channel).
Definition color.h:90
void setG(uint8_t val)
Sets the green component.
Definition color.h:52
bool operator==(const Color &other) const
Equality operator.
Definition color.h:123
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
TextStream & hex(TextStream &s)
Sets integer base to 16 (hexadecimal).
Definition textstream.h:409