Belle II Software light-2406-ragdoll
ColorPalette.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <framework/utilities/ColorPalette.h>
9
10#include <TColor.h>
11
12#include <string>
13#include <map>
14#include <array>
15#include <stdexcept>
16
17namespace Belle2::TangoPalette {
18 const char* getHex(const std::string& tangoName, int tangoId)
19 {
20 using ColorTuple = std::array<const char*, 3>;
21 static std::map<std::string, ColorTuple> tango;
22 if (tango.empty()) {
23 tango["Aluminium"] = ColorTuple({"#eeeeec", "#d3d7cf", "#babdb6"});
24 tango["Butter"] = ColorTuple({"#fce94f", "#edd400", "#c4a000"});
25 tango["Chameleon"] = ColorTuple({"#8ae234", "#73d216", "#4e9a06"});
26 tango["Orange"] = ColorTuple({"#fcaf3e", "#f57900", "#ce5c00"});
27 tango["Chocolate"] = ColorTuple({"#e9b96e", "#c17d11", "#8f5902"});
28 tango["Sky Blue"] = ColorTuple({"#729fcf", "#3465a4", "#204a87"});
29 tango["Plum"] = ColorTuple({"#ad7fa8", "#75507b", "#5c3566"});
30 tango["Slate"] = ColorTuple({"#888a85", "#555753", "#2e3436"});
31 tango["Scarlet Red"] = ColorTuple({"#ef2929", "#cc0000", "#a40000"});
32 }
33
34 if (tangoId < 1 or tangoId > 3)
35 throw std::runtime_error("tangoId must be 1, 2, or 3!");
36 return tango.at(tangoName)[tangoId - 1];
37 }
38
39 int getTColorID(const std::string& tangoName, int tangoId)
40 {
41 return TColor::GetColor(getHex(tangoName, tangoId));
42 }
43}
Implements a colour palette, see http://sobac.com/sobac/tangocolors.htm.
Definition: ColorPalette.h:23
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:18
int getTColorID(const std::string &tangoName, int tangoId=1)
Get TColor ID for given name in tango colour palette.
Definition: ColorPalette.cc:39