10 static Hsv rgb2hsv(
const Rgb &in);
11 static Rgb hsv2rgb(
const Hsv &in);
17 float min = in.
r < in.
g ? in.
r : in.
g;
20 float max = in.
r > in.
g ? in.
r : in.
g;
21 max = max > in.
b ? max : in.
b;
24 const float delta = max -
min;
48 out.
h = (in.
g - in.
b) / delta;
52 out.
h = 2.0f + (in.
b - in.
r) / delta;
56 out.
h = 4.0f + (in.
r - in.
g) / delta;
83 if(hh >= 360.0f) hh = 0.0f;
86 const long i = (long)hh;
87 const float ff = hh - i;
88 const float p = in.
v * (1.0f - in.
s);
89 const float q = in.
v * (1.0f - (in.
s * ff));
90 const float t = in.
v * (1.0f - (in.
s * (1.0f - ff)));
142 const static float GOLDEN_ANGLE = 137.507764f;
144 float goldenHue(
const std::size_t i)
146 return fmod(GOLDEN_ANGLE * i, 360.0f);
158 Rgba::Rgba(
const float r,
const float g,
const float b,
const float a)
166 Rgba::operator std_msgs::ColorRGBA () const noexcept
168 std_msgs::ColorRGBA ret;
209 Rgb::Rgb(
const float r,
const float g,
const float b)
216 Rgb::operator std_msgs::ColorRGBA () const noexcept
218 std_msgs::ColorRGBA ret;
226 Rgb::operator
Rgba () const noexcept
239 return rgb2hsv(*
this);
264 Hsv::Hsv(
const float h,
const float s,
const float v)
273 return hsv2rgb(*
this);
293 return Hsv(goldenHue(i), 1.0
f, 1.0
f);