Logo ROOT  
Reference Guide
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 32 of file RColor.hxx.

Public Member Functions

 RColor (const RGB_t &rgb)
 Construct color with provided RGB_t value. More...
 
 RColor (int r, int g, int b)
 Construct color with provided r,g,b values. More...
 
 RColor (int r, int g, int b, float alpha)
 Construct color with provided r,g,b and alpha values. 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 ()
 
void ClearAlpha ()
 Clear alpha value of the color. More...
 
void ClearAuto ()
 Clear auto flag of the RColor. More...
 
void ClearName ()
 Clear color plain SVG name (if any) More...
 
void ClearRGB ()
 Clear RGB color value (if any) More...
 
float GetAlpha () const
 Returns color alpha (opacity) as float from 0. More...
 
std::string GetAlphaHex () const
 Returns color alpha (opacity) as hex string like FF. More...
 
int GetBlue () const
 Returns blue color component 0..255. More...
 
int GetGreen () const
 Returns green color component 0..255. More...
 
std::string GetHex () const
 Return color as hex string like 00FF00. More...
 
bool GetHLS (float &hue, float &light, float &satur) const
 Return the Hue, Light, Saturation (HLS) definition of this RColor. More...
 
std::string GetName () const
 Returns color as plain SVG name like "white" or "lightblue". More...
 
int GetRed () const
 Returns red color component 0..255. More...
 
bool GetRGB (int &r, int &g, int &b) const
 Decodes hex color value into RGB - each color component as integer from 0 to 255 If color was not specified as hex, method returns false. More...
 
bool HasAlpha () const
 Returns true if color alpha (opacity) was specified. More...
 
bool IsAuto () const
 Returns true if color should get auto value when primitive drawing is performed. More...
 
RColorSetAlpha (float _alpha)
 Set color alpha (opacity) value - from 0 to 1. More...
 
RColorSetAlphaHex (const std::string &_alfa)
 Set color alpha (opacity) value as hex string. More...
 
RColorSetAuto (bool on=true)
 Set automatic mode for RColor, will be assigned before primitive painted on the canvas. More...
 
RColorSetHex (const std::string &_hex)
 Set color as hex string like 00FF00. More...
 
RColorSetHLS (float hue, float light, float satur)
 Set the Red Green and Blue (RGB) values from the Hue, Light, Saturation (HLS). More...
 
RColorSetName (const std::string &_name)
 Set color as plain SVG name like "white" or "lightblue". More...
 
RColorSetRGB (const RGB_t &rgb)
 Set r/g/b/ components of color as hex code, default for the color. More...
 
RColorSetRGB (int r, int g, int b)
 Set r/g/b/ components of color as hex code, default for the color. More...
 
- Public Member Functions inherited from ROOT::Experimental::RAttrBase
 RAttrBase ()=default
 
virtual ~RAttrBase ()=default
 

Static Public Attributes

static constexpr RGB_t kBlack {{0, 0, 0}}
 
static constexpr RGB_t kBlue {{0, 0, 255}}
 
static constexpr RGB_t kGreen {{0, 255, 0}}
 
static constexpr double kOpaque {1.}
 
static constexpr RGB_t kRed {{255, 0, 0}}
 
static constexpr double kTransparent {0.}
 
static constexpr RGB_t kWhite {{255, 255, 255}}
 

Private Types

using RGB_t = std::array< int, 3 >
 

Private Member Functions

int GetColorComponent (int indx) const
 Decodes color component and returns integer from 0 to 255 Values of indx 0: Red, 1: Green, 2: Blue If color was not specified as hex, method returns 0. More...
 
bool GetRGBFloat (float &r, float &g, float &b) const
 Decodes hex color value into RGB - each color component as float from 0. More...
 
 R__ATTR_CLASS (RColor, "color_", AddString("rgb", "").AddString("a", "").AddString("name", "").AddBool("auto", false))
 
RColorSetRGBFloat (float r, float g, float b)
 Set RGB values as floats, each from 0..1. More...
 

Static Private Member Functions

static std::string toHex (int v)
 Converts integer from 0 to 255 into hex format with two digits like 00. More...
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from ROOT::Experimental::RAttrBase
 RAttrBase (const RAttrBase &src)
 
 RAttrBase (RAttrBase *parent, const std::string &prefix)
 
 RAttrBase (RDrawable *drawable, const std::string &prefix)
 
