The color class.
Definition at line 35 of file RColor.hxx.
Public Member Functions | |
RColor ()=default | |
RColor (const RGB_t &rgb) | |
Construct color with provided RGB_t value. | |
RColor (const std::string &name) | |
Construct color with provided name. | |
RColor (uint8_t r, uint8_t g, uint8_t b) | |
Construct color with provided r,g,b values. | |
RColor (uint8_t r, uint8_t g, uint8_t b, float alpha) | |
Construct color with provided r,g,b and alpha values. | |
std::string | AsHex (bool with_alpha=false) const |
Returns color value in hex format like "66FF66" - without any prefix Alpha parameter can be optionally included. | |
std::vector< uint8_t > | AsRGBA () const |
Returns color as RGBA array, trying also convert color name into RGBA value. | |
std::string | AsSVG () const |
Returns color value as it will be used in SVG drawing It either include hex format #66FF66 or just plain SVG name. | |
void | Clear () |
uint8_t | GetAlpha () const |
Returns color alpha (opacity) as uint8_t 0..255. | |
float | GetAlphaFloat () const |
Returns color alpha (opacity) as float from 0..1. | |
uint8_t | GetBlue () const |
Returns blue color component 0..255. | |
uint8_t | GetGreen () const |
Returns green color component 0..255. | |
bool | GetHLS (float &hue, float &light, float &satur) const |
Return the Hue, Light, Saturation (HLS) definition of this RColor. | |
const std::string & | GetName () const |
Returns color as plain SVG name like "white" or "lightblue". | |
uint8_t | GetRed () const |
Returns red color component 0..255. | |
const std::vector< uint8_t > & | GetRGBA () const |
Returns color as RGBA array - when exists. | |
bool | HasAlpha () const |
Returns true if color alpha (opacity) was specified. | |
bool | IsEmpty () const |
Returns true if no color is specified. | |
void | SetAlpha (uint8_t alpha) |
Set alpha as value from range 0..255. | |
void | SetAlphaFloat (float alpha) |
Set alpha as float value from range 0..1. | |
void | SetHLS (float hue, float light, float satur) |
Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS). | |
RColor & | SetName (const std::string &name) |
Set color as plain SVG name like "white" or "lightblue". | |
void | SetRGB (const RGB_t &rgb) |
Set r/g/b components of color. | |
void | SetRGB (uint8_t r, uint8_t g, uint8_t b) |
Set r/g/b components of color. | |
void | SetRGBA (uint8_t r, uint8_t g, uint8_t b, float alpha) |
Set r/g/b/a components of color. | |
void | SetRGBA (uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) |
Set r/g/b/a components of color. | |
Static Public Attributes | |
static R__DLLEXPORT constexpr RGB_t | kAqua {{0, 0xFF, 0xFF}} |
static R__DLLEXPORT constexpr RGB_t | kBlack {{0, 0, 0}} |
static R__DLLEXPORT constexpr RGB_t | kBlue {{0, 0, 0xff}} |
static R__DLLEXPORT constexpr RGB_t | kFuchsia {{0xFF, 0, 0xFF}} |
static R__DLLEXPORT constexpr RGB_t | kGreen {{0, 0x80, 0}} |
static R__DLLEXPORT constexpr RGB_t | kGrey {{0x80, 0x80, 0x80}} |
static R__DLLEXPORT constexpr RGB_t | kLime {{0, 0xFF, 0}} |
static R__DLLEXPORT constexpr RGB_t | kMaroon {{0x80, 0, 0}} |
static R__DLLEXPORT constexpr RGB_t | kNavy {{0, 0, 0x80}} |
static R__DLLEXPORT constexpr RGB_t | kOlive {{0x80, 0x80, 0}} |
static R__DLLEXPORT constexpr float | kOpaque {1.} |
static R__DLLEXPORT constexpr RGB_t | kPurple {{0x80, 0, 0x80}} |
static R__DLLEXPORT constexpr RGB_t | kRed {{0xff, 0, 0}} |
static R__DLLEXPORT constexpr float | kSemiTransparent {0.5} |
static R__DLLEXPORT constexpr RGB_t | kSilver {{0xc0, 0xc0, 0xc0}} |
static R__DLLEXPORT constexpr RGB_t | kTeal {{0, 0x80, 0x80}} |
static R__DLLEXPORT constexpr float | kTransparent {0.} |
static R__DLLEXPORT constexpr RGB_t | kWhite {{0xff, 0xff, 0xff}} |
static R__DLLEXPORT constexpr RGB_t | kYellow {{0xff, 0xff, 0}} |
Private Types | |
using | RGB_t = std::array< uint8_t, 3 > |
Private Member Functions | |
bool | SetAlphaHex (const std::string &hex) |
Set Alpha value as hex. | |
bool | SetRGBHex (const std::string &hex) |
Set RGB values as hex. | |
Static Private Member Functions | |
static bool | ConvertToRGB (const std::string &name, std::vector< uint8_t > &rgba) |
Converts string name of color in RGB value - when possible. | |
static std::string | toHex (uint8_t v) |
Converts integer from 0 to 255 into hex format with two digits like 00. | |
Private Attributes | |
std::string | fName |
name of color - if any | |
std::vector< uint8_t > | fRGBA |
RGB + Alpha. | |
Friends | |
bool | operator== (const RColor &lhs, const RColor &rhs) |
class | RAttrColor |
#include <ROOT/RColor.hxx>
|
private |
Definition at line 39 of file RColor.hxx.
|
default |
Construct color with provided r,g,b values.
Definition at line 58 of file RColor.hxx.
Construct color with provided r,g,b and alpha values.
Definition at line 61 of file RColor.hxx.
|
inline |
Construct color with provided RGB_t value.
Definition at line 67 of file RColor.hxx.
|
inline |
Construct color with provided name.
Definition at line 70 of file RColor.hxx.
std::string RColor::AsHex | ( | bool | with_alpha = false | ) | const |
Returns color value in hex format like "66FF66" - without any prefix Alpha parameter can be optionally included.
Definition at line 162 of file RColor.cxx.
std::vector< uint8_t > RColor::AsRGBA | ( | ) | const |
Returns color as RGBA array, trying also convert color name into RGBA value.
Returns color as RGBA array, includes optionally alpha parameter 0..255.
Definition at line 146 of file RColor.cxx.
std::string RColor::AsSVG | ( | ) | const |
Returns color value as it will be used in SVG drawing It either include hex format #66FF66 or just plain SVG name.
Definition at line 178 of file RColor.cxx.
|
inline |
Definition at line 210 of file RColor.hxx.
Converts string name of color in RGB value - when possible.
Definition at line 41 of file RColor.cxx.
|
inline |
Returns color alpha (opacity) as uint8_t 0..255.
Definition at line 172 of file RColor.hxx.
|
inline |
Returns color alpha (opacity) as float from 0..1.
Definition at line 185 of file RColor.hxx.
|
inline |
Returns blue color component 0..255.
Definition at line 162 of file RColor.hxx.
|
inline |
Returns green color component 0..255.
Definition at line 152 of file RColor.hxx.
bool RColor::GetHLS | ( | float & | hue, |
float & | light, | ||
float & | satur | ||
) | const |
Return the Hue, Light, Saturation (HLS) definition of this RColor.
Returns the Hue, Light, Saturation (HLS) definition of this RColor If color was not specified as hex, method returns false.
Definition at line 193 of file RColor.cxx.
|
inline |
Returns color as plain SVG name like "white" or "lightblue".
Definition at line 199 of file RColor.hxx.
|
inline |
Returns red color component 0..255.
Definition at line 142 of file RColor.hxx.
|
inline |
Returns color as RGBA array - when exists.
Definition at line 136 of file RColor.hxx.
|
inline |
Returns true if color alpha (opacity) was specified.
Definition at line 130 of file RColor.hxx.
|
inline |
Returns true if no color is specified.
Definition at line 133 of file RColor.hxx.
Set alpha as value from range 0..255.
Definition at line 116 of file RColor.hxx.
|
inline |
Set alpha as float value from range 0..1.
Definition at line 105 of file RColor.hxx.
|
private |
Set Alpha value as hex.
Definition at line 135 of file RColor.cxx.
void RColor::SetHLS | ( | float | hue, |
float | light, | ||
float | satur | ||
) |
Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS).
Set the color value from the Hue, Light, Saturation (HLS).
Definition at line 240 of file RColor.cxx.
|
inline |
Set color as plain SVG name like "white" or "lightblue".
Clears RGB component before
Definition at line 191 of file RColor.hxx.
Set r/g/b components of color.
Definition at line 73 of file RColor.hxx.
Set r/g/b components of color.
Definition at line 76 of file RColor.hxx.
Set r/g/b/a components of color.
Definition at line 96 of file RColor.hxx.
Set r/g/b/a components of color.
Definition at line 87 of file RColor.hxx.
|
private |
Set RGB values as hex.
Definition at line 118 of file RColor.cxx.
|
staticprivate |
Converts integer from 0 to 255 into hex format with two digits like 00.
Definition at line 105 of file RColor.cxx.
Definition at line 236 of file RColor.hxx.
|
friend |
Definition at line 37 of file RColor.hxx.
|
private |
name of color - if any
Definition at line 44 of file RColor.hxx.
|
private |
RGB + Alpha.
Definition at line 43 of file RColor.hxx.
|
staticconstexpr |
Definition at line 219 of file RColor.hxx.
|
staticconstexpr |
Definition at line 216 of file RColor.hxx.
|
staticconstexpr |
Definition at line 224 of file RColor.hxx.
|
staticconstexpr |
Definition at line 222 of file RColor.hxx.
|
staticconstexpr |
Definition at line 217 of file RColor.hxx.
|
staticconstexpr |
Definition at line 221 of file RColor.hxx.
|
staticconstexpr |
Definition at line 218 of file RColor.hxx.
|
staticconstexpr |
Definition at line 228 of file RColor.hxx.
|
staticconstexpr |
Definition at line 223 of file RColor.hxx.
|
staticconstexpr |
Definition at line 226 of file RColor.hxx.
|
staticconstexpr |
Definition at line 234 of file RColor.hxx.
|
staticconstexpr |
Definition at line 220 of file RColor.hxx.
|
staticconstexpr |
Definition at line 229 of file RColor.hxx.
|
staticconstexpr |
Definition at line 233 of file RColor.hxx.
|
staticconstexpr |
Definition at line 227 of file RColor.hxx.
|
staticconstexpr |
Definition at line 225 of file RColor.hxx.
|
staticconstexpr |
Definition at line 232 of file RColor.hxx.
|
staticconstexpr |
Definition at line 231 of file RColor.hxx.
|
staticconstexpr |
Definition at line 230 of file RColor.hxx.