hsl/hsla 4 args special functions

This commit is contained in:
ConnorSkees 2020-04-07 00:04:19 -04:00
parent 6b817dcb24
commit 0ddabb5afd

View File

@ -117,6 +117,12 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
format!("$alpha: Expected {} to have no units or \"%\".", v).into() format!("$alpha: Expected {} to have no units or \"%\".", v).into()
) )
} }
v if v.is_special_function() => {
return Ok(Value::Ident(
format!("hsl({}, {}, {}, {})", hue, saturation, lightness, v),
QuoteKind::None,
));
}
v => return Err(format!("$alpha: {} is not a number.", v).into()), v => return Err(format!("$alpha: {} is not a number.", v).into()),
}; };
Ok(Value::Color(Color::from_hsla( Ok(Value::Color(Color::from_hsla(
@ -233,6 +239,12 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
format!("$alpha: Expected {} to have no units or \"%\".", v).into() format!("$alpha: Expected {} to have no units or \"%\".", v).into()
) )
} }
v if v.is_special_function() => {
return Ok(Value::Ident(
format!("hsl({}, {}, {}, {})", hue, saturation, lightness, v),
QuoteKind::None,
));
}
v => return Err(format!("$alpha: {} is not a number.", v).into()), v => return Err(format!("$alpha: {} is not a number.", v).into()),
}; };
Ok(Value::Color(Color::from_hsla( Ok(Value::Color(Color::from_hsla(