Color
micro::color is a plain aggregate holding four uint8_t components — red,
green, blue, and alpha — each in the range [0, 255]. Alpha defaults to 255
(fully opaque) when omitted.
Construction
// Individual components (alpha defaults to 255):
auto orange = micro::color{255, 128, 0};
// With explicit alpha:
auto semitransparent = micro::color{255, 128, 0, 128};
// From a packed 0xRRGGBB integer:
auto c1 = micro::color::from_rgb(0xff8000);
// From a packed 0xRRGGBBAA integer:
auto c2 = micro::color::from_rgba(0xff8000ff);
Conversion
std::uint32_t rgb = c.to_rgb(); // 0xRRGGBB (alpha discarded)
std::uint32_t rgba = c.to_rgba(); // 0xRRGGBBAA
auto [r, g, b, a] = c.to_floats(); // components in [0.0f, 1.0f]
Equality
bool same = c1 == c2; // exact member-wise comparison
Named constants
| Constant | Value |
|---|---|
color::black |
(0, 0, 0) |
color::white |
(255, 255, 255) |
color::red |
(255, 0, 0) |
color::green |
(0, 255, 0) |
color::blue |
(0, 0, 255) |
color::yellow |
(255, 255, 0) |
color::cyan |
(0, 255, 255) |
color::magenta |
(255, 0, 255) |
color::transparent |
(0, 0, 0, 0) |
All named constants are inline constexpr — usable everywhere, zero runtime cost.