|
koutil
|
Structure representing a color. More...
#include <color.h>
Public Types | |
| enum class | Tag : std::uint8_t { RGB , ID } |
| using | channel_t = std::uint8_t |
Public Member Functions | |
| constexpr | color_t () |
| constexpr | color_t (channel_t r, channel_t g, channel_t b) |
| Constructor with RGB values. | |
| constexpr | color_t (std::uint8_t id) |
| Constructor with an ID value. | |
| constexpr std::array< channel_t, 3 > | get_channels () const |
| Gets the RGB channel values of the color. | |
| constexpr channel_t | id () const |
| Gets the ID value of the color. | |
| constexpr color_bg_t | as_bg () const |
| Converts the color to a ColorBG object. | |
| constexpr color_fg_t | as_fg () const |
| Converts the color to a ColorFG object. | |
| constexpr bool | operator== (color_t other) const |
Static Public Member Functions | |
| static constexpr color_t | from_rgb (channel_t red, channel_t green, channel_t blue) |
| Creates a Color object from RGB values. | |
| static constexpr color_t | from_id (channel_t id) |
| Creates a Color object from an ID value. | |
| static constexpr color_t | from_hsv (std::uint16_t h, float s, float v) |
| Creates a Color object from HSV values. | |
| static consteval color_t | from_hex (std::string_view hex) |
| Creates a Color object from a hexadecimal string. | |
Public Attributes | |
| const channel_t | red |
| const channel_t | green |
| const channel_t | blue |
| const Tag | tag |
Static Private Member Functions | |
| static consteval std::uint8_t | extract_value (char val) |
| Extracts a value from a hexadecimal character. | |
| static constexpr std::uint8_t | convert_val (float val) |
| Converts a floating-point value to a channel value. | |
Structure representing a color.
The Color structure represents a color with red, green, and blue channels. It can also represent a color using an ID value. Color objects can be created from RGB values, ID values, hexadecimal strings, or HSV values.
| using koutil::term::color_t::channel_t = std::uint8_t |
|
strong |
|
inlineconstexpr |
Constructor with RGB values.
Initializes the color with the specified RGB values and the RGB tag.
| r | Red channel value. |
| g | Green channel value. |
| b | Blue channel value. |
|
inlineconstexpr |
Constructor with an ID value.
Initializes the color with the specified ID value and the ID tag.
| id | ID value. |
|
nodiscardconstexpr |
Converts the color to a ColorBG object.
|
nodiscardconstexpr |
Converts the color to a ColorFG object.
|
inlinestaticconstexprprivate |
Converts a floating-point value to a channel value.
| val | Floating-point value. |
|
inlinestaticconstevalprivate |
Extracts a value from a hexadecimal character.
| val | Hexadecimal character. |
|
inlinestaticconsteval |
Creates a Color object from a hexadecimal string.
| hex | Hexadecimal string (e.g., "#RRGGBB" or "#RGB"). |
|
staticconstexpr |
Creates a Color object from HSV values.
| h | Hue value (0-359). |
| s | Saturation value (0.0-1.0). |
| v | Value (0.0-1.0). |
Creates a Color object from an ID value.
| id | ID value. |
|
inlinestaticconstexpr |
Creates a Color object from RGB values.
| red | Red channel value. |
| green | Green channel value. |
| blue | Blue channel value. |
|
inlinenodiscardconstexpr |
Gets the RGB channel values of the color.
|
inlinenodiscardconstexpr |
Gets the ID value of the color.
|
inlineconstexpr |
| const channel_t koutil::term::color_t::blue |
| const channel_t koutil::term::color_t::green |
| const channel_t koutil::term::color_t::red |
| const Tag koutil::term::color_t::tag |