Pixel Color Union. The Color union allows access to each unsigned 8 bit RGBA color component individually or as a single 32 bit unsigned integer, making possible color asignments similar to those used on the web (IE: color = 0xFF000000 with the format 0xAARRGGBB). The union type is also 32bits wide which makes it suitable to be passed as value or as reference. Wherever a Color variable can be passed it should be possible to pass a 32 bit unsigned integer value, but some compilers may complain depending on the set warning level.
More...
#include <aeongui/Color.hpp>
|
| | Color (uint32_t value) |
| | 32 bit Unsigned integer constructor.
|
| | Color (const std::string &value) |
| | Construct a Color from a CSS color string.
|
| | Color (uint8_t A, uint8_t R, uint8_t G, uint8_t B) |
| | 4 8 bit Unsigned integer component constructor.
|
| void | Blend (Color src) |
| | Blends the color with the incoming source color. To better handle transparency the blend function uses the source alpha as source factor and one minus source alpha as destination factor.
|
| double | R () const |
| | Get red component as a double in [0.0, 1.0].
|
| double | G () const |
| | Get green component as a double in [0.0, 1.0].
|
| double | B () const |
| | Get blue component as a double in [0.0, 1.0].
|
| double | A () const |
| | Get alpha component as a double in [0.0, 1.0].
|
| std::string | ToString () const |
| | Convert the color to a CSS-style string representation.
|
|
| static bool | IsColor (const std::string &value, uint32_t *color_value=nullptr) |
| | Check whether a string represents a valid CSS color.
|
|
|
uint32_t | bgra |
| | 32 bit Unsigned integer color value.
|
|
struct { | |
|
uint8_t b | |
| | Blue color element.
|
|
uint8_t g | |
| | Green color element.
|
|
uint8_t r | |
| | Red color element.
|
|
uint8_t a | |
| | Alpha color element.
|
| }; | |
|
|
static const std::regex | ColorRegex {"#[0-9A-Fa-f]{8}|#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|grey|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|none|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen"} |
| | Regex used to parse CSS color strings.
|
Pixel Color Union. The Color union allows access to each unsigned 8 bit RGBA color component individually or as a single 32 bit unsigned integer, making possible color asignments similar to those used on the web (IE: color = 0xFF000000 with the format 0xAARRGGBB). The union type is also 32bits wide which makes it suitable to be passed as value or as reference. Wherever a Color variable can be passed it should be possible to pass a 32 bit unsigned integer value, but some compilers may complain depending on the set warning level.
◆ Color() [1/3]
| AeonGUI::Color::Color |
( |
uint32_t | value | ) |
|
|
explicit |
32 bit Unsigned integer constructor.
- Parameters
-
◆ Color() [2/3]
| AeonGUI::Color::Color |
( |
const std::string & | value | ) |
|
Construct a Color from a CSS color string.
- Parameters
-
| value | A CSS color string (e.g. "#FF0000" or "red"). |
◆ Color() [3/3]
| AeonGUI::Color::Color |
( |
uint8_t | A, |
|
|
uint8_t | R, |
|
|
uint8_t | G, |
|
|
uint8_t | B ) |
4 8 bit Unsigned integer component constructor.
- Parameters
-
| A | Alpha color value. |
| R | Red color value. |
| G | Green color value. |
| B | Blue color value. |
◆ A()
| double AeonGUI::Color::A |
( |
| ) |
const |
Get alpha component as a double in [0.0, 1.0].
- Returns
- The alpha component.
◆ B()
| double AeonGUI::Color::B |
( |
| ) |
const |
Get blue component as a double in [0.0, 1.0].
- Returns
- The blue component.
◆ Blend()
| void AeonGUI::Color::Blend |
( |
Color | src | ) |
|
Blends the color with the incoming source color. To better handle transparency the blend function uses the source alpha as source factor and one minus source alpha as destination factor.
- Parameters
-
| src | Incomming source color. |
◆ G()
| double AeonGUI::Color::G |
( |
| ) |
const |
Get green component as a double in [0.0, 1.0].
- Returns
- The green component.
◆ IsColor()
| bool AeonGUI::Color::IsColor |
( |
const std::string & | value, |
|
|
uint32_t * | color_value = nullptr ) |
|
static |
Check whether a string represents a valid CSS color.
- Parameters
-
| value | The string to test. |
| color_value | Optional output for the parsed color. |
- Returns
- true if the string is a valid color.
◆ R()
| double AeonGUI::Color::R |
( |
| ) |
const |
Get red component as a double in [0.0, 1.0].
- Returns
- The red component.
◆ ToString()
| std::string AeonGUI::Color::ToString |
( |
| ) |
const |
Convert the color to a CSS-style string representation.
- Returns
- A string such as "rgba(255,0,0,1)".
The documentation for this union was generated from the following files: