The color class.
Definition at line 33 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 &color) | |
Construct color with provided string | |
RColor (float ordinal) | |
Construct color with provided ordinal value | |
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. | |
const std::string & | AsString () const |
Returns color as it stored as string. | |
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. | |
float | GetOrdinal () const |
Return ordinal value, which was set before with SetOrdinal() call. | |
uint8_t | GetRed () const |
Returns red color component 0..255. | |
bool | HasAlpha () const |
Returns true if color alpha (opacity) was specified. | |
bool | IsAuto () const |
Returns true if color specified as auto color. | |
bool | IsEmpty () const |
Returns true if color is empty. | |
bool | IsName () const |
Returns true if color specified as name. | |
bool | IsOrdinal () const |
Returns if color codes ordinal value from palette. | |
bool | IsRGB () const |
returns true if color stored as RGB | |
bool | IsRGBA () const |
returns true if color stored as RGBA | |
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 | SetColor (const std::string &col) |
Set color as string. | |
void | SetHLS (float hue, float light, float satur) |
Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS). | |
bool | SetName (const std::string &name) |
Set color as plain SVG name like "white" or "lightblue". | |
void | SetOrdinal (float val) |
Set color as ordinal value from RPalette When object will be painted on the client side, actual color will be extracted from the RPalette Only 5 digits after . | |
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, uint8_t alpha) |
Set r/g/b/a components of color, a is integer between 0..255. | |
Static Public Member Functions | |
static const RColor & | AutoColor () |
Set the color value from the Hue, Light, Saturation (HLS). | |
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 std::vector< uint8_t > | ConvertNameToRGB (const std::string &name) |
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 | fColor |
string representation of color | |
Friends | |
bool | operator== (const RColor &lhs, const RColor &rhs) |
#include <ROOT/RColor.hxx>
|
private |
Definition at line 35 of file RColor.hxx.
|
default |
|
inline |
Construct color with provided r,g,b values.
Definition at line 53 of file RColor.hxx.
|
inline |
Construct color with provided r,g,b and alpha values.
Definition at line 56 of file RColor.hxx.
|
inline |
Construct color with provided RGB_t value.
Definition at line 62 of file RColor.hxx.
|
inline |
Construct color with provided string
Definition at line 65 of file RColor.hxx.
|
inline |
Construct color with provided ordinal value
Definition at line 68 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 275 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 197 of file RColor.cxx.
|
inline |
Returns color as it stored as string.
Definition at line 157 of file RColor.hxx.
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 291 of file RColor.cxx.
|
static |
Set the color value from the Hue, Light, Saturation (HLS).
Definition at line 383 of file RColor.cxx.
|
inline |
Definition at line 171 of file RColor.hxx.
|
staticprivate |
Converts string name of color in RGB value - when possible.
Definition at line 156 of file RColor.cxx.
|
inline |
Returns color alpha (opacity) as uint8_t 0..255.
Definition at line 130 of file RColor.hxx.
|
inline |
Returns color alpha (opacity) as float from 0..1.
Definition at line 137 of file RColor.hxx.
|
inline |
Returns blue color component 0..255.
Definition at line 123 of file RColor.hxx.
|
inline |
Returns green color component 0..255.
Definition at line 116 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 304 of file RColor.cxx.
float RColor::GetOrdinal | ( | ) | const |
Return ordinal value, which was set before with SetOrdinal() call.
Definition at line 124 of file RColor.cxx.
|
inline |
Returns red color component 0..255.
Definition at line 109 of file RColor.hxx.
|
inline |
Returns true if color alpha (opacity) was specified.
Definition at line 103 of file RColor.hxx.
bool RColor::IsAuto | ( | ) | const |
Returns true if color specified as auto color.
Definition at line 83 of file RColor.cxx.
|
inline |
Returns true if color is empty.
Definition at line 71 of file RColor.hxx.
bool RColor::IsName | ( | ) | const |
Returns true if color specified as name.
Definition at line 75 of file RColor.cxx.
bool RColor::IsOrdinal | ( | ) | const |
Returns if color codes ordinal value from palette.
Definition at line 91 of file RColor.cxx.
bool RColor::IsRGB | ( | ) | const |
returns true if color stored as RGB
Definition at line 42 of file RColor.cxx.
bool RColor::IsRGBA | ( | ) | const |
returns true if color stored as RGBA
Definition at line 50 of file RColor.cxx.
void RColor::SetAlpha | ( | uint8_t | alpha | ) |
Set alpha as value from range 0..255.
Set color alpha, can only be done if real color was assigned before.
Definition at line 133 of file RColor.cxx.
|
inline |
Set alpha as float value from range 0..1.
Definition at line 92 of file RColor.hxx.
|
private |
Set Alpha value as hex.
Definition at line 263 of file RColor.cxx.
|
inline |
Set color as string.
Definition at line 160 of file RColor.hxx.
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 351 of file RColor.cxx.
|
inline |
Set color as plain SVG name like "white" or "lightblue".
Definition at line 143 of file RColor.hxx.
void RColor::SetOrdinal | ( | float | val | ) |
Set color as ordinal value from RPalette When object will be painted on the client side, actual color will be extracted from the RPalette Only 5 digits after .
are stored
Definition at line 103 of file RColor.cxx.
|
inline |
Set r/g/b components of color.
Definition at line 80 of file RColor.hxx.
void RColor::SetRGB | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b | ||
) |
void RColor::SetRGBA | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
uint8_t | alpha | ||
) |
Set r/g/b/a components of color, a is integer between 0..255.
Set color as RGB.
Definition at line 66 of file RColor.cxx.
|
private |
Set RGB values as hex.
Definition at line 246 of file RColor.cxx.
|
staticprivate |
Converts integer from 0 to 255 into hex format with two digits like 00.
Definition at line 233 of file RColor.cxx.
Definition at line 198 of file RColor.hxx.
|
private |
string representation of color
Definition at line 39 of file RColor.hxx.
|
staticconstexpr |
Definition at line 181 of file RColor.hxx.
|
staticconstexpr |
Definition at line 178 of file RColor.hxx.
|
staticconstexpr |
Definition at line 186 of file RColor.hxx.
|
staticconstexpr |
Definition at line 184 of file RColor.hxx.
|
staticconstexpr |
Definition at line 179 of file RColor.hxx.
|
staticconstexpr |
Definition at line 183 of file RColor.hxx.
|
staticconstexpr |
Definition at line 180 of file RColor.hxx.
|
staticconstexpr |
Definition at line 190 of file RColor.hxx.
|
staticconstexpr |
Definition at line 185 of file RColor.hxx.
|
staticconstexpr |
Definition at line 188 of file RColor.hxx.
|
staticconstexpr |
Definition at line 196 of file RColor.hxx.
|
staticconstexpr |
Definition at line 182 of file RColor.hxx.
|
staticconstexpr |
Definition at line 191 of file RColor.hxx.
|
staticconstexpr |
Definition at line 195 of file RColor.hxx.
|
staticconstexpr |
Definition at line 189 of file RColor.hxx.
|
staticconstexpr |
Definition at line 187 of file RColor.hxx.
|
staticconstexpr |
Definition at line 194 of file RColor.hxx.
|
staticconstexpr |
Definition at line 193 of file RColor.hxx.
|
staticconstexpr |
Definition at line 192 of file RColor.hxx.