I’m from a 3D rendering background where this is trivial to do, but I can’t find how to do this in Java2D:
Say I have points A, B and colors cA, cB.
The points are joined together by a quadTo() command and stroked. I want the colors to smoothly interpolate between each point. i.e. point A is color cA, point B is color cB, and the color of the line between A and B linearly interpolates between cA and cB.
I’ve tried stroking with a gradient fill but for my purposes it is far too slow, and also produces inaccurate results since I am actually joining up hundreds of these curve segments into continuous paths (using GeneralPath).
Is good ‘ole point to point linear color interpolation not supported in Java2D?
The answer is: you can’t do it. Java2D doesn’t support this operation.