The lookup of lower and upper bound precisely at a gradient stop will pick the neighbors on both sides instead of just going with the actual one. This results in interpolated color that could be quite fare off.
Example with stops defines for 0.2, 0.4, 0.6, 0.8 and 1.0 The position is 0.4 and the lower and upper bound is set to 0.2 and 0.6 in stead of just picking 0.4 for one or both. I believe the fix would be to include an equal in one or both of the compare's of method getCoulorAt(…) in tools.
public Color getColorAt(final double POSITION_OF_COLOR) {
…
if (Double.compare(fraction,POSITION) < 0) {
lowerBound = stops.get(fraction);
}
if (Double.compare(fraction, POSITION) > 0) {
upperBound = stops.get(fraction);
break;
}
…
The lookup of lower and upper bound precisely at a gradient stop will pick the neighbors on both sides instead of just going with the actual one. This results in interpolated color that could be quite fare off. Example with stops defines for 0.2, 0.4, 0.6, 0.8 and 1.0 The position is 0.4 and the lower and upper bound is set to 0.2 and 0.6 in stead of just picking 0.4 for one or both. I believe the fix would be to include an equal in one or both of the compare's of method getCoulorAt(…) in tools.
public Color getColorAt(final double POSITION_OF_COLOR) { … if (Double.compare(fraction,POSITION) < 0) { lowerBound = stops.get(fraction); } if (Double.compare(fraction, POSITION) > 0) { upperBound = stops.get(fraction); break; } …