// 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 int redVal = 256; // value to use in red component of the Stroke() command int redGap = 256/loopNum; // add this value for each new line. size(w,h); while(counter < loopNum){ stroke(redVal,0,0); redVal -= redGap; 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 ++; }