Volume with lines

Hi there! I am drawing this origami folds simulating volume with a loop of lines in every side. But second side’s loop is not complete as I was expecting, following the red line you can see on the picture. Could anyone please tell me why?

void setup(){
size(1000,1000);
background(255);
stroke(0);
strokeWeight(1);

int num = 50;
for (float i=0; i<=num; i+=2) {

beginShape();
// x-Pos                            y-Pos
vertex(map(i, 0, num,  200,  800), map(i, 0, num,  400, 500));
vertex(map(i, 0, num,  300,  800), map(i, 0, num,  600, 500));
vertex(map(i, 0, num,  500,  800), map(i, 0, num,  200, 500));
endShape();
}
}

The default fill color is white, same as your background. Switch off the fill and it works.

void setup() {
  size(1000, 1000);
  background(255);
  stroke(0);
  strokeWeight(1);
  noFill();    // switch off the fill
  int num = 50;
  for (float i=0; i<=num; i+=2) {

    beginShape();
    // x-Pos                            y-Pos
    vertex(map(i, 0, num, 200, 800), map(i, 0, num, 400, 500));
    vertex(map(i, 0, num, 300, 800), map(i, 0, num, 600, 500));
    vertex(map(i, 0, num, 500, 800), map(i, 0, num, 200, 500));
    endShape();
  }
}
3 Likes