remove todo! from other color functions
This commit is contained in:
parent
e746bc7bda
commit
22ab800e4c
@ -92,11 +92,9 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let hue = match arg!(args, -1, "hue" = Value::Null) {
|
let hue = match arg!(args, -1, "hue" = Value::Null) {
|
||||||
Value::Dimension(n, Unit::None)
|
Value::Dimension(n, _) => Some(n),
|
||||||
| Value::Dimension(n, Unit::Percent)
|
|
||||||
| Value::Dimension(n, Unit::Deg) => Some(n),
|
|
||||||
Value::Null => None,
|
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);
|
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, saturation, "saturation", -100, 100);
|
||||||
opt_scale_arg!(args, luminance, "lightness", -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.
|
// Color::as_hsla() returns more exact values than Color::hue(), etc.
|
||||||
let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla();
|
let (this_hue, this_saturation, this_luminance, this_alpha) = color.as_hsla();
|
||||||
return Ok(Value::Color(Color::from_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(
|
scale(
|
||||||
this_saturation,
|
this_saturation,
|
||||||
saturation.unwrap_or(Number::from(0)),
|
saturation.unwrap_or(Number::from(0)),
|
||||||
|
@ -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 {
|
fn lex_ident(&mut self) -> TokenKind {
|
||||||
let mut string = String::with_capacity(99);
|
let mut string = String::with_capacity(99);
|
||||||
while let Some(c) = self.buf.peek() {
|
while let Some(c) = self.buf.peek() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user