Create polyline using independent color from each point

Is there some method to create polyline using independent color from each point?

each point owns the unique color.
and the color of the polyline is interpolated by each point.