Utility functions related to colors.
More...
#include <Colors.h>
|
static std::vector< std::string > | getList () |
| Get a list of useful colors.
|
|
static double | hueToRgb (double p, double q, double t) |
| Transforms a Color given in the HLS System to RGB.
|
|
static std::array< double, 3 > | hlsToRgb (double h, double l, double s) |
| Transforms a Color given in the HLS System to RGB.
|
|
static std::string | getWheelColor (int degree) |
| Get a color from the wheel of colors.
|
|
Utility functions related to colors.
Definition at line 22 of file Colors.h.
◆ getList()
std::vector< std::string > getList |
( |
| ) |
|
|
static |
Get a list of useful colors.
Definition at line 15 of file Colors.cc.
16{
17 return {
18 "red",
19 "blue",
20 "green",
21 "orangered",
22 "cyan",
23 "olive",
24 "maroon",
25 "turquoise",
26 "lime",
27 "teal",
28 "darkgreen",
29 "indigo",
30 "darkolivegreen",
31 "orange",
32 "darkmagenta",
33 "seagreen",
34 "magenta",
35 "midnightblue",
36 "darkgoldenrod"
37 };
38}
◆ getWheelColor()
std::string getWheelColor |
( |
int |
degree | ) |
|
|
static |
Get a color from the wheel of colors.
- Parameters
-
degree | the degree viewed form the center of the color wheel (greater 0) |
Definition at line 71 of file Colors.cc.
72{
73 double hue(degree % 360 / 360.);
74 double saturation = 0.75;
75 double lightness = 0.5;
76
78 std::ostringstream oss;
79 oss << "rgb(" << rgb[0] * 100 << "%, " << rgb[1] * 100 << "%, " << rgb[2] * 100 << "%)";
80 return oss.str();
81}
static std::array< double, 3 > hlsToRgb(double h, double l, double s)
Transforms a Color given in the HLS System to RGB.
◆ hlsToRgb()
std::array< double, 3 > hlsToRgb |
( |
double |
h, |
|
|
double |
l, |
|
|
double |
s |
|
) |
| |
|
static |
Transforms a Color given in the HLS System to RGB.
- Parameters
-
h | Hue ranging from 0 to 1. |
l | Lighness. |
s | Saturation. |
- Returns
- Array containing rgb-values in the order red, green, blue.
Definition at line 56 of file Colors.cc.
57{
58 if (s == 0) {
59 return {l, l, l};
60 } else {
61 double q = l < 0.5 ? l * (1 + s) : l + s - l * s;
62 double p = 2 * l - q;
63 return {
67 };
68 }
69}
static double hueToRgb(double p, double q, double t)
Transforms a Color given in the HLS System to RGB.
◆ hueToRgb()
double hueToRgb |
( |
double |
p, |
|
|
double |
q, |
|
|
double |
t |
|
) |
| |
|
static |
Transforms a Color given in the HLS System to RGB.
Definition at line 40 of file Colors.cc.
41{
42 while (t < 0) t += 1;
43 while (t > 1) t -= 1;
44 if (t < 1. / 6.) {
45 return p + (q - p) * 6 * t;
46 }
47 if (t < 1. / 2.) {
48 return q;
49 }
50 if (t < 2. / 3.) {
51 return p + (q - p) * (2. / 3. - t) * 6;
52 }
53 return p;
54}
The documentation for this class was generated from the following files:
- tracking/trackFindingCDC/display/include/Colors.h
- tracking/trackFindingCDC/display/src/Colors.cc