codac 2.0.0
|
Color structure, in RGBA or HSVA format. More...
#include <codac2_Color.h>
Public Member Functions | |
Color () | |
Default constructor. | |
Color (const std::array< float, 3 > &xyz, Model m_=Model::RGB) | |
Constructor from an array of 3 floats. | |
Color (const std::array< float, 4 > &xyza, Model m_=Model::RGB) | |
Constructor from an array of 4 floats. | |
Color (const std::initializer_list< float > xyza, Model m_=Model::RGB) | |
Constructor from an initializer list of floats. | |
Color (const std::string &hex_str) | |
Constructor from a hex string. | |
const Model & | model () const |
Getter for the color model. | |
std::string | hex_str () const |
Converts the color to a hex string in html format. | |
codac2::Vector | vec () const |
Converts the color to a codac2::Vector. | |
Color | rgb () const |
Converts the color to RGB format. | |
Color | hsv () const |
Converts the color to HSV format. | |
Static Public Member Functions | |
static Color | none () |
Empty color (transparent white) | |
static Color | random () |
Random color (full opacity) | |
Color structure, in RGBA or HSVA format.
This class is used to represent a Color, either in RGBA or HSVA format. It inherits from std::array<float,4> and provides methods to convert between different color models.
For RGBA, the values are in the range [0,255].
For HSVA, the values are in the range [0,360] for hue and [0,100] for saturation, value and alpha.
Predefined Colors are also available.
|
explicit |
Default constructor.
All values are set to 0
|
explicit |
Constructor from an array of 3 floats.
xyz | Array of 3 floats (RGB or HSV values) |
m_ | Color model (RGB or HSV) |
|
explicit |
Constructor from an array of 4 floats.
xyza | Array of 4 floats (RGBA or HSVA values) |
m_ | Color model (RGB or HSV) |
|
explicit |
Constructor from an initializer list of floats.
xyza | Initializer list of floats (RGB, RGBA, HSV or HSVA values) |
m_ | Color model (RGB or HSV) |
|
explicit |
Constructor from a hex string.
hex_str | Hex string in html format (e.g. #ff0000 or #ff0000ff) |
|
inline |
Getter for the color model.
std::string codac2::Color::hex_str | ( | ) | const |
Converts the color to a hex string in html format.
codac2::Vector codac2::Color::vec | ( | ) | const |
Converts the color to a codac2::Vector.