remove todo! from other color functions

This commit is contained in:
ConnorSkees 2020-03-21 00:10:15 -04:00
parent e746bc7bda
commit 22ab800e4c
2 changed files with 6 additions and 14 deletions

View File

@ -92,11 +92,9 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
}
let hue = match arg!(args, -1, "hue" = Value::Null) {
Value::Dimension(n, Unit::None)
| Value::Dimension(n, Unit::Percent)
| Value::Dimension(n, Unit::Deg) => Some(n),
Value::Dimension(n, _) => Some(n),
Value::Null => None,
_ => todo!("expected either unitless or % number for hue"),
v => return Err(format!("$hue: {} is not a number.", v).into()),
};
opt_hsl!(args, saturation, "saturation", -100, 100);
@ -177,22 +175,14 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
)));
}
let hue = match arg!(args, -1, "hue" = Value::Null) {
Value::Dimension(n, Unit::None)
| Value::Dimension(n, Unit::Percent)
| Value::Dimension(n, Unit::Deg) => Some(n),
Value::Null => None,
_ => todo!("expected either unitless or % number for hue"),
};
opt_scale_arg!(args, saturation, "saturation", -100, 100);
opt_scale_arg!(args, luminance, "lightness", -100, 100);
if hue.is_some() || saturation.is_some() || luminance.is_some() {
if saturation.is_some() || luminance.is_some() {
// Color::as_hsla() returns more exact values than Color::hue(), etc.
let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla();
return Ok(Value::Color(Color::from_hsla(
scale(this_hue, hue.unwrap_or(Number::from(0)), Number::from(360)),
scale(this_hue, Number::from(0), Number::from(360)),
scale(
this_saturation,
saturation.unwrap_or(Number::from(0)),

View File

@ -303,6 +303,8 @@ impl<'a> Lexer<'a> {
}
}
// TODO: handle weird characters that *are* ascii
// e.g. how do we handle `color: ;`
fn lex_ident(&mut self) -> TokenKind {
let mut string = String::with_capacity(99);
while let Some(c) = self.buf.peek() {