mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 13:51:31 +01:00
Clamp numbers in saturate() et al.
This commit is contained in:
parent
683f4afb40
commit
d0a31b0ade
@ -173,28 +173,32 @@ void defineCoreFunctions(Environment environment) {
|
||||
var color = arguments[0].assertColor("color");
|
||||
var amount = arguments[1].assertNumber("amount");
|
||||
return color.changeHsl(
|
||||
lightness: color.lightness + amount.valueInRange(0, 100, "amount"));
|
||||
lightness: (color.lightness + amount.valueInRange(0, 100, "amount"))
|
||||
.clamp(0, 100));
|
||||
});
|
||||
|
||||
environment.defineFunction("darken", r"$color, $amount", (arguments) {
|
||||
var color = arguments[0].assertColor("color");
|
||||
var amount = arguments[1].assertNumber("amount");
|
||||
return color.changeHsl(
|
||||
lightness: color.lightness - amount.valueInRange(0, 100, "amount"));
|
||||
lightness: (color.lightness - amount.valueInRange(0, 100, "amount"))
|
||||
.clamp(0, 100));
|
||||
});
|
||||
|
||||
environment.defineFunction("saturate", r"$color, $amount", (arguments) {
|
||||
var color = arguments[0].assertColor("color");
|
||||
var amount = arguments[1].assertNumber("amount");
|
||||
return color.changeHsl(
|
||||
saturation: color.saturation + amount.valueInRange(0, 100, "amount"));
|
||||
saturation: (color.saturation + amount.valueInRange(0, 100, "amount"))
|
||||
.clamp(0, 100));
|
||||
});
|
||||
|
||||
environment.defineFunction("desaturate", r"$color, $amount", (arguments) {
|
||||
var color = arguments[0].assertColor("color");
|
||||
var amount = arguments[1].assertNumber("amount");
|
||||
return color.changeHsl(
|
||||
saturation: color.saturation - amount.valueInRange(0, 100, "amount"));
|
||||
saturation: (color.saturation - amount.valueInRange(0, 100, "amount"))
|
||||
.clamp(0, 100));
|
||||
});
|
||||
|
||||
environment.defineFunction("grayscale", r"$color", (arguments) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user