Implement builtin function grayscale()
This commit is contained in:
parent
08bfa8f145
commit
af8bd516b2
@ -314,4 +314,11 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
||||
};
|
||||
Some(Value::Color(color.fade_out(amount)))
|
||||
});
|
||||
decl!(f "grayscale", |args, _| {
|
||||
let color = match arg!(args, 0, "color").eval() {
|
||||
Value::Color(c) => c,
|
||||
_ => todo!("non-color given to builtin function `grayscale()`")
|
||||
};
|
||||
Some(Value::Color(color.desaturate(Number::from(1))))
|
||||
});
|
||||
}
|
||||
|
@ -341,3 +341,13 @@ test!(
|
||||
"a {\n color: opacify(rgba(0, 0, 17, 0.8), 0.2);\n}\n",
|
||||
"a {\n color: #000011;\n}\n"
|
||||
);
|
||||
test!(
|
||||
grayscale_1,
|
||||
"a {\n color: grayscale(plum);\n}\n",
|
||||
"a {\n color: #bfbfbf;\n}\n"
|
||||
);
|
||||
test!(
|
||||
grayscale_2,
|
||||
"a {\n color: grayscale(red);\n}\n",
|
||||
"a {\n color: gray;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user