Skip to content

Commit

Permalink
Fix gradient interpolation for opacity stops beyond the last color st…
Browse files Browse the repository at this point in the history
…op (#2377)

Fixes #2353
  • Loading branch information
gpeal authored Sep 2, 2023
1 parent 423665d commit 5ca7e90
Show file tree
Hide file tree
Showing 2 changed files with 450 additions and 1 deletion.
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);
}
}
}
Loading

0 comments on commit 5ca7e90

Please sign in to comment.