Represents a color based on RGBA (red, green, blue, alpha).
More...
#include <luciad/drawing/Color.h>
|
constexpr | Color () |
| Creates a default (transparent black) Color. More...
|
|
| Color (const char *hexString) |
| Creates a new color based on the given hex string. More...
|
|
| Color (const std::string &hexString) |
| Creates a new color based on the given hex string. More...
|
|
constexpr | Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
| Creates a new color with the given value for red, green, blue and alpha (transparency). More...
|
|
uint8_t | a () const |
| The alpha (transparency) component of the color. More...
|
|
std::array< double, 4 > | asDoubles () const |
| Returns this Color as a doubles array containing values {r, g, b, a} . More...
|
|
uint8_t | b () const |
| The blue component of the color. More...
|
|
uint8_t | g () const |
| The green component of the color. More...
|
|
bool | operator!= (const Color &rhs) const |
|
bool | operator== (const Color &rhs) const |
|
uint8_t | r () const |
| The red component of the color. More...
|
|
std::string | toHexString () const |
| Returns this color as a hex string. More...
|
|
Represents a color based on RGBA (red, green, blue, alpha).
◆ Color() [1/4]
constexpr luciad::Color::Color |
( |
| ) |
|
|
inlineconstexpr |
Creates a default (transparent black) Color.
◆ Color() [2/4]
constexpr luciad::Color::Color |
( |
uint8_t |
r, |
|
|
uint8_t |
g, |
|
|
uint8_t |
b, |
|
|
uint8_t |
a = 255 |
|
) |
| |
|
inlineconstexpr |
Creates a new color with the given value for red, green, blue and alpha (transparency).
- Parameters
-
r | the red component of the color |
g | the green component of the color |
b | the blue component of the color |
a | the alpha component of the color. For example: 255 is fully opaque, 0 is fully transparent. The default value is 255. |
◆ Color() [3/4]
luciad::Color::Color |
( |
const std::string & |
hexString | ) |
|
Creates a new color based on the given hex string.
- Parameters
-
hexString | a hex string representing a color, for example "#ff0000" for red, or "#00ff0088" for semi-transparent green. |
◆ Color() [4/4]
luciad::Color::Color |
( |
const char * |
hexString | ) |
|
Creates a new color based on the given hex string.
- Parameters
-
hexString | a hex string representing a color, for example "#ff0000" for red, or "#00ff0088" for semi-transparent green. |
◆ a()
uint8_t luciad::Color::a |
( |
| ) |
const |
|
inline |
The alpha (transparency) component of the color.
- Returns
- the alpha (transparency) component of the color.
◆ asDoubles()
std::array< double, 4 > luciad::Color::asDoubles |
( |
| ) |
const |
Returns this Color as a doubles array containing values {r, g, b, a}
.
These are double values between [0, 1]
.
- Returns
- this Color as a doubles array containing values
{r, g, b, a}
. These are double values between [0, 1]
.
- Since
- 2020.1
◆ b()
uint8_t luciad::Color::b |
( |
| ) |
const |
|
inline |
The blue component of the color.
- Returns
- the blue component of the color.
◆ black()
static constexpr Color luciad::Color::black |
( |
| ) |
|
|
inlinestaticconstexpr |
The color black.
- Returns
- a black color.
◆ blue()
static constexpr Color luciad::Color::blue |
( |
| ) |
|
|
inlinestaticconstexpr |
The color blue.
- Returns
- a blue color.
◆ cyan()
static constexpr Color luciad::Color::cyan |
( |
| ) |
|
|
inlinestaticconstexpr |
The color cyan.
- Returns
- a cyan color.
◆ fromDoubles()
static Color luciad::Color::fromDoubles |
( |
const double |
r, |
|
|
const double |
g, |
|
|
const double |
b, |
|
|
const double |
a = 1.0 |
|
) |
| |
|
inlinestatic |
Creates a new Color from the given double values.
All values are expected to be in the [0, 1] range. Other values will be clipped to this range.
- Parameters
-
r | the red component of the color |
g | the green component of the color |
b | the blue component of the color |
a | the alpha component of the color. For example: 1.0 is fully opaque, 0.0 is fully transparent. The default value is 1.0. |
- Returns
- a new Color
◆ g()
uint8_t luciad::Color::g |
( |
| ) |
const |
|
inline |
The green component of the color.
- Returns
- the green component of the color.
◆ green()
static constexpr Color luciad::Color::green |
( |
| ) |
|
|
inlinestaticconstexpr |
The color green.
- Returns
- a green color.
◆ magenta()
static constexpr Color luciad::Color::magenta |
( |
| ) |
|
|
inlinestaticconstexpr |
The color magenta.
- Returns
- a magenta color.
◆ operator!=()
bool luciad::Color::operator!= |
( |
const Color & |
rhs | ) |
const |
◆ operator==()
bool luciad::Color::operator== |
( |
const Color & |
rhs | ) |
const |
◆ r()
uint8_t luciad::Color::r |
( |
| ) |
const |
|
inline |
The red component of the color.
- Returns
- the red component of the color.
◆ red()
static constexpr Color luciad::Color::red |
( |
| ) |
|
|
inlinestaticconstexpr |
The color red.
- Returns
- a red color.
◆ toHexString()
std::string luciad::Color::toHexString |
( |
| ) |
const |
Returns this color as a hex string.
The format is "#rrggbb"
when alpha is 255, or "#rrggbbaa"
otherwise.
- Returns
- this color as a hex string.
- Since
- 2020.1
◆ transparent()
static constexpr Color luciad::Color::transparent |
( |
| ) |
|
|
inlinestaticconstexpr |
The color transparent.
- Returns
- a transparent color.
◆ white()
static constexpr Color luciad::Color::white |
( |
| ) |
|
|
inlinestaticconstexpr |
The color white.
- Returns
- a white color.
◆ yellow()
static constexpr Color luciad::Color::yellow |
( |
| ) |
|
|
inlinestaticconstexpr |
The color yellow.
- Returns
- a yellow color.