mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-15 07:28:16 +08:00
Color alpha support. (#884)
This commit is contained in:
@@ -29,10 +29,16 @@ class Color {
|
||||
Color(Palette16 index); // Implicit conversion from index to Color.
|
||||
Color(Palette256 index); // Implicit conversion from index to Color.
|
||||
// NOLINTEND
|
||||
Color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255);
|
||||
static Color RGB(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value);
|
||||
static Color RGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha);
|
||||
static Color HSVA(uint8_t hue,
|
||||
uint8_t saturation,
|
||||
uint8_t value,
|
||||
uint8_t alpha);
|
||||
static Color Interpolate(float t, const Color& a, const Color& b);
|
||||
static Color Blend(const Color& lhs, const Color& rhs);
|
||||
|
||||
//---------------------------
|
||||
// List of colors:
|
||||
@@ -310,6 +316,7 @@ class Color {
|
||||
bool operator!=(const Color& rhs) const;
|
||||
|
||||
std::string Print(bool is_background_color) const;
|
||||
bool IsOpaque() const { return alpha_ == 255; }
|
||||
|
||||
private:
|
||||
enum class ColorType : uint8_t {
|
||||
@@ -322,6 +329,7 @@ class Color {
|
||||
uint8_t red_ = 0;
|
||||
uint8_t green_ = 0;
|
||||
uint8_t blue_ = 0;
|
||||
uint8_t alpha_ = 0;
|
||||
};
|
||||
|
||||
inline namespace literals {
|
||||
|
@@ -38,7 +38,7 @@ struct Pixel {
|
||||
|
||||
// The graphemes stored into the pixel. To support combining characters,
|
||||
// like: a?, this can potentially contain multiple codepoints.
|
||||
std::string character = " ";
|
||||
std::string character = "";
|
||||
|
||||
// Colors:
|
||||
Color background_color = Color::Default;
|
||||
|
Reference in New Issue
Block a user