const Rec_t AccessAttr (const std::string &name) const
 Find attributes container and full-qualified name for value. More...
 
const Val_t AccessValue (const std::string &name, bool use_style=true) const
 
void AssignDrawable (RDrawable *drawable, const std::string &prefix)
 Return value from attributes container - no style or defaults are used. More...
 
void AssignParent (RAttrBase *parent, const std::string &prefix)
 
void Clear ()
 Clear all respective values from drawable. More...
 
void ClearValue (const std::string &name)
 
void CopyTo (RAttrBase &tgt, bool use_style=true) const
 Copy attributes into target object. More...
 
bool CopyValue (const std::string &name, const RAttrMap::Value_t &value, bool check_type=true)
 Copy attributes from other object. More...
 
Rec_t EnsureAttr (const std::string &name)
 Ensure attribute with give name exists - creates container for attributes if required. More...
 
template<typename RET_TYPE , typename MATCH_TYPE = void>
auto Eval (const std::string &name, bool use_dflts=true) const
 Evaluate attribute value. More...
 
virtual const RAttrMapGetDefaults () const
 Return default values for attributes, empty for base class. More...
 
const std::string & GetPrefix () const
 
template<typename T >
GetValue (const std::string &name) const
 
template<typename T = void>
bool HasValue (const std::string &name, bool check_defaults=false) const
 
bool IsSame (const RAttrBase &src, bool use_style=true) const
 Check if all values which are evaluated in this object are exactly the same as in tgt object. More...
 
bool IsValueEqual (const std::string &name, const RAttrMap::Value_t &value, bool use_style=false) const
 Copy attributes into target object. More...
 
RAttrBaseoperator= (const RAttrBase &src)
 
void SetValue (const std::string &name, bool value)
 
void SetValue (const std::string &name, const std::string &value)
 
void SetValue (const std::string &name, double value)
 
void SetValue (const std::string &name, int value)
 

#include <ROOT/RColor.hxx>

Inheritance diagram for ROOT::Experimental::RColor:
[legend]

Member Typedef Documentation

◆ RGB_t

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

Definition at line 36 of file RColor.hxx.

Constructor & Destructor Documentation

◆ RColor() [1/3]

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

Construct color with provided r,g,b values.

Definition at line 55 of file RColor.hxx.

◆ RColor() [2/3]

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

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

Definition at line 58 of file RColor.hxx.

◆ RColor() [3/3]

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

Construct color with provided RGB_t value.

Definition at line 65 of file RColor.hxx.

Member Function Documentation

◆ AsSVG()

std::string ROOT::Experimental::RColor::AsSVG ( ) const
inline

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 163 of file RColor.hxx.

◆ Clear()

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

Definition at line 174 of file RColor.hxx.

◆ ClearAlpha()

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

Clear alpha value of the color.

Definition at line 140 of file RColor.hxx.

◆ ClearAuto()

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

Clear auto flag of the RColor.

Definition at line 153 of file RColor.hxx.

◆ ClearName()

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

Clear color plain SVG name (if any)

Definition at line 112 of file RColor.hxx.

◆ ClearRGB()

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

Clear RGB color value (if any)

Definition at line 95 of file RColor.hxx.

◆ GetAlpha()

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

Returns color alpha (opacity) as float from 0.

to 1.

Definition at line 115 of file RColor.hxx.

◆ GetAlphaHex()

std::string ROOT::Experimental::RColor::GetAlphaHex ( ) const
inline

Returns color alpha (opacity) as hex string like FF.

Default is empty

Definition at line 124 of file RColor.hxx.

◆ GetBlue()

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

Returns blue color component 0..255.

Definition at line 92 of file RColor.hxx.

◆ GetColorComponent()

int RColor::GetColorComponent ( int  indx) const
private

Decodes color component and returns integer from 0 to 255 Values of indx 0: Red, 1: Green, 2: Blue If color was not specified as hex, method returns 0.

Definition at line 59 of file RColor.cxx.

◆ GetGreen()

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

Returns green color component 0..255.

Definition at line 89 of file RColor.hxx.

◆ GetHex()

