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 | black (float alpha=1.) |
Black color. | |
static Color | white (float alpha=1.) |
White color. | |
static Color | green (float alpha=1.) |
Green color. | |
static Color | blue (float alpha=1.) |
Blue color. | |
static Color | cyan (float alpha=1.) |
Cyan color. | |
static Color | yellow (float alpha=1.) |
Yellow color. | |
static Color | red (float alpha=1.) |
Red color. | |
static Color | dark_gray (float alpha=1.) |
Dark gray color. | |
static Color | purple (float alpha=1.) |
Light gray color. | |
static Color | dark_green (float alpha=1.) |
Dark green color. | |
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.
|
inlinestatic |
Black color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
White color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Green color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Blue color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Cyan color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Yellow color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Red color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Dark gray color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Light gray color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |
|
inlinestatic |
Dark green color.
alpha | Alpha value between 0. (transparent) and 1. (opaque) |