so got a question involving linear gradients in Java, using multiple colors. I am looking to get an RGB color at any point along agradient. Creating the gradient and painting it is easy, and i can get the fractions and colors for those colors i set.....
The issue i have is that i want to get an RGB color at any point along the gradient. to break it down, an example application would be the creation and display of a gradient in some JPanel with size of 255 (maxSize=255 (see below)). depending on the size of said JPanel (maxSize) the interpolation would be different (larger number in maxSize would result in more interpolated values). I would like to be able to grab the RGB value at any location along the gradient, you could almost equate it to being able to do the following...
grab the RGB value based on the location in the gradient
RGB_Values = p.getColorByGradientLocation(float locationInGradient);
or
grab the RGB value based off a specific value, somewhere between Point2D start and Point2D end
RGB_Values = p.getColorByValue(float value);
e.g setting gradient code
Point2D start = new Point2D.Float(0, 0);
Point2D end = new Point2D.Float(0, maxSize);
Color[] colors = {n number of colors};
dist[] = ((float) i / (float) colors.length); //equally distributes colors
p = new LinearGradientPaint(start, end, dist, colors, CycleMethod.NO_CYCLE);
Many Thanks