two arg special function rgb/rgba
This commit is contained in:
parent
c95c69be4d
commit
b545c162f5
@ -57,10 +57,7 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
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<String, Builtin>) {
|
||||
} 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<String, Builtin>) {
|
||||
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<String, Builtin>) {
|
||||
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<String, Builtin>) {
|
||||
} 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<String, Builtin>) {
|
||||
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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user