29 const string &palette):
41 Palette(
"txt/colors.txt", palette){
90 const string &palette){
105 ifstream file(
file_);
107 string current_palette_ =
"";
109 while(getline(file, line)){
113 auto start = line.find(
'[');
114 auto end = line.find(
']');
115 if(start==string::npos && end!=string::npos){
116 ERROR(
"Could not find opening brace in line "+to_string(line_num));
118 if(start!=string::npos && end==string::npos){
119 ERROR(
"Could not find closing brace in line "+to_string(line_num));
121 if(start<end && start != string::npos && end != string::npos){
122 current_palette_ = line.substr(start+1, end-start-1);
123 }
else if(current_palette_ ==
palette_ 126 istringstream iss(line);
129 if(color != color_name)
continue;
135 DBG(
"No color " << color_name <<
" in palette " <<
palette_ <<
" in file " <<
file_);
150 return TColor::GetColor(r, g, b);
164 return TColor::GetColor(r, g, b);
179 TColor::HSV2RGB(h, s, v, r, g, b);
195 TColor::HLS2RGB(h, l, s, r, g, b);
211 TColor::HLS2RGB(h, l, s, r, g, b);
void ReplaceAll(std::string &str, const std::string &orig, const std::string &rep)
Int_t operator()(const std::string &color_name) const
Gets the ROOT color number corresponding to a color in the configuration file.
const std::string & PaletteName() const
Get the name of the palette from which colors are read.
std::string palette_
Palette name from which to read color definitions.
const std::string & File() const
Get the file from which colors are read.
std::string file_
File from which to read color definitions.
static Int_t RGB(Int_t r, Int_t g, Int_t b)
Gets the ROOT color number corresponding to a given RGB color.
Palette(const std::string &file, const std::string &palette)
Construct from file and palette names.
static Int_t HLS(Int_t h, Int_t l, Int_t s)
Gets the ROOT color number corresponding to a given HLS/HSL color.
static Int_t HSV(Float_t h, Float_t s, Float_t v)
Gets the ROOT color number corresponding to a given HSV color.
Loads colors from a text configuration file.