nannou
nannou copied to clipboard
How to draw a line with a color gradient?
We cannot pass a Gradient
object to a points_colored
, so how can we draw a line that has a color gradient according its path?
@bzm3r Maybe there's a better way and I haven't actually tried, but as a workaround you could try to render the gradient into a texture and use points_textured
instead.
I think this is shown in the draw_polyline
example. It doesn’t use Gradient specifically, but you can do it yourself. You have to manually apply the Gradient by setting the Gradient’s domain to the length of the line and using Gradient.get()
for each vertex.