diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index 6613f59..a1da9d4 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -108,14 +108,15 @@ pub(crate) fn register(f: &mut BTreeMap) { }); decl!(f "saturate", |args, _| { max_args!(args, 2); - let color = match arg!(args, 0, "color").eval() { - Value::Color(c) => c, - v => return Err(format!("$color: {} is not a color.", v).into()), - }; let amount = match arg!(args, 1, "amount").eval() { Value::Dimension(n, u) => bound!("amount", n, u, 0, 100) / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into()) }; + let color = match arg!(args, 0, "color").eval() { + Value::Color(c) => c, + Value::Dimension(n, u) => return Ok(Value::Ident(format!("saturate({}{})", n, u), QuoteKind::None)), + v => return Err(format!("$color: {} is not a color.", v).into()), + }; Ok(Value::Color(color.saturate(amount))) }); decl!(f "desaturate", |args, _| { diff --git a/src/builtin/color/rgb.rs b/src/builtin/color/rgb.rs index a2a08e6..5715567 100644 --- a/src/builtin/color/rgb.rs +++ b/src/builtin/color/rgb.rs @@ -188,7 +188,7 @@ pub(crate) fn register(f: &mut BTreeMap) { }; let weight = match arg!(args, 2, "weight"=Value::Dimension(Number::from(50), Unit::None)) { - Value::Dimension(n, _) => n / Number::from(100), + Value::Dimension(n, u) => bound!("weight", n, u, 0, 100) / Number::from(100), v => return Err(format!("$weight: {} is not a number.", v).into()), }; Ok(Value::Color(color1.mix(color2, weight)))