RGB color representation with values in [0,1] range.
More...
#include <colors.h>
|
| RGB () |
| Default constructor initializes RGB to black (0,0,0)
|
|
| RGB (const double r, const double g, const double b) |
| Construct RGB from normalized values.
|
|
| RGB (const std::array< double, 3 > rgb) |
| Construct RGB from array of normalized values.
|
|
| RGB (const std::string &hex) |
| Construct RGB from hexadecimal color string.
|
|
| RGB (const HSL &hsl) |
| Construct RGB from HSL color.
|
|
| RGB (const XYZ &xyz) |
| Construct RGB from XYZ color.
|
|
| RGB (const Lab &lab) |
| Construct RGB from Lab color.
|
|
| RGB (const LCHab &lch) |
| Construct RGB from LCHab color.
|
|
bool | operator== (const RGB &other) const |
| Equality operator for RGB colors.
|
|
bool | operator!= (const RGB &other) const |
| Inequality operator for RGB colors.
|
|
std::string | hex () const |
| Convert RGB to hexadecimal string.
|
|
double | r () const |
| Get red component [0,1].
|
|
double | g () const |
| Get green component [0,1].
|
|
double | b () const |
| Get blue component [0,1].
|
|
RGB color representation with values in [0,1] range.
The RGB class provides conversion between RGB and other color spaces including HSL, XYZ, and Lab. All RGB values are normalized to [0,1].
std::string
hex = red.hex();
RGB color representation with values in [0,1] range.
std::string hex() const
Convert RGB to hexadecimal string.
Definition at line 83 of file colors.h.
◆ RGB() [1/7]
qualpal::colors::RGB::RGB |
( |
const double |
r, |
|
|
const double |
g, |
|
|
const double |
b |
|
) |
| |
Construct RGB from normalized values.
- Parameters
-
r | Red component [0,1] |
g | Green component [0,1] |
b | Blue component [0,1] |
◆ RGB() [2/7]
qualpal::colors::RGB::RGB |
( |
const std::array< double, 3 > |
rgb | ) |
|
Construct RGB from array of normalized values.
- Parameters
-
rgb | Array containing [r, g, b] values in [0,1] |
◆ RGB() [3/7]
qualpal::colors::RGB::RGB |
( |
const std::string & |
hex | ) |
|
Construct RGB from hexadecimal color string.
- Parameters
-
hex | Hex color string in format "#RRGGBB" or "#RGB" |
- Exceptions
-
std::invalid_argument | if hex format is invalid |
◆ RGB() [4/7]
qualpal::colors::RGB::RGB |
( |
const HSL & |
hsl | ) |
|
Construct RGB from HSL color.
- Parameters
-
hsl | HSL color to convert from |
◆ RGB() [5/7]
qualpal::colors::RGB::RGB |
( |
const XYZ & |
xyz | ) |
|
Construct RGB from XYZ color.
- Parameters
-
xyz | XYZ color to convert from |
◆ RGB() [6/7]
qualpal::colors::RGB::RGB |
( |
const Lab & |
lab | ) |
|
Construct RGB from Lab color.
- Parameters
-
lab | Lab color to convert from |
◆ RGB() [7/7]
qualpal::colors::RGB::RGB |
( |
const LCHab & |
lch | ) |
|
Construct RGB from LCHab color.
- Parameters
-
lch | LCHab color to convert from |
◆ b()
double qualpal::colors::RGB::b |
( |
| ) |
const |
|
inline |
Get blue component [0,1].
Definition at line 180 of file colors.h.
◆ g()
double qualpal::colors::RGB::g |
( |
| ) |
const |
|
inline |
Get green component [0,1].
Definition at line 178 of file colors.h.
◆ hex()
std::string qualpal::colors::RGB::hex |
( |
| ) |
const |
Convert RGB to hexadecimal string.
- Returns
- Hex color string in format "#rrggbb"
std::string
hex = red.hex();
◆ operator!=()
bool qualpal::colors::RGB::operator!= |
( |
const RGB & |
other | ) |
const |
|
inline |
Inequality operator for RGB colors.
- Parameters
-
other | Other RGB color to compare with |
- Returns
- true if RGB colors are not equal, false otherwise
Definition at line 162 of file colors.h.
◆ operator==()
bool qualpal::colors::RGB::operator== |
( |
const RGB & |
other | ) |
const |
|
inline |
Equality operator for RGB colors.
- Parameters
-
other | Other RGB color to compare with |
- Returns
- true if both RGB colors are equal, false otherwise
Definition at line 151 of file colors.h.
◆ r()
double qualpal::colors::RGB::r |
( |
| ) |
const |
|
inline |
Get red component [0,1].
Definition at line 176 of file colors.h.
The documentation for this class was generated from the following file: