protected void endShapeStroke(int mode) {
    switch (shape) {
    case POINTS:
    {
      int stop = shapeLast;
      for (int i = shapeFirst; i < stop; i++) {
//        if (strokeWeight == 1) {
        addPoint(i);
//        } else {
//          addLineBreak();  // total overkill for points
//          addLine(i, i);
//        }
      }
    }
    break;

    case LINES:
    {
      // store index of first vertex
      int first = lineCount;
      int stop = shapeLast - 1;
      //increment = (shape == LINES) ? 2 : 1;

      // for LINE_STRIP and LINE_LOOP, make this all one path
      if (shape != LINES) addLineBreak();

      for (int i = shapeFirst; i < stop; i += 2) {
        // for LINES, make a new path for each segment
        if (shape == LINES) addLineBreak();
        addLine(i, i+1);
      }

      // for LINE_LOOP, close the loop with a final segment
      //if (shape == LINE_LOOP) {
      if (mode == CLOSE) {
        addLine(stop, lines[first][VERTEX1]);
      }
    }
    break;

    case TRIANGLES:
    {
      for (int i = shapeFirst; i < shapeLast-2; i += 3) {
        addLineBreak();
        //counter = i - vertex_start;
        addLine(i+0, i+1);
        addLine(i+1, i+2);
        addLine(i+2, i+0);
      }
    }
    break;

    case TRIANGLE_STRIP:
    {
      // first draw all vertices as a line strip
      int stop = shapeLast-1;

      addLineBreak();
      for (int i = shapeFirst; i < stop; i++) {
        //counter = i - vertex_start;
        addLine(i, i+1);
      }

      // then draw from vertex (n) to (n+2)
      stop = shapeLast-2;
      for (int i = shapeFirst; i < stop; i++) {
        addLineBreak();
        addLine(i, i+2);
      }
    }
    break;

    case TRIANGLE_FAN:
    {
      // this just draws a series of line segments
      // from the center to each exterior point
      for (int i = shapeFirst + 1; i < shapeLast; i++) {
        addLineBreak();
        addLine(shapeFirst, i);
      }

      // then a single line loop around the outside.
      addLineBreak();
      for (int i = shapeFirst + 1; i < shapeLast-1; i++) {
        addLine(i, i+1);
      }
      // closing the loop
      addLine(shapeLast-1, shapeFirst + 1);
    }
    break;

    case QUADS:
    {
      for (int i = shapeFirst; i < shapeLast; i += 4) {
        addLineBreak();
        //counter = i - vertex_start;
        addLine(i+0, i+1);
        addLine(i+1, i+2);
        addLine(i+2, i+3);
        addLine(i+3, i+0);
      }
    }
    break;

    case QUAD_STRIP:
    {
      for (int i = shapeFirst; i < shapeLast - 3; i += 2) {
        addLineBreak();
        addLine(i+0, i+2);
        addLine(i+2, i+3);
        addLine(i+3, i+1);
        addLine(i+1, i+0);
      }
    }
    break;

    case POLYGON:
    {
      // store index of first vertex
      int stop = shapeLast - 1;

      addLineBreak();
      for (int i = shapeFirst; i < stop; i++) {
        addLine(i, i+1);
      }
      if (mode == CLOSE) {
        // draw the last line connecting back to the first point in poly
        addLine(stop, shapeFirst); //lines[first][VERTEX1]);
      }
    }
    break;
    }