How to change color along a curve? I have a curve, which has been made visible by using a circle as a bevel object. I would like the color to change along the length of the curve. In other words, the curve will start red, and then change to blue towards the end.

I have figured out how to make the color change as a function of a coordinate (in this case the x-coordinate), but I cannot figure out how to get the coordinate along the length of the curve so that I can pass it to the ColorRamp.





Any ideas?
The trick is to enable UV mapping on the curve and then use UV as the input texture coordinate. Then use can use the mapping node to rotate the default UV positioning to get the gradient to run along the length of the curve. Please note I had to adjust the X/Y scale factor to get the whole gradient to show on the curve.