MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ hsv_to_rgb()

glm::vec3 MayaFlux::Kinesis::hsv_to_rgb ( glm::vec3  hsv)
inlinenoexcept

Convert hue, saturation and value to red, green and blue.

All components are in [0, 1]. Hue wraps, so 1 is the same colour as 0; saturation and value are clamped.

Parameters
hsvHue in x, saturation in y, value in z.
Returns
Red in x, green in y, blue in z.

Definition at line 16 of file ColorSpace.hpp.

17{
18 const float hue = hsv.x - std::floor(hsv.x);
19 const float saturation = std::clamp(hsv.y, 0.F, 1.F);
20 const float value = std::clamp(hsv.z, 0.F, 1.F);
21 const float sector = hue * 6.F;
22
23 const auto channel = [&](float offset) {
24 const float k = std::fmod(offset + sector, 6.F);
25 return value - value * saturation * std::clamp(std::min(k, 4.F - k), 0.F, 1.F);
26 };
27
28 return { channel(5.F), channel(3.F), channel(1.F) };
29}
uint64_t offset
Definition Composite.cpp:10
glm::vec3 value

References offset, and value.

Referenced by MayaFlux::Portal::Forma::ColorPicker::place().

+ Here is the caller graph for this function: