MCPcopy Create free account
hub / github.com/DISTRHO/DPF / fromHSL

Method fromHSL

dgl/src/Color.cpp:183–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183Color Color::fromHSL(float hue, float saturation, float lightness, float alpha)
184{
185 float m1, m2;
186 Color col;
187 hue = fmodf(hue, 1.0f);
188 if (hue < 0.0f) hue += 1.0f;
189 fixRange(saturation);
190 fixRange(lightness);
191 m2 = lightness <= 0.5f ? (lightness * (1 + saturation)) : (lightness + saturation - lightness * saturation);
192 m1 = 2 * lightness - m2;
193 col.red = computeHue(hue + 1.0f/3.0f, m1, m2);
194 col.green = computeHue(hue, m1, m2);
195 col.blue = computeHue(hue - 1.0f/3.0f, m1, m2);
196 col.alpha = alpha;
197 col.fixBounds();
198 return col;
199}
200
201Color Color::fromHTML(const char* rgb, const float alpha) noexcept
202{

Callers

nothing calls this directly

Calls 3

fixRangeFunction · 0.85
computeHueFunction · 0.85
fixBoundsMethod · 0.80

Tested by

no test coverage detected