38 :
red(
std::clamp(r, 0, 255)),
59 if (hexString.length() != 7 || !hexString.starts_with(
"#") ||
63 throw std::invalid_argument(
64 fmt::format(
"Invalid hex string for Color \"{}\"", hexString));
77 constexpr operator Color()
const {
89 if (hexString.length() != 7 || !hexString.starts_with(
"#") ||
93 throw std::invalid_argument(
94 fmt::format(
"Invalid hex string for Color \"{}\"", hexString));
Represents colors that can be used with Addressable LEDs.
Definition: Color8Bit.h:23
constexpr Color8Bit(std::string_view hexString)
Constructs a Color8Bit from a hex string.
Definition: Color8Bit.h:58
constexpr auto HexString() const
Return this color represented as a hex string.
Definition: Color8Bit.h:111
constexpr Color8Bit(const Color &color)
Constructs a Color8Bit from a Color.
Definition: Color8Bit.h:47
static constexpr Color8Bit FromHexString(std::string_view hexString)
Create a Color8Bit from a hex string.
Definition: Color8Bit.h:88
constexpr bool operator==(const Color8Bit &) const =default
constexpr Color8Bit(int r, int g, int b)
Constructs a Color8Bit.
Definition: Color8Bit.h:37
int red
Red component (0-255).
Definition: Color8Bit.h:119
constexpr Color8Bit()=default
Constructs a default color (black).
int blue
Blue component (0-255).
Definition: Color8Bit.h:125
int green
Green component (0-255).
Definition: Color8Bit.h:122
Represents colors that can be used with Addressable LEDs.
Definition: Color.h:24
basic_string_view< char > string_view
Definition: core.h:501
Definition: AprilTagPoseEstimator.h:15
constexpr char hexdigit(unsigned X, bool LowerCase=false) noexcept
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
Definition: StringExtras.h:37
constexpr bool isHexDigit(char C) noexcept
Checks if character C is a hexadecimal numeric character.
Definition: StringExtras.h:65
constexpr unsigned hexDigitValue(char C) noexcept
Interpret the given character C as a hexadecimal digit and return its value.
Definition: StringExtras.h:46
Fixed length string (array of character) for compile time use.
Definition: ct_string.h:29
color
Definition: color.h:16
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:108