diff --git a/src/builtin/color/rgb.rs b/src/builtin/color/rgb.rs index d43d5d3..85ff7b7 100644 --- a/src/builtin/color/rgb.rs +++ b/src/builtin/color/rgb.rs @@ -57,10 +57,7 @@ pub(crate) fn register(f: &mut HashMap) { Some(red) => format!("rgb({}, {}, {})", red, v, blue), None => format!("rgb({}, {})", v, blue), }; - return Ok(Value::Ident( - string, - QuoteKind::None, - )); + return Ok(Value::Ident(string, QuoteKind::None)); } Some(v) => return Err(format!("$green: {} is not a number.", v).into()), None => return Err("Missing element $green.".into()), @@ -87,6 +84,13 @@ pub(crate) fn register(f: &mut HashMap) { } else if args.len() == 2 { let color = match arg!(args, scope, super_selector, 0, "color") { Value::Color(c) => c, + v if v.is_special_function() => { + let alpha = arg!(args, scope, super_selector, 1, "alpha"); + return Ok(Value::Ident( + format!("rgb({}, {})", v, alpha), + QuoteKind::None, + )); + } v => return Err(format!("$color: {} is not a color.", v).into()), }; let alpha = match arg!(args, scope, super_selector, 1, "alpha") { @@ -97,6 +101,18 @@ pub(crate) fn register(f: &mut HashMap) { format!("$alpha: Expected {} to have no units or \"%\".", v).into() ) } + v if v.is_special_function() => { + return Ok(Value::Ident( + format!( + "rgb({}, {}, {}, {})", + color.red(), + color.green(), + color.blue(), + v + ), + QuoteKind::None, + )); + } v => return Err(format!("$alpha: {} is not a number.", v).into()), }; Ok(Value::Color(color.with_alpha(alpha))) @@ -245,10 +261,7 @@ pub(crate) fn register(f: &mut HashMap) { Some(red) => format!("rgba({}, {}, {})", red, v, blue), None => format!("rgba({}, {})", v, blue), }; - return Ok(Value::Ident( - string, - QuoteKind::None, - )); + return Ok(Value::Ident(string, QuoteKind::None)); } Some(v) => return Err(format!("$green: {} is not a number.", v).into()), None => return Err("Missing element $green.".into()), @@ -275,6 +288,13 @@ pub(crate) fn register(f: &mut HashMap) { } else if args.len() == 2 { let color = match arg!(args, scope, super_selector, 0, "color") { Value::Color(c) => c, + v if v.is_special_function() => { + let alpha = arg!(args, scope, super_selector, 1, "alpha"); + return Ok(Value::Ident( + format!("rgb({}, {})", v, alpha), + QuoteKind::None, + )); + } v => return Err(format!("$color: {} is not a color.", v).into()), }; let alpha = match arg!(args, scope, super_selector, 1, "alpha") { @@ -285,6 +305,18 @@ pub(crate) fn register(f: &mut HashMap) { format!("$alpha: Expected {} to have no units or \"%\".", v).into() ) } + v if v.is_special_function() => { + return Ok(Value::Ident( + format!( + "rgb({}, {}, {}, {})", + color.red(), + color.green(), + color.blue(), + v + ), + QuoteKind::None, + )); + } v => return Err(format!("$alpha: {} is not a number.", v).into()), }; Ok(Value::Color(color.with_alpha(alpha)))