General-purpose RGBA color. More...
#include <color.h>

Public Member Functions | |
| Color ()=default | |
| Default constructor. Creates an invalid (all-zero) color. | |
| Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) | |
| Constructs a color from RGBA components. | |
| bool | isValid () const |
| Returns true if this color was explicitly constructed. | |
| uint8_t | r () const |
| Returns the red component. | |
| uint8_t | g () const |
| Returns the green component. | |
| uint8_t | b () const |
| Returns the blue component. | |
| uint8_t | a () const |
| Returns the alpha component. | |
| void | setR (uint8_t val) |
| Sets the red component. | |
| void | setG (uint8_t val) |
| Sets the green component. | |
| void | setB (uint8_t val) |
| Sets the blue component. | |
| void | setA (uint8_t val) |
| Sets the alpha component. | |
| String | toHex (bool includeAlpha=false) const |
| Converts this color to a hex string. | |
| Color | lerp (const Color &other, double t) const |
| Linearly interpolates between this color and another. | |
| Color | inverted () const |
| Returns the RGB-inverted color (255 - each channel). | |
| double | luminance () const |
| Returns the perceptual luminance (0.0 to 1.0). | |
| Color | contrastingBW () const |
| Returns black or white, whichever contrasts best. | |
| Color | complementary () const |
| Returns the complementary color (hue rotated 180 degrees). | |
| bool | operator== (const Color &other) const |
| Equality operator. | |
| bool | operator!= (const Color &other) const |
| Inequality operator. | |
Static Public Member Functions | |
| static Color | fromHex (const String &hex) |
| Creates a Color from a hex string. | |
Static Public Attributes | |
| static const Color | Black |
| static const Color | White |
| static const Color | Red |
| static const Color | Green |
| static const Color | Blue |
| static const Color | Yellow |
| static const Color | Cyan |
| static const Color | Magenta |
| static const Color | DarkGray |
| static const Color | LightGray |
| static const Color | Orange |
| static const Color | Transparent |
| static const Color | Ignored |
General-purpose RGBA color.
A simple value type storing red, green, blue, and alpha channels as uint8_t values. Provides named color constants, hex conversion, and linear interpolation.
| Color Color::complementary | ( | ) | const |
Returns the complementary color (hue rotated 180 degrees).
Converts to HSL, rotates hue by 180 degrees, and converts back. Saturation, lightness, and alpha are preserved.
|
inline |
Returns black or white, whichever contrasts best.
Uses perceptual luminance to decide. Alpha is preserved.
|
inline |
Returns the RGB-inverted color (255 - each channel).
Alpha is preserved.
|
inline |
Converts this color to a hex string.
| includeAlpha | If true, includes the alpha channel. |