The color class.
Definition at line 34 of file RColor.hxx.
Public Member Functions | |
RColor ()=default | |
RColor (const RGB_t &rgb) | |
Construct color with provided RGB_t value. More... | |
RColor (const std::string &name) | |
Construct color with provided name. More... | |
RColor (uint8_t r, uint8_t g, uint8_t b) | |
Construct color with provided r,g,b values. More... | |
RColor (uint8_t r, uint8_t g, uint8_t b, float alpha) | |
Construct color with provided r,g,b and alpha values. More... | |
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. More... | |
std::vector< uint8_t > | AsRGBA () const |
Returns color as RGBA array, trying also convert color name into RGBA value. More... | |
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. More... | |
void | Clear () |
uint8_t | GetAlpha () const |
Returns color alpha (opacity) as uint8_t 0..255. More... | |
float | GetAlphaFloat () const |
Returns color alpha (opacity) as float from 0..1. More... | |
uint8_t | GetBlue () const |
Returns blue color component 0..255. More... | |
uint8_t | GetGreen () const |
Returns green color component 0..255. More... | |
bool | GetHLS (float &hue, float &light, float &satur) const |
Return the Hue, Light, Saturation (HLS) definition of this RColor. More... | |
const std::string & | GetName () const |
Returns color as plain SVG name like "white" or "lightblue". More... | |
uint8_t | GetRed () const |
Returns red color component 0..255. More... | |
const std::vector< uint8_t > & | GetRGBA () const |
Returns color as RGBA array - when exists. More... | |
bool | HasAlpha () const |
Returns true if color alpha (opacity) was specified. More... | |
bool | IsEmpty () const |
Returns true if no color is specified. More... | |
void | SetAlpha (uint8_t alpha) |
Set alpha as value from range 0..255. More... | |
void | SetAlphaFloat (float alpha) |
Set alpha as float value from range 0..1. More... | |
void | SetHLS (float hue, float light, float satur) |
Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS). More... | |
RColor & | SetName (const std::string &name) |
Set color as plain SVG name like "white" or "lightblue". More... | |
void | SetRGB (const RGB_t &rgb) |
Set r/g/b components of color. More... | |
void | SetRGB (uint8_t r, uint8_t g, uint8_t b) |
Set r/g/b components of color. More... | |
void | SetRGBA (uint8_t r, uint8_t g, uint8_t b, uint8_t alpha) |
Set r/g/b/a components of color. More... | |
Static Public Attributes | |
static constexpr RGB_t | kAqua {{0, 0xFF, 0xFF}} |
static constexpr RGB_t | kBlack {{0, 0, 0}} |
static constexpr RGB_t | kBlue {{0, 0, 0xff}} |
static constexpr RGB_t | kFuchsia {{0xFF, 0, 0xFF}} |
static constexpr RGB_t | kGreen {{0, 0x80, 0}} |
static constexpr RGB_t | kGrey {{0x80, 0x80, 0x80}} |
static constexpr RGB_t | kLime {{0, 0xFF, 0}} |
static constexpr RGB_t | kMaroon {{0x80, 0, 0}} |
static constexpr RGB_t | kNavy {{0, 0, 0x80}} |
static constexpr RGB_t | kOlive {{0x80, 0x80, 0}} |
static constexpr float | kOpaque {1.} |
static constexpr RGB_t | kPurple {{0x80, 0, 0x80}} |
static constexpr RGB_t | kRed {{0xff, 0, 0}} |
static constexpr float | kSemiTransparent {0.5} |
static constexpr RGB_t | kSilver {{0xc0, 0xc0, 0xc0}} |
static constexpr RGB_t | kTeal {{0, 0x80, 0x80}} |
static constexpr float | kTransparent {0.} |
static constexpr RGB_t | kWhite {{0xff, 0xff, 0xff}} |
static 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. More... | |
bool | SetRGBHex (const std::string &hex) |
Set RGB values as hex. More... | |
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. More... | |
static std::string | toHex (uint8_t v) |
Converts integer from 0 to 255 into hex format with two digits like 00. More... | |
Private Attributes | |
std::string | fName |
name of color - if any More... | |
std::vector< uint8_t > | fRGBA |
RGB + Alpha. More... | |
Friends | |
bool | operator== (const RColor &lhs, const RColor &rhs) |
class | RAttrColor |
#include <ROOT/RColor.hxx>
|
private |
Definition at line 38 of file RColor.hxx.
|
default |
Construct color with provided r,g,b values.
Definition at line 57 of file RColor.hxx.
Construct color with provided r,g,b and alpha values.
Definition at line 60 of file RColor.hxx.
|
inline |
Construct color with provided RGB_t value.
Definition at line 66 of file RColor.hxx.
|
inline |
Construct color with provided name.
Definition at line 69 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 200 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 162 of file RColor.hxx.
|
inline |
Returns color alpha (opacity) as float from 0..1.
Definition at line 175 of file RColor.hxx.
|
inline |
Returns blue color component 0..255.
Definition at line 152 of file RColor.hxx.
|
inline |
Returns green color component 0..255.
Definition at line 142 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 189 of file RColor.hxx.
|
inline |
Returns red color component 0..255.
Definition at line 132 of file RColor.hxx.
|
inline |
Returns color as RGBA array - when exists.
Definition at line 126 of file RColor.hxx.
|
inline |
Returns true if color alpha (opacity) was specified.
Definition at line 120 of file RColor.hxx.
|
inline |
Returns true if no color is specified.
Definition at line 123 of file RColor.hxx.
Set alpha as value from range 0..255.
Definition at line 106 of file RColor.hxx.
|
inline |
Set alpha as float value from range 0..1.
Definition at line 95 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 181 of file RColor.hxx.
Set r/g/b components of color.
Definition at line 72 of file RColor.hxx.
Set r/g/b components of color.
Definition at line 75 of file RColor.hxx.
Set r/g/b/a components of color.
Definition at line 86 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 226 of file RColor.hxx.
|
friend |
Definition at line 36 of file RColor.hxx.
|
private |
name of color - if any
Definition at line 43 of file RColor.hxx.
|
private |
RGB + Alpha.
Definition at line 42 of file RColor.hxx.
|
staticconstexpr |
Definition at line 209 of file RColor.hxx.
|
staticconstexpr |
Definition at line 206 of file RColor.hxx.
|
staticconstexpr |
Definition at line 214 of file RColor.hxx.
|
staticconstexpr |
Definition at line 212 of file RColor.hxx.
|
staticconstexpr |
Definition at line 207 of file RColor.hxx.
|
staticconstexpr |
Definition at line 211 of file RColor.hxx.
|
staticconstexpr |
Definition at line 208 of file RColor.hxx.
|
staticconstexpr |
Definition at line 218 of file RColor.hxx.
|
staticconstexpr |
Definition at line 213 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 210 of file RColor.hxx.
|
staticconstexpr |
Definition at line 219 of file RColor.hxx.
|
staticconstexpr |
Definition at line 223 of file RColor.hxx.
|
staticconstexpr |
Definition at line 217 of file RColor.hxx.
|
staticconstexpr |
Definition at line 215 of file RColor.hxx.
|
staticconstexpr |
Definition at line 222 of file RColor.hxx.
|
staticconstexpr |
Definition at line 221 of file RColor.hxx.
|
staticconstexpr |
Definition at line 220 of file RColor.hxx.