mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-15 23:48:15 +08:00
Add more example for colors.
This commit is contained in:

committed by
Arthur Sonzogni

parent
dc8c090753
commit
d09996a6c7
@@ -10,8 +10,22 @@ namespace ftxui {
|
||||
/// @ingroup screen
|
||||
class Color {
|
||||
public:
|
||||
enum Palette16 : uint8_t;
|
||||
enum Palette256: uint8_t;
|
||||
|
||||
Color(); // Transparent.
|
||||
Color(Palette16 index); // Implicit conversion from index to Color.
|
||||
Color(Palette256 index); // Implicit conversion from index to Color.
|
||||
Color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static Color RGB(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value);
|
||||
|
||||
//---------------------------
|
||||
// List of colors:
|
||||
//---------------------------
|
||||
|
||||
// clang-format off
|
||||
enum Palette16 {
|
||||
enum Palette16 : uint8_t {
|
||||
Black = 30,
|
||||
Blue = 34,
|
||||
BlueLight = 94,
|
||||
@@ -31,7 +45,7 @@ class Color {
|
||||
YellowLight = 93,
|
||||
};
|
||||
|
||||
enum Palette256 {
|
||||
enum Palette256 : uint8_t {
|
||||
Aquamarine1 = 122,
|
||||
Aquamarine1Bis = 86,
|
||||
Aquamarine3 = 79,
|
||||
@@ -275,14 +289,6 @@ class Color {
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
public:
|
||||
Color(); // Transparent.
|
||||
Color(Palette256 index); // Implicit conversion from index to Color.
|
||||
Color(Palette16 index); // Implicit conversion from index to Color.
|
||||
Color(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static Color RGB(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static Color HSV(uint8_t hue, uint8_t saturation, uint8_t value);
|
||||
|
||||
// --- Operators ------
|
||||
bool operator==(const Color& rhs) const;
|
||||
bool operator!=(const Color& rhs) const;
|
||||
|
23
include/ftxui/screen/color_info.hpp
Normal file
23
include/ftxui/screen/color_info.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef FTXUI_SCREEN_COLOR_INFO_HPP
|
||||
#define FTXUI_SCREEN_COLOR_INFO_HPP
|
||||
|
||||
#include <ftxui/screen/color.hpp>
|
||||
|
||||
namespace ftxui {
|
||||
|
||||
struct ColorInfo {
|
||||
const char* name;
|
||||
uint8_t index;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
uint8_t hue;
|
||||
uint8_t saturation;
|
||||
uint8_t value;
|
||||
};
|
||||
|
||||
ColorInfo GetColorInfo(Color::Palette256 index);
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
#endif /* end of include guard: FTXUI_SCREEN_COLOR_INFO_HPP */
|
Reference in New Issue
Block a user