|
CoreComponents 3.0.0
A Modern C++ Toolkit
|
ARGB color tuple (32 bit) More...
#include <cc/Color>
Public Member Functions | |
| Color () | |
| Create an invalid color. | |
| Color (uint32_t w) | |
| Create a color from word w. | |
| Color (int w) | |
| Color (const char *s) | |
| Color (const String &s) | |
| Construct a color from color literal or name s. | |
| template<class T > | |
| Color (T r, T g, T b, T a=0xFF) | |
| Compose a color from its components. | |
| Color | operator() (int percent) const |
| Create a semi-transparent version of this color with percent opacity. | |
| operator bool () const | |
| Check if valid. | |
| bool | isValid () const |
| Check if valid. | |
| bool | isOpaque () const |
| Check if this color is fully opaque. | |
| uint32_t | alpha () const |
| Return the alpha color component | |
| uint32_t | red () const |
| Return the red color component | |
| uint32_t | green () const |
| Return the green color component | |
| uint32_t | blue () const |
| Return the blue color component | |
| void | applyOver (Color b) |
| Alpha-blend color b over this color. | |
| Color | on (Color b) const |
| Alpha-blend this color over b and return the result. | |
| void | mixIn (Color b, int percent) |
| Mix color b into this color by percent. | |
| Color | mixedWith (Color b, int percent) const |
| Return this color mixed with b by percent | |
| Color | lighter (int percent) const |
| Return a lighter version of this color | |
| Color | darker (int percent) const |
| Return a darker version of this color | |
| Color | premultiplied () const |
| Translate from non-premultiplied to premultiplied representation. | |
| Color | normalized () const |
| Translate from premultiplied to non-premultiplied representation. | |
| void | premultiply () |
| Translate from non-premultiplied to premultiplied representation. | |
| void | normalize () |
| Translate from premultiplied to non-premultiplied representation. | |
| uint32_t | value () const |
| Convert to an unsigned 32-bit word. | |
| uint32_t & | value () |
| Access underlying unsigned 32-bit word. | |
| operator uint32_t () const | |
| Access underlying unsigned 32-bit word. | |
| String | toString () const |
| Stringify this color value. | |
Static Public Member Functions | |
| static Color | fromHue (double h) |
| Get the full color of hue h. | |
| static Color | fromHsv (double h, double s, double v) |
| Get color from a HSV tuple. | |
| static Color | fromHsl (double h, double s, double l) |
| Get color from HSL tuple. | |
| static Color | blend (Color a, Color b) |
| Alpha-blend color a over color b. | |
Static Public Attributes | |
| static const Color | Transparent { 0x00, 0x00, 0x00, 0x00 } |
| Transparent color constant. | |
| static const Color | Black { 0x00, 0x00, 0x00 } |
| Black color constant. | |
| static const Color | White { 0xFF, 0xFF, 0xFF } |
| White color constant. | |
| static const Color | Red { 0xFF, 0x00, 0x00 } |
| Red color constant. | |
| static const Color | Green { 0x00, 0xFF, 0x00 } |
| Green color constant. | |
| static const Color | Blue { 0x00, 0x00, 0xFF } |
| Blue color constant. | |
| static constexpr int | AlphaShift = 24 |
| Bit position of the alpha component within the 32 bit color word. | |
| static constexpr int | RedShift = 16 |
| Bit position of the red component within the 32 bit color word. | |
| static constexpr int | GreenShift = 8 |
| Bit position of the green component within the 32 bit color word. | |
| static constexpr int | BlueShift = 0 |
| Bit position of the blue component within the 32 bit color word. | |
| static constexpr uint32_t | RedMask = uint32_t(0xFF) << RedShift |
| Bitmask for the red component of the 32 bit color word. | |
| static constexpr uint32_t | GreenMask = uint32_t(0xFF) << GreenShift |
| Bitmask for the green component of the 32 bit color word. | |
| static constexpr uint32_t | BlueMask = uint32_t(0xFF) << BlueShift |
| Bitmask for the blue component of the 32 bit color word. | |
| static constexpr uint32_t | AlphaMask = uint32_t(0xFF) << AlphaShift |
| Bitmask for the alpha component of the 32 bit color word. | |
ARGB color tuple (32 bit)
| Color | ( | ) |
Create an invalid color.
Construct a color from color literal or name s.
| s | Color specification to parse Color literals can be either SVG color names (e.g. 'AliceBlue') or literal RGB tuples (#RRGGBB, #RRGGBBAA, #RGB, #RGBA). |
| Color | ( | T | r, |
| T | g, | ||
| T | b, | ||
| T | a = 0xFF ) |
Compose a color from its components.
| r | Red component (0..0xFF) |
| g | Green component (0..0xFF) |
| b | Blue component (0..0xFF) |
| a | Opacity component (0..0xFF) |
|
static |
Get the full color of hue h.
| h | Hue in range [0, 360] |
|
static |
Get color from a HSV tuple.
| h | Hue in range [0, 360] |
| s | Saturation in range [0, 1] |
| v | Value in range [0, 1] |
|
static |
Get color from HSL tuple.
| h | Hue in range [0, 360] |
| s | Saturation in range [0, 1] |
| l | Luminance in range [0, 1] |
| Color operator() | ( | int | percent | ) | const |
Create a semi-transparent version of this color with percent opacity.
|
explicit |
Check if valid.
A color is considered invalid, if alpha is zero and either red, green or blue is non-zero.
| bool isValid | ( | ) | const |
Check if valid.
A color is considered invalid, if alpha is zero and either red, green or blue is non-zero.
| bool isOpaque | ( | ) | const |
Check if this color is fully opaque.
| uint32_t alpha | ( | ) | const |
Return the alpha color component
| uint32_t red | ( | ) | const |
Return the red color component
| uint32_t green | ( | ) | const |
Return the green color component
| uint32_t blue | ( | ) | const |
Return the blue color component
| void applyOver | ( | Color | b | ) |
Alpha-blend color b over this color.
| void mixIn | ( | Color | b, |
| int | percent ) |
Mix color b into this color by percent.
| Color lighter | ( | int | percent | ) | const |
Return a lighter version of this color
| Color darker | ( | int | percent | ) | const |
Return a darker version of this color
| Color premultiplied | ( | ) | const |
Translate from non-premultiplied to premultiplied representation.
| Color normalized | ( | ) | const |
Translate from premultiplied to non-premultiplied representation.
| void premultiply | ( | ) |
Translate from non-premultiplied to premultiplied representation.
| void normalize | ( | ) |
Translate from premultiplied to non-premultiplied representation.
| uint32_t value | ( | ) | const |
Convert to an unsigned 32-bit word.
| uint32_t & value | ( | ) |
Access underlying unsigned 32-bit word.
| operator uint32_t | ( | ) | const |
Access underlying unsigned 32-bit word.
| String toString | ( | ) | const |
Stringify this color value.
|
static |
Transparent color constant.
|
static |
Black color constant.
|
static |
White color constant.
|
static |
Red color constant.
|
static |
Green color constant.
|
static |
Blue color constant.
|
staticconstexpr |
Bit position of the alpha component within the 32 bit color word.
|
staticconstexpr |
Bit position of the red component within the 32 bit color word.
|
staticconstexpr |
Bit position of the green component within the 32 bit color word.
|
staticconstexpr |
Bit position of the blue component within the 32 bit color word.
Bitmask for the red component of the 32 bit color word.
|
staticconstexpr |
Bitmask for the green component of the 32 bit color word.
Bitmask for the blue component of the 32 bit color word.
|
staticconstexpr |
Bitmask for the alpha component of the 32 bit color word.