std::string ROOT::Experimental::RColor::GetHex ( ) const
inline

Return color as hex string like 00FF00.

Definition at line 81 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 85 of file RColor.cxx.

◆ GetName()

std::string ROOT::Experimental::RColor::GetName ( ) const
inline

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

Definition at line 109 of file RColor.hxx.

◆ GetRed()

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

Returns red color component 0..255.

Definition at line 86 of file RColor.hxx.

◆ GetRGB()

bool RColor::GetRGB ( int &  r,
int &  g,
int &  b 
) const

Decodes hex color value into RGB - each color component as integer from 0 to 255 If color was not specified as hex, method returns false.

Definition at line 42 of file RColor.cxx.

◆ GetRGBFloat()

bool RColor::GetRGBFloat ( float &  r,
float &  g,
float &  b 
) const
private

Decodes hex color value into RGB - each color component as float from 0.

to 1. If color was not specified as hex, method returns false

Definition at line 70 of file RColor.cxx.

◆ HasAlpha()

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

Returns true if color alpha (opacity) was specified.

Definition at line 127 of file RColor.hxx.

◆ IsAuto()

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

Returns true if color should get auto value when primitive drawing is performed.

Definition at line 143 of file RColor.hxx.

◆ R__ATTR_CLASS()

ROOT::Experimental::RColor::R__ATTR_CLASS ( RColor  ,
"color_"  ,
AddString("rgb", "").AddString("a", "").AddString("name", "").AddBool("auto", false)   
)
private

◆ SetAlpha()

RColor & ROOT::Experimental::RColor::SetAlpha ( float  _alpha)
inline

Set color alpha (opacity) value - from 0 to 1.

Definition at line 130 of file RColor.hxx.

◆ SetAlphaHex()

RColor & ROOT::Experimental::RColor::SetAlphaHex ( const std::string &  _alfa)
inline

Set color alpha (opacity) value as hex string.

Definition at line 133 of file RColor.hxx.

◆ SetAuto()

RColor & ROOT::Experimental::RColor::SetAuto ( bool  on = true)
inline

Set automatic mode for RColor, will be assigned before primitive painted on the canvas.

Definition at line 146 of file RColor.hxx.

◆ SetHex()

RColor & ROOT::Experimental::RColor::SetHex ( const std::string &  _hex)
inline

Set color as hex string like 00FF00.

Definition at line 74 of file RColor.hxx.

◆ SetHLS()

RColor & 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 130 of file RColor.cxx.

◆ SetName()

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

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

Clears RGB component before

Definition at line 101 of file RColor.hxx.

◆ SetRGB() [1/2]

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

Set r/g/b/ components of color as hex code, default for the color.

Definition at line 68 of file RColor.hxx.

◆ SetRGB() [2/2]

RColor & ROOT::Experimental::RColor::SetRGB ( int  r,
int  g,
int  b 
)
inline

Set r/g/b/ components of color as hex code, default for the color.

Definition at line 71 of file RColor.hxx.

◆ SetRGBFloat()

RColor & ROOT::Experimental::RColor::SetRGBFloat ( float  r,
float  g,
float  b 
)
inlineprivate

Set RGB values as floats, each from 0..1.

Real color values will be stored in hex format

Definition at line 43 of file RColor.hxx.

◆ toHex()

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

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

Definition at line 24 of file RColor.cxx.

Friends And Related Function Documentation

◆ operator==

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

Definition at line 190 of file RColor.hxx.

Member Data Documentation

◆ kBlack

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

Definition at line 186 of file RColor.hxx.

◆ kBlue

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

Definition at line 184 of file RColor.hxx.

◆ kGreen

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

Definition at line 183 of file RColor.hxx.

◆ kOpaque

constexpr double RColor::kOpaque {1.}
staticconstexpr

Definition at line 188 of file RColor.hxx.

◆ kRed

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

Definition at line 182 of file RColor.hxx.

◆ kTransparent

constexpr double RColor::kTransparent {0.}
staticconstexpr

Definition at line 187 of file RColor.hxx.

◆ kWhite

constexpr RColor::RGB_t RColor::kWhite {{255, 255, 255}}
staticconstexpr

Definition at line 185 of file RColor.hxx.

Libraries for ROOT::Experimental::RColor:
[legend]

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