Skip to content

Commit

Permalink
Clamp $alpha in adjust-color() with HSL args
Browse files Browse the repository at this point in the history
Closes #708
  • Loading branch information
nex3 committed Jul 3, 2019
1 parent 7bfba04 commit 2105a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

[plain-CSS invert]: https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/invert

* The `adjust-color()` function no longer throws an error when a large `$alpha`
value is combined with HSL adjustments.

* The `alpha()` function now produces clearer error messages when the wrong
number of arguments are passed.

Expand Down
2 changes: 1 addition & 1 deletion lib/src/functions/color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ final _adjust = BuiltInCallable("adjust", r"$color, $kwargs...", (arguments) {
hue: color.hue + (hue ?? 0),
saturation: (color.saturation + (saturation ?? 0)).clamp(0, 100),
lightness: (color.lightness + (lightness ?? 0)).clamp(0, 100),
alpha: color.alpha + (alpha ?? 0));
alpha: (color.alpha + (alpha ?? 0)).clamp(0, 1));
} else if (alpha != null) {
return color.changeAlpha((color.alpha + (alpha ?? 0)).clamp(0, 1));
} else {
Expand Down

0 comments on commit 2105a13

Please sign in to comment.