Treat negative hues correctly in HSL.
This commit is contained in:
parent
e598249186
commit
4365b75629
|
@ -113,7 +113,12 @@ impl ColorF {
|
||||||
pub fn from_hsla(mut h: f32, s: f32, l: f32, a: f32) -> ColorF {
|
pub fn from_hsla(mut h: f32, s: f32, l: f32, a: f32) -> ColorF {
|
||||||
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
|
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
|
||||||
|
|
||||||
|
// Make sure hue is always positive.
|
||||||
h %= 2.0 * PI;
|
h %= 2.0 * PI;
|
||||||
|
if h < 0.0 {
|
||||||
|
h += 2.0 * PI;
|
||||||
|
}
|
||||||
|
|
||||||
h *= 3.0 / PI;
|
h *= 3.0 / PI;
|
||||||
|
|
||||||
// Calculate chroma.
|
// Calculate chroma.
|
||||||
|
|
Loading…
Reference in New Issue