21 #include "glog/logging.h" 27 constexpr
float kInitialHue = 0.69f;
28 constexpr
float kSaturation = 0.85f;
29 constexpr
float kValue = 0.77f;
30 constexpr
float kGoldenRatioConjugate = (std::sqrt(5.f) - 1.f) / 2.f;
31 constexpr
float kAlpha = 1.f;
33 ::std_msgs::ColorRGBA CreateRgba(
const float r,
const float g,
const float b) {
34 ::std_msgs::ColorRGBA result;
42 ::std_msgs::ColorRGBA HsvToRgb(
const float h,
const float s,
const float v) {
43 const float h_6 = (h == 1.f) ? 0.f : 6 * h;
44 const int h_i = std::floor(h_6);
45 const float f = h_6 - h_i;
47 const float p = v * (1.f - s);
48 const float q = v * (1.f - f * s);
49 const float t = v * (1.f - (1.f - f) * s);
52 return CreateRgba(v, t, p);
53 }
else if (h_i == 1) {
54 return CreateRgba(q, v, p);
55 }
else if (h_i == 2) {
56 return CreateRgba(p, v, t);
57 }
else if (h_i == 3) {
58 return CreateRgba(p, q, v);
59 }
else if (h_i == 4) {
60 return CreateRgba(t, p, v);
61 }
else if (h_i == 5) {
62 return CreateRgba(v, p, q);
64 return CreateRgba(0.f, 0.f, 0.f);
74 const float hue = std::fmod(kInitialHue + kGoldenRatioConjugate *
id, 1.
f);
75 return HsvToRgb(hue, kSaturation, kValue);
::std_msgs::ColorRGBA GetColor(int id)