16using namespace std::literals;
41 return red_ ==
rhs.red_ && green_ ==
rhs.green_ && blue_ ==
rhs.blue_ &&
51 case ColorType::Palette1:
54 case ColorType::Palette16:
57 case ColorType::Palette256:
60 case ColorType::TrueColor:
63 + std::to_string(red_) +
";"
64 + std::to_string(green_) +
";"
65 + std::to_string(blue_);
87 type_ = ColorType::Palette16;
99 : type_(ColorType::TrueColor), red_(red), green_(green), blue_(blue) {
123 type_ = ColorType::Palette256;
126 type_ = ColorType::Palette16;
140 return {red, green, blue};
177 if (
a.type_ == ColorType::Palette1 ||
178 b.type_ == ColorType::Palette1) {
188 switch (
color.type_) {
189 case ColorType::Palette1: {
193 case ColorType::Palette16: {
201 case ColorType::Palette256: {
209 case ColorType::TrueColor:
212 *green =
color.green_;
231 constexpr float gamma = 2.2F;
234 const float c_f =
a_f * (1.0F -
t) +
243inline namespace literals {
250 return {red, green, blue};
A class representing terminal colors.
Color()
Build a transparent color.
static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value)
Build a Color from its HSV representation. https://en.wikipedia.org/wiki/HSL_and_HSV.
bool operator!=(const Color &rhs) const
bool operator==(const Color &rhs) const
static Color RGB(uint8_t red, uint8_t green, uint8_t blue)
Build a Color from its RGB representation. https://en.wikipedia.org/wiki/RGB_color_model.
std::string Print(bool is_background_color) const
static Color Interpolate(float t, const Color &a, const Color &b)
Color ColorSupport()
Get the color support of the terminal.
ColorInfo GetColorInfo(Color::Palette256 index)
Component Slider(SliderOption< T > options)
A slider in any direction.
Decorator color(Color)
Decorate using a foreground color.