5#include "roo_backport.h"
6#include "roo_backport/byte.h"
8#include "roo_io/memory/fill.h"
23 : argb_(0xFF000000LL | (
r << 16) | (
g << 8) |
b) {}
27 : argb_((
a << 24) | (
r << 16) | (
g << 8) |
b) {}
36 constexpr uint8_t a()
const {
return (argb_ >> 24) & 0xFF; }
38 constexpr uint8_t r()
const {
return (argb_ >> 16) & 0xFF; }
40 constexpr uint8_t g()
const {
return (argb_ >> 8) & 0xFF; }
42 constexpr uint8_t b()
const {
return argb_ & 0xFF; }
70 return Color(
a << 24 | (argb_ & 0x00FFFFFF));
75 return Color(
r << 16 | (argb_ & 0xFF00FFFF));
80 return Color(
g << 8 | (argb_ & 0xFFFF00FF));
85 return Color(
b << 0 | (argb_ & 0xFFFFFF00));
89 constexpr bool isOpaque()
const {
return a() == 0xFF; }
110 roo_io::PatternFill<sizeof(Color)>((roo::byte *)
buf, count,
111 (
const roo::byte *)(&
color));
114template <
typename ColorMode>
117 ColorMode mode = ColorMode()) {
118 return mode.toArgbColor(mode.fromArgbColor(
color));
133static constexpr auto Transparent =
Color(0);
140static constexpr auto Background =
Color(0x00FFFFFF);
ARGB8888 color stored as a 32-bit unsigned integer.
constexpr Color withR(uint8_t r) const
Return a copy with the specified red channel.
constexpr Color withG(uint8_t g) const
Return a copy with the specified green channel.
constexpr Color(uint8_t r, uint8_t g, uint8_t b)
Construct opaque color from RGB.
void set_b(uint8_t g)
Set blue channel.
void set_g(uint8_t g)
Set green channel.
constexpr bool isOpaque() const
Return true if the color is fully opaque (alpha = 255).
constexpr Color(uint8_t a, uint8_t r, uint8_t g, uint8_t b)
Construct ARGB color from components.
void set_r(uint8_t r)
Set red channel.
constexpr uint8_t a() const
Alpha channel.
constexpr uint8_t b() const
Blue channel.
constexpr uint8_t g() const
Green channel.
constexpr uint8_t r() const
Red channel.
constexpr Color(uint32_t argb)
Construct from a packed ARGB value.
constexpr Color withA(uint8_t a) const
Return a copy with the specified alpha channel.
constexpr Color withB(uint8_t b) const
Return a copy with the specified blue channel.
constexpr Color toOpaque()
Return a fully opaque copy (alpha = 255).
Color()
Construct transparent black.
void set_a(uint8_t a)
Set alpha channel.
constexpr uint32_t asArgb() const
Return packed ARGB value.
Defines 140 opaque HTML named colors.
constexpr Color Graylevel(uint8_t level)
Return an opaque gray with r = g = b = level.
constexpr bool operator==(const Color &a, const Color &b)
Equality operator for colors.
constexpr bool operator!=(const Color &a, const Color &b)
Inequality operator for colors.
void FillColor(Color *buf, uint32_t count, Color color)
Fill an array with a single color.
constexpr Color TruncateColor(Color color, ColorMode mode=ColorMode())
Truncate a color to a given color mode and back to ARGB.