I am currently trying to make a rainbow trail that follows your mouse. i used Linkedlist to plot the points of my mouse so the trail follows along. The trail itself looks pe
To get the effect you want, you are probably going to have to create a custom gradient paint that spans the gamut of hue along one axis and the range of alpha transparency along the other. As a related example, this KineticModel uses a RadialGradientPaint
to create an array of GradientImage instances. In each image, the alpha varies radially from 0xff
(1.0) at the center to 0x3f
(0.25) at the periphery.
Addendum: Based on your picture, just set the graphics context's Stroke
to a suitable width, set the paint to the next hue from your color lookup table (clut
), and drawLine()
. You can vary the hue, keeping the the saturation and brightness constant.
float N = 360;
Queue<Color> clut = new LinkedList<Color>();
for (int i = 0; i < N; i++) {
clut.add(Color.getHSBColor(i / N, 1, 1));
}
You'll have to decide when to change colors based on space or time. For the latter, javax.swing.Timer
is a good choice.