mirror of
https://github.com/danog/dart-sass.git
synced 2024-12-04 10:37:52 +01:00
Add opacify() et al
This commit is contained in:
parent
04b012befe
commit
8b8f6bfbee
@ -222,6 +222,13 @@ void defineCoreFunctions(Environment environment) {
|
|||||||
return new SassNumber(color.alpha);
|
return new SassNumber(color.alpha);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
environment.setFunction(new BuiltInCallable("opacify", r"$color", _opacify));
|
||||||
|
environment.setFunction(new BuiltInCallable("fade-in", r"$color", _opacify));
|
||||||
|
environment.setFunction(
|
||||||
|
new BuiltInCallable("transparentize", r"$color", _transparentize));
|
||||||
|
environment
|
||||||
|
.setFunction(new BuiltInCallable("fade-out", r"$color", _transparentize));
|
||||||
|
|
||||||
// ## Introspection
|
// ## Introspection
|
||||||
|
|
||||||
environment.setFunction(new BuiltInCallable("inspect", r"$value",
|
environment.setFunction(new BuiltInCallable("inspect", r"$value",
|
||||||
@ -280,3 +287,17 @@ SassColor _mix(SassColor color1, SassColor color2, SassNumber weight) {
|
|||||||
(color1.blue * weight1 + color2.blue * weight2).round(),
|
(color1.blue * weight1 + color2.blue * weight2).round(),
|
||||||
color1.alpha * weightScale + color2.alpha * (1 - weightScale));
|
color1.alpha * weightScale + color2.alpha * (1 - weightScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SassColor _opacify(List<Value> arguments) {
|
||||||
|
var color = arguments[0].assertColor("color");
|
||||||
|
var amount = arguments[1].assertNumber("amount");
|
||||||
|
|
||||||
|
return color.changeAlpha(color.alpha + amount.valueInRange(0, 1, "amount"));
|
||||||
|
}
|
||||||
|
|
||||||
|
SassColor _transparentize(List<Value> arguments) {
|
||||||
|
var color = arguments[0].assertColor("color");
|
||||||
|
var amount = arguments[1].assertNumber("amount");
|
||||||
|
|
||||||
|
return color.changeAlpha(color.alpha - amount.valueInRange(0, 1, "amount"));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user