Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gradient interpolation for opacity stops beyond the last color stop #2377

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ int getColorInBetweenColorStops(float position, float opacity, float[] colorStop
if (colorStopPosition < position && i != colorStopPositions.length - 1) {
continue;
}
if (i == colorStopPositions.length - 1 && position >= colorStopPosition) {
return Color.argb(
(int) (opacity * 255),
Color.red(colorStopColors[i]),
Color.green(colorStopColors[i]),
Color.blue(colorStopColors[i])
);
}
// We found the position in which position is between i - 1 and i.
float distanceBetweenColors = colorStopPositions[i] - colorStopPositions[i - 1];
float distanceToLowerColor = position - colorStopPositions[i - 1];
Expand Down Expand Up @@ -264,4 +272,4 @@ protected static float[] mergeUniqueElements(float[] arrayA, float[] arrayB) {

return Arrays.copyOf(mergedNotTruncated, mergedNotTruncated.length - numDuplicates);
}
}
}