Skip to content

Commit

Permalink
Fix wrong order of lerp when parsing of color stops (#324)
Browse files Browse the repository at this point in the history
The `_getColorInBetweenColorStops` interpolated between color stops with
the order of stops inverted between the two it should interpolate with
(comparing with `_getColorInBetweenOpacityStops` confirms this as well).
This means that if there is more than two stops in the gradient, the
second color in the gradient never appears and the third one takes its
place, and the colors are on the wrong stop after that.
  • Loading branch information
idlewan authored Dec 18, 2023
1 parent c7066ca commit 9f4a8d7
Show file tree
Hide file tree
Showing 10 changed files with 679 additions and 1 deletion.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/src/parser/gradient_color_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class GradientColorParser {
var upperColor = colorStopColors[i];
var lowerColor = colorStopColors[i - 1];
return GammaEvaluator.evaluate(
percentage, upperColor.withOpacity(1), lowerColor.withOpacity(1))
percentage, lowerColor.withOpacity(1), upperColor.withOpacity(1))
.withOpacity(opacity);
}
throw Exception('Unreachable code.');
Expand Down
Binary file modified test/goldens/all/Tests/gradientopacityinterpolation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/Tests/gradientwithvaryingopacitystops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/Tests/interpolatebetweenopacitystops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/Tests/miterlimit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/gradientcolorinterpolation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/lottiefiles/fabulous_onboarding_animation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/goldens/all/lottiefiles/rocket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9f4a8d7

Please sign in to comment.