diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index ab51c8f..d3ced94 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -23,7 +23,12 @@ pub(crate) fn register(f: &mut BTreeMap) { | Value::Dimension(n, Unit::Percent) => n / Number::from(100), _ => todo!("expected either unitless or % number for alpha"), }; - Some(Value::Color(Color::from_hsla(hue, saturation, luminance, Number::from(1)))) + let alpha = match arg!(args, 3, "alpha"=Value::Dimension(Number::from(1), Unit::None)) { + Value::Dimension(n, Unit::None) => n, + Value::Dimension(n, Unit::Percent) => n / Number::from(100), + _ => todo!("non-number alpha given to builtin function `rgb()`") + }; + Some(Value::Color(Color::from_hsla(hue, saturation, luminance, alpha))) }); decl!(f "hsla", |args, _| { let hue = match arg!(args, 0, "hue").eval() { diff --git a/tests/color.rs b/tests/color.rs index ea49f6c..135815e 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -128,6 +128,11 @@ test!( "a {\n color: hsl($hue: 193, $saturation: 67%, $luminance: 99);\n}\n", "a {\n color: #fbfdfe;\n}\n" ); +test!( + hsl_four_args, + "a {\n color: hsl(0, 0, 0, 0.456);\n}\n", + "a {\n color: rgba(0, 0, 0, 0.456);\n}\n" +); test!( hsl_negative_hue, "a {\n color: hsl(-60deg, 100%, 50%);\n}\n",