Closed cainja closed 3 weeks ago
@jessicasyu
I am a little confused about the desired functionality in the Colors class, as this method touches a lot of UI functionality.
How should the colors be interpolated when given nonlinear values?
Specific proposed unit test in question:
@Test
public void getRGB_NonlinearColorsCalledBetweenMinAndMax_returnsInterpolatedColor() {
Colors colors = new Colors(new Color[] {
new Color(0, 0, 0, 0),
new Color(100, 100, 100, 0),
new Color(200, 200, 200, 200),
}, new double[] { 0, 0.1, 1});
assertEquals(new Color(0, 0, 0, 0).getRGB(), colors.getRGB(0));
assertEquals(new Color(50, 50, 50, 0).getRGB(), colors.getRGB(0.05));
assertEquals(new Color(100, 100, 100, 0).getRGB(), colors.getRGB(0.1));
assertEquals(new Color(200, 200, 200, 125).getRGB(), colors.getRGB(0.55));
assertEquals(new Color(200, 200, 200, 200).getRGB(), colors.getRGB(1));
}
1) Should colors.getColor(0.1)
return Color(100, 100, 100, 0)
?
2) Should the other colors be interpolated linearly between the specified values in the double array?
Yeah, if I remember correctly, this class is an implementation of MASON's ColorMap
that allowed for multiple colors in the gradient. I think the more effective solution is replacing it with the new CompositeColorMap
(which doesn't exist in the version of MASON we are using). We might want to update to MASON 22, but that is probably a separate issue.
To answer your questions:
colors.getColor(0.1)
should return Color(100, 100, 100, 0)
Colors is missing unit tests