Drawing a line with color gradient using vertices

edited January 2017 in Questions about Code

Hello,

I want to draw a connected line that consists of n vertices. These n vertices have different colors, so there should be a gradient applied. However, I can't figure out the correct method to do so.

What I have so far (waypoints is a list with objects that have an assigned color and a PVector position):

pushMatrix();
  translate(map.getCenter().x, map.getCenter().y);
  beginShape();
  for(int i = 0; i < waypoints.size(); i++) { 
    noFill(); 
    stroke(waypoints.get(i).getColor());
    curveVertex(waypoints.get(i).getPosition().x, waypoints.get(i).getPosition().y);
  }
  endShape();
popMatrix();

This does not seem to work as the stroke is monochrome. Does anybody have an idea what I'm missing here? Is it only possible using lines(...) or is there also a way using vertices?

Thanks in advance!
ezkhimo

Tagged:

Answers

Sign In or Register to comment.