58 constexpr RGB() :
b(0),
g(0),
r(0) {}
67 constexpr RGB(std::uint8_t red, std::uint8_t green, std::uint8_t blue) :
b(blue),
g(green),
r(red) {}
72 constexpr auto operator==(
const RGB &other)
const noexcept ->
bool =
default;
79 [[nodiscard]]
constexpr auto to_grayscale() const noexcept -> std::uint8_t {
80 return static_cast<std::uint8_t
>((0.299 *
static_cast<double>(
r)) + (0.587 *
static_cast<double>(
g)) +
81 (0.114 *
static_cast<double>(
b)));
150 constexpr RGBA(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 255)
151 :
a(alpha),
b(blue),
g(green),
r(red) {}
158 constexpr explicit RGBA(
const RGB &rgb) :
a(255),
b(rgb.
b),
g(rgb.
g),
r(rgb.
r) {}
177 [[nodiscard]]
constexpr auto to_grayscale() const noexcept -> std::uint8_t {
178 return static_cast<std::uint8_t
>((0.299 *
static_cast<double>(
r)) + (0.587 *
static_cast<double>(
g)) +
179 (0.114 *
static_cast<double>(
b)));
constexpr RGB Blue
Definition color.hpp:189
constexpr RGB Yellow
Definition color.hpp:190
constexpr RGB DarkGray
Definition color.hpp:194
constexpr RGB Cyan
Definition color.hpp:191
constexpr RGB Magenta
Definition color.hpp:192
constexpr RGB LightGray
Definition color.hpp:195
constexpr RGB Black
Definition color.hpp:185
constexpr RGB White
Definition color.hpp:186
constexpr RGB Red
Definition color.hpp:187
constexpr RGB Green
Definition color.hpp:188
constexpr RGB Gray
Definition color.hpp:193
std::uint8_t b
Blue component (0-255)
Definition color.hpp:133
constexpr RGBA(const RGB &rgb)
Construct RGBA from RGB (fully opaque).
Definition color.hpp:158
std::uint8_t a
Alpha component (0-255, 0=transparent, 255=opaque)
Definition color.hpp:132
std::uint8_t g
Green component (0-255)
Definition color.hpp:134
std::uint8_t r
Red component (0-255)
Definition color.hpp:135
constexpr RGBA(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha=255)
Construct RGBA color from components.
Definition color.hpp:150
constexpr auto to_grayscale() const noexcept -> std::uint8_t
Convert to grayscale using standard luminance formula.
Definition color.hpp:177
constexpr RGBA()
Default constructor initializes to transparent black.
Definition color.hpp:140
constexpr auto to_rgb() const noexcept -> RGB
Convert to RGB (discards alpha channel).
Definition color.hpp:170
constexpr auto operator==(const RGBA &other) const noexcept -> bool=default
Equality comparison.
constexpr auto to_grayscale() const noexcept -> std::uint8_t
Convert to grayscale using standard luminance formula.
Definition color.hpp:79
std::uint8_t g
Green component (0-255)
Definition color.hpp:52
constexpr RGB()
Default constructor initializes to black.
Definition color.hpp:58
constexpr auto operator==(const RGB &other) const noexcept -> bool=default
Equality comparison.
constexpr RGB(std::uint8_t red, std::uint8_t green, std::uint8_t blue)
Construct RGB color from components.
Definition color.hpp:67
std::uint8_t r
Red component (0-255)
Definition color.hpp:53
std::uint8_t b
Blue component (0-255)
Definition color.hpp:51