Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Experimental::RColor Class Reference

The color class.

Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch
Sergey Linev S.Lin.nosp@m.ev@g.nosp@m.si.de
Date
2017-09-26
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

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_tAsRGBA () 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 RColorAutoColor ()
 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_tConvertNameToRGB (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>

Member Typedef Documentation

◆ RGB_t

using ROOT::Experimental::RColor::RGB_t = std::array<uint8_t, 3>
private

Definition at line 35 of file RColor.hxx.

Constructor & Destructor Documentation

◆ RColor() [1/6]

ROOT::Experimental::RColor::RColor ( )
default

◆ RColor() [2/6]

ROOT::Experimental::RColor::RColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inline

Construct color with provided r,g,b values.

Definition at line 53 of file RColor.hxx.

◆ RColor() [3/6]

ROOT::Experimental::RColor::RColor ( uint8_t  r,
uint8_t  g,
uint8_t  b,
float  alpha 
)
inline

Construct color with provided r,g,b and alpha values.

Definition at line 56 of file RColor.hxx.

◆ RColor() [4/6]

ROOT::Experimental::RColor::RColor ( const RGB_t rgb)
inline

Construct color with provided RGB_t value.

Definition at line 62 of file RColor.hxx.

◆ RColor() [5/6]

ROOT::Experimental::RColor::RColor ( const std::string &  color)
inline

Construct color with provided string

Definition at line 65 of file RColor.hxx.

◆ RColor() [6/6]

ROOT::Experimental::RColor::RColor ( float  ordinal)
inline

Construct color with provided ordinal value

Definition at line 68 of file RColor.hxx.

Member Function Documentation

◆ AsHex()

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.

◆ AsRGBA()

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.

◆ AsString()

const std::string & ROOT::Experimental::RColor::AsString ( ) const
inline

Returns color as it stored as string.

Definition at line 157 of file RColor.hxx.

◆ AsSVG()

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.

◆ AutoColor()

const RColor & RColor::AutoColor ( )
static

Set the color value from the Hue, Light, Saturation (HLS).

Definition at line 383 of file RColor.cxx.

◆ Clear()

void ROOT::Experimental::RColor::Clear ( )
inline

Definition at line 171 of file RColor.hxx.

◆ ConvertNameToRGB()

std::vector< uint8_t > RColor::ConvertNameToRGB ( const std::string &  name)
staticprivate

Converts string name of color in RGB value - when possible.

Definition at line 156 of file RColor.cxx.

◆ GetAlpha()

uint8_t ROOT::Experimental::RColor::GetAlpha ( ) const
inline

Returns color alpha (opacity) as uint8_t 0..255.

Definition at line 130 of file RColor.hxx.

◆ GetAlphaFloat()

float ROOT::Experimental::RColor::GetAlphaFloat ( ) const
inline

Returns color alpha (opacity) as float from 0..1.

Definition at line 137 of file RColor.hxx.

◆ GetBlue()

uint8_t ROOT::Experimental::RColor::GetBlue ( ) const
inline

Returns blue color component 0..255.

Definition at line 123 of file RColor.hxx.

◆ GetGreen()

uint8_t ROOT::Experimental::RColor::GetGreen ( ) const
inline

Returns green color component 0..255.

Definition at line 116 of file RColor.hxx.

◆ GetHLS()

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.

◆ GetOrdinal()

float RColor::GetOrdinal ( ) const

Return ordinal value, which was set before with SetOrdinal() call.

Definition at line 124 of file RColor.cxx.

◆ GetRed()

uint8_t ROOT::Experimental::RColor::GetRed ( ) const
inline

Returns red color component 0..255.

Definition at line 109 of file RColor.hxx.

◆ HasAlpha()

bool ROOT::Experimental::RColor::HasAlpha ( ) const
inline

Returns true if color alpha (opacity) was specified.

Definition at line 103 of file RColor.hxx.

◆ IsAuto()

bool RColor::IsAuto ( ) const

Returns true if color specified as auto color.

Definition at line 83 of file RColor.cxx.

◆ IsEmpty()

bool ROOT::Experimental::RColor::IsEmpty ( ) const
inline

Returns true if color is empty.

Definition at line 71 of file RColor.hxx.

◆ IsName()

bool RColor::IsName ( ) const

Returns true if color specified as name.

Definition at line 75 of file RColor.cxx.

◆ IsOrdinal()

bool RColor::IsOrdinal ( ) const

Returns if color codes ordinal value from palette.

Definition at line 91 of file RColor.cxx.

◆ IsRGB()

bool RColor::IsRGB ( ) const

returns true if color stored as RGB

Definition at line 42 of file RColor.cxx.

◆ IsRGBA()

bool RColor::IsRGBA ( ) const

returns true if color stored as RGBA

Definition at line 50 of file RColor.cxx.

◆ SetAlpha()

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.

◆ SetAlphaFloat()

void ROOT::Experimental::RColor::SetAlphaFloat ( float  alpha)
inline

Set alpha as float value from range 0..1.

Definition at line 92 of file RColor.hxx.

◆ SetAlphaHex()

bool RColor::SetAlphaHex ( const std::string &  hex)
private

Set Alpha value as hex.

Definition at line 263 of file RColor.cxx.

◆ SetColor()

void ROOT::Experimental::RColor::SetColor ( const std::string &  col)
inline

Set color as string.

Definition at line 160 of file RColor.hxx.

◆ SetHLS()

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.

◆ SetName()

bool ROOT::Experimental::RColor::SetName ( const std::string &  name)
inline

Set color as plain SVG name like "white" or "lightblue".

Definition at line 143 of file RColor.hxx.

◆ SetOrdinal()

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.

◆ SetRGB() [1/2]

void ROOT::Experimental::RColor::SetRGB ( const RGB_t rgb)
inline

Set r/g/b components of color.

Definition at line 80 of file RColor.hxx.

◆ SetRGB() [2/2]

void RColor::SetRGB ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set r/g/b components of color.

Set color as RGB.

Definition at line 58 of file RColor.cxx.

◆ SetRGBA()

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.

◆ SetRGBHex()

bool RColor::SetRGBHex ( const std::string &  hex)
private

Set RGB values as hex.

Definition at line 246 of file RColor.cxx.

◆ toHex()

std::string RColor::toHex ( uint8_t  v)
staticprivate

Converts integer from 0 to 255 into hex format with two digits like 00.

Definition at line 233 of file RColor.cxx.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const RColor lhs,
const RColor rhs 
)
friend

Definition at line 198 of file RColor.hxx.

Member Data Documentation

◆ fColor

std::string ROOT::Experimental::RColor::fColor
private

string representation of color

Definition at line 39 of file RColor.hxx.

◆ kAqua

constexpr RColor::RGB_t RColor::kAqua {{0, 0xFF, 0xFF}}
staticconstexpr

Definition at line 181 of file RColor.hxx.

◆ kBlack

constexpr RColor::RGB_t RColor::kBlack {{0, 0, 0}}
staticconstexpr

Definition at line 178 of file RColor.hxx.

◆ kBlue

constexpr RColor::RGB_t RColor::kBlue {{0, 0, 0xff}}
staticconstexpr

Definition at line 186 of file RColor.hxx.

◆ kFuchsia

constexpr RColor::RGB_t RColor::kFuchsia {{0xFF, 0, 0xFF}}
staticconstexpr

Definition at line 184 of file RColor.hxx.

◆ kGreen

constexpr RColor::RGB_t RColor::kGreen {{0, 0x80, 0}}
staticconstexpr

Definition at line 179 of file RColor.hxx.

◆ kGrey

constexpr RColor::RGB_t RColor::kGrey {{0x80, 0x80, 0x80}}
staticconstexpr

Definition at line 183 of file RColor.hxx.

◆ kLime

constexpr RColor::RGB_t RColor::kLime {{0, 0xFF, 0}}
staticconstexpr

Definition at line 180 of file RColor.hxx.

◆ kMaroon

constexpr RColor::RGB_t RColor::kMaroon {{0x80, 0, 0}}
staticconstexpr

Definition at line 190 of file RColor.hxx.

◆ kNavy

constexpr RColor::RGB_t RColor::kNavy {{0, 0, 0x80}}
staticconstexpr

Definition at line 185 of file RColor.hxx.

◆ kOlive

constexpr RColor::RGB_t RColor::kOlive {{0x80, 0x80, 0}}
staticconstexpr

Definition at line 188 of file RColor.hxx.

◆ kOpaque

constexpr float RColor::kOpaque {1.}
staticconstexpr

Definition at line 196 of file RColor.hxx.

◆ kPurple

constexpr RColor::RGB_t RColor::kPurple {{0x80, 0, 0x80}}
staticconstexpr

Definition at line 182 of file RColor.hxx.

◆ kRed

constexpr RColor::RGB_t RColor::kRed {{0xff, 0, 0}}
staticconstexpr

Definition at line 191 of file RColor.hxx.

◆ kSemiTransparent

constexpr float RColor::kSemiTransparent {0.5}
staticconstexpr

Definition at line 195 of file RColor.hxx.

◆ kSilver

constexpr RColor::RGB_t RColor::kSilver {{0xc0, 0xc0, 0xc0}}
staticconstexpr

Definition at line 189 of file RColor.hxx.

◆ kTeal

constexpr RColor::RGB_t RColor::kTeal {{0, 0x80, 0x80}}
staticconstexpr

Definition at line 187 of file RColor.hxx.

◆ kTransparent

constexpr float RColor::kTransparent {0.}
staticconstexpr

Definition at line 194 of file RColor.hxx.

◆ kWhite

constexpr RColor::RGB_t RColor::kWhite {{0xff, 0xff, 0xff}}
staticconstexpr

Definition at line 193 of file RColor.hxx.

◆ kYellow

constexpr RColor::RGB_t RColor::kYellow {{0xff, 0xff, 0}}
staticconstexpr

Definition at line 192 of file RColor.hxx.

Libraries for ROOT::Experimental::RColor:

The documentation for this class was generated from the following files: