// Example 6-6: Legs with a for loop size(480, 270); background(255); int y = 80; // Vertical location of each line int spacing = 10; // How far apart is each line int len = 20; // Length of each line // Translation of the legs while loop to a for loop. // THREE ;-SEPARATED SECTIONS OF THE FOR LOOP ARE: // 1. VARIABLE INITIALIZATION WHEN YOU START THE LOOP. // 2. TEST CODE THAT RUNS AT THE TOP OF THE LOOP. // 3. VARIABLE UPDATE CODE THAT RUNS BEFORE THE 2ND & SUBSEQUENT LOOP TESTS for (int x = 50, z = 60; x <= 150; x += spacing, z = z + spacing) { line(x, y, z, y + len); } /* THE FOLLOWING CODE HAS THE SAME EFFECT AS THE ABOVE FOR LOOP for (int x = 50 ; x <= 150; x += spacing) { line(x, y, x, y + len); } int x = 50 ; // declare variable x and initialize it. while (x <= 150) { line(x, y, x, y + len); x += spacing ; // Update loop control variable } */