38 return red_ ==
rhs.red_ && green_ ==
rhs.green_ && blue_ ==
rhs.blue_ &&
49 case ColorType::Palette1:
51 case ColorType::Palette16:
53 case ColorType::Palette256:
54 return "48;5;" + std::to_string(red_);
55 case ColorType::TrueColor:
56 return "48;2;" + std::to_string(red_) +
";" + std::to_string(green_) +
57 ";" + std::to_string(blue_);
61 case ColorType::Palette1:
63 case ColorType::Palette16:
65 case ColorType::Palette256:
66 return "38;5;" + std::to_string(red_);
67 case ColorType::TrueColor:
68 return "38;2;" + std::to_string(red_) +
";" + std::to_string(green_) +
69 ";" + std::to_string(blue_);
87 : type_(ColorType::
Palette16), red_(index), alpha_(255) {}
92 : type_(ColorType::
Palette256), red_(index), alpha_(255) {
96 type_ = ColorType::Palette16;
109 : type_(ColorType::TrueColor),
137 type_ = ColorType::Palette256;
140 type_ = ColorType::Palette16;
154 return RGBA(red, green, blue, 255);
167 return {red, green, blue,
alpha};
182 uint8_t p = (v * (255 - s)) >> 8;
196 return {0, 0, 0,
alpha};
208 return HSVA(h, s, v, 255);
213 if (a.type_ == ColorType::Palette1 ||
214 b.type_ == ColorType::Palette1) {
224 switch (
color.type_) {
225 case ColorType::Palette1: {
229 case ColorType::Palette16: {
237 case ColorType::Palette256: {
245 case ColorType::TrueColor:
248 *green =
color.green_;
267 constexpr float gamma = 2.2F;
270 const float c_f =
a_f * (1.0F - t) +
287inline namespace literals {
294 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.
static Color RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
Build a Color from its RGBA representation. https://en.wikipedia.org/wiki/RGB_color_model.
static Color Blend(const Color &lhs, const Color &rhs)
Blend two colors together using the alpha channel.
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)
static Color HSVA(uint8_t hue, uint8_t saturation, uint8_t value, uint8_t alpha)
Build a Color from its HSV representation. https://en.wikipedia.org/wiki/HSL_and_HSV.
Color ColorSupport()
Get the color support of the terminal.
std::shared_ptr< T > Make(Args &&... args)
ColorInfo GetColorInfo(Color::Palette256 index)
Decorator color(Color)
Decorate using a foreground color.