Path colour/gradient

I’ve made my own audio thumbnail to draw a colored waveform that weights a colour or another based on most prominent frequencies. Initially I was doing it by drawing vertical lines where each line (that represents a certain amount of samples) had it’s own colour based on those frequencies. That was plain simple to do by setting the corresponding colour before each line drawing.
But the waveform looked clunky and ugly and I’m also planning to make it zoomable, so I redid it by, instead of drawVerticalLine from “top” to “bottom” points, I set a lineTo which will be then stroked in the path. The question now is: is there a way to set a colour for each line/section before stroking the whole path at once? Or as an alternative, some kind of mask over the path to be able to modify its colour by sections? I’ve tried making multiple paths (one for each line to draw) but it’s really inefficient

1 Like