Arg errors for (de)saturate

This commit is contained in:
ConnorSkees 2020-02-16 11:47:15 -05:00
parent 92a7264f9a
commit 7c451e333e

View File

@ -107,9 +107,8 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
v => return Err(format!("$color: {} is not a color.", v).into()), v => return Err(format!("$color: {} is not a color.", v).into()),
}; };
let amount = match arg!(args, 1, "amount").eval() { let amount = match arg!(args, 1, "amount").eval() {
Value::Dimension(n, Unit::None) => n, Value::Dimension(n, _) => n / Number::from(100),
Value::Dimension(n, Unit::Percent) => n / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into())
_ => todo!("expected either unitless or % number for amount"),
}; };
Ok(Value::Color(color.saturate(amount))) Ok(Value::Color(color.saturate(amount)))
}); });
@ -119,9 +118,8 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
v => return Err(format!("$color: {} is not a color.", v).into()), v => return Err(format!("$color: {} is not a color.", v).into()),
}; };
let amount = match arg!(args, 1, "amount").eval() { let amount = match arg!(args, 1, "amount").eval() {
Value::Dimension(n, Unit::None) => n, Value::Dimension(n, _) => n / Number::from(100),
Value::Dimension(n, Unit::Percent) => n / Number::from(100), v => return Err(format!("$amount: {} is not a number.", v).into())
_ => todo!("expected either unitless or % number for amount"),
}; };
Ok(Value::Color(color.desaturate(amount))) Ok(Value::Color(color.desaturate(amount)))
}); });