Belle II Software  release-05-01-25
ColorPalette.cc
1 #include <framework/utilities/ColorPalette.h>
2 
3 #include <TColor.h>
4 
5 #include <string>
6 #include <map>
7 #include <array>
8 
9 namespace Belle2::TangoPalette {
10  const char* getHex(const std::string& tangoName, int tangoId)
11  {
12  using ColorTuple = std::array<const char*, 3>;
13  static std::map<std::string, ColorTuple> tango;
14  if (tango.empty()) {
15  tango["Aluminium"] = ColorTuple({"#eeeeec", "#d3d7cf", "#babdb6"});
16  tango["Butter"] = ColorTuple({"#fce94f", "#edd400", "#c4a000"});
17  tango["Chameleon"] = ColorTuple({"#8ae234", "#73d216", "#4e9a06"});
18  tango["Orange"] = ColorTuple({"#fcaf3e", "#f57900", "#ce5c00"});
19  tango["Chocolate"] = ColorTuple({"#e9b96e", "#c17d11", "#8f5902"});
20  tango["Sky Blue"] = ColorTuple({"#729fcf", "#3465a4", "#204a87"});
21  tango["Plum"] = ColorTuple({"#ad7fa8", "#75507b", "#5c3566"});
22  tango["Slate"] = ColorTuple({"#888a85", "#555753", "#2e3436"});
23  tango["Scarlet Red"] = ColorTuple({"#ef2929", "#cc0000", "#a40000"});
24  }
25 
26  if (tangoId < 1 or tangoId > 3)
27  throw std::runtime_error("tangoId must be 1, 2, or 3!");
28  return tango.at(tangoName)[tangoId - 1];
29  }
30 
31  int getTColorID(const std::string& tangoName, int tangoId)
32  {
33  return TColor::GetColor(getHex(tangoName, tangoId));
34  }
35 }
Belle2::TangoPalette::getTColorID
int getTColorID(const std::string &tangoName, int tangoId=1)
Get TColor ID for given name in tango colour palette.
Definition: ColorPalette.cc:31
Belle2::TangoPalette::getHex
const char * getHex(const std::string &tangoName, int tangoId=1)
Get six-digit hex code (#abcdef) for given name in tango colour palette.
Definition: ColorPalette.cc:10
Belle2::TangoPalette
Implements a colour palette, see http://sobac.com/sobac/tangocolors.htm.
Definition: ColorPalette.h:16