| 181 | } |
| 182 | |
| 183 | Color 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 | |
| 201 | Color Color::fromHTML(const char* rgb, const float alpha) noexcept |
| 202 | { |
nothing calls this directly
no test coverage detected