Skip to content

Commit

Permalink
Prevent duplicate positions in gradient fills (#1768)
Browse files Browse the repository at this point in the history
Fixes #1675
  • Loading branch information
gpeal authored Mar 22, 2021
1 parent 4deb885 commit 8ed9569
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/deploymentTargetDropDown.xml

# Gradle
.idea/**/gradle.xml
Expand Down
4 changes: 4 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ public GradientColor parse(JsonReader reader, float scale)
double value = array.get(i);
switch (i % 4) {
case 0:
// position
positions[colorIndex] = (float) value;
// Positions should monotonically increase. If they don't, it can cause rendering problems on some phones.
// https://github.com/airbnb/lottie-android/issues/1675
if (colorIndex > 0 && positions[colorIndex - 1] >= (float) value) {
positions[colorIndex] = (float) value + 0.01f;
} else {
positions[colorIndex] = (float) value;
}
break;
case 1:
r = (int) (value * 255);
Expand Down

0 comments on commit 8ed9569

Please sign in to comment.