qualpal::colors::RGB
C++ · cpp · 4.1.0
RGB color representation with values in [0,1] range.
Represents a color in the standard Red-Green-Blue (RGB) color space. All channel values are normalized to the range [0, 1].
Provides conversion constructors for HSL, XYZ, Lab, and LCHab color spaces. Also supports construction from hexadecimal color strings in "#RRGGBB" or "#RGB" format.
// Create RGB from normalized values
RGB ;
// Create from hex string (6-digit and 3-digit)
RGB ;
RGB ;
// Convert to hex
std::string hex = red.; // "#ff0000"Throws
std::invalid_argument
if hex string format is invalid.
See also
HSL, XYZ, Lab, LCHab for conversions.
Methods
RGB
RGB
Source: include/qualpal/colors.h
Default constructor initializes RGB to black (0,0,0).
RGB
Source: include/qualpal/colors.h
Parameters
hsl
HSL color to convert from
RGB
Source: include/qualpal/colors.h
Construct RGB from LCHab color.
Parameters
lch
LCHab color to convert from
RGB
Source: include/qualpal/colors.h
Parameters
lab
Lab color to convert from
RGB
Source: include/qualpal/colors.h
Parameters
xyz
XYZ color to convert from
RGB
Source: include/qualpal/colors.h
inline Construct RGB from hexadecimal color string literal.
Parameters
hex
Hex color string in format "#RRGGBB" or "#RGB"
Throws
std::invalid_argument
if hex format is invalid
RGB
Source: include/qualpal/colors.h
Construct RGB from normalized values.
Parameters
r
Red component [0,1]
g
Green component [0,1]
b
Blue component [0,1]
RGB
Source: include/qualpal/colors.h
Construct RGB from array of normalized values.
Parameters
rgb
Array containing [r, g, b] values in [0,1]
RGB
Source: include/qualpal/colors.h
Construct RGB from hexadecimal color string.
Parameters
hex
Hex color string in format "#RRGGBB" or "#RGB"
Throws
std::invalid_argument
if hex format is invalid
RGB ; // 6-digit format
RGB ; // 3-digit formatb
Source: include/qualpal/colors.h
inline double Get blue component [0,1].
g
Source: include/qualpal/colors.h
inline double Get green component [0,1].
hex
Source: include/qualpal/colors.h
std::string Convert RGB to hexadecimal string.
Returns
Hex color string in format "#rrggbb"
RGB ;
std::string hex = red.; // "#ff0000"operator!=
Source: include/qualpal/colors.h
inline bool Inequality operator for RGB colors.
Parameters
other
Other RGB color to compare with
Returns
true if RGB colors are not equal, false otherwise
operator==
Source: include/qualpal/colors.h
inline bool Equality operator for RGB colors.
Parameters
other
Other RGB color to compare with
Returns
true if both RGB colors are equal, false otherwise
r
Source: include/qualpal/colors.h
inline double Get red component [0,1].
