Here is the patch for November 17, 2011:
One of the problems with the previous example is that we only get one line width for all segments, and only one color (which we didn’t even bother to set). You could change these in the main loop, but you’d be disappointed; since the stroke() is not called until after the loop has drawn all the segments, only the last call will be used for the stroke() function.
In this updated version, we set the colors and locations (and call stroke) at each iteration. However, we also need to save the last position just before the stroke call. Once stroke is called, the path is lost – and therefore, the “current location” is 0,0. So we find the current location just before the stroke(), use that for the next iteration, and are rewarded with the ability to change the line width and color for each segment.
Nov 18, 2011 at 5:45am #214982