diff --git a/src/color/mod.rs b/src/color/mod.rs index 8c3da1a..24a7f34 100644 --- a/src/color/mod.rs +++ b/src/color/mod.rs @@ -370,7 +370,7 @@ impl Color { /// Create RGBA representation from HSLA values pub fn from_hsla(hue: Number, saturation: Number, luminance: Number, alpha: Number) -> Self { - let mut hue = if hue > Number::from(360) { + let mut hue = if hue >= Number::from(360) { hue % Number::from(360) } else if hue < Number::from(-360) { Number::from(360) + hue % Number::from(360) diff --git a/tests/color.rs b/tests/color.rs index 3fa4968..86bd048 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -247,6 +247,11 @@ test!( "a {\n color: hue(rgb(1, 0, 1));\n}\n", "a {\n color: 300deg;\n}\n" ); +test!( + hue_of_360_becomes_0, + "a {\n color: hue(hsl(360, 10%, 20%));\n}\n", + "a {\n color: 0deg;\n}\n" +); test!( hue_green_equals_blue, "a {\n color: hue(rgb(0, 1, 1));\n}\n",