// Code-and-me class code, May 20th // Goal: Create an image with evenly spaced horizontal lines // Step 3: Lets take advantage of the repetative nature of our code, and use a while{} statement for a loop int h = 200; // height int w = 200; // width int yGap = 5; // the gap (on Y axis) to create between each line. int yPos = 0; // The variable that will define y position for each line. int counter = 0; // a counter variable for our loop int loopNum = h/yGap; // math for getting the number of lines to draw .. // .. depending on the hight of our stage and the gap between each line size(w,h); while(counter < loopNum){ //line(0,yPos, w,yPos); //line(200, 0, counter, yPos); line(0,0,200, yPos); yPos += yGap; // same as: ypos = ypos + yGap --> set yPos to its own value plus yGap --> increase yPos by yGap counter ++; }