I have never ever used IM and for now I'm reading the examples section which looks a little bit overwhelming for now

The problem I'm trying to solve is the following:
Having a PNG picture of a given size and an array of points data (each having XY-coordinates and a color value) build a connected path with multiple gradient stops on it.
It should look smth like this:

I guess the simpliest way to do it is to draw separate lines with rotated gradient (so i'll have to compute the angle somewhere in my app). But that way lines would not be connected and there would be ugly overlaps in cases where lines connect this way: /\
Also it would be very cool to round the corners a little bit (or make some kind of joint there), but that's optional.
Is it even possible to draw? Maybe there are some parts of documentation I should concentrate my attention on?