Syntax of loops:
Anatomy of a for loop:
for (int y = 0; y < height; y += 15) { stroke(0); rect(10,y,10,10); }
Anatomy of a nested loop:
for (int y = 0; y < height; y += 15) { for (int x = 0; x < height; x += 25) { stroke(0); rect(x, y, 10, 10); } }
LOOP EXERCISES!!
For these exercises, you may not use the mouse button, use mouse location system variables mouseX and mouseY. Restrict yourself to black and white.
L1 — Interaction and Iteration: One Line
Develop a composition which in which one (straight) line responds to the position of the cursor.
L2 — Interaction and Iteration: Ten Lines
Develop a composition which in which ten straight lines respond to the cursor.
L3 — Interaction and Iteration: 100 Lines
Develop a composition which in which one hundred lines respond to the cursor.
L4 — Interaction and Iteration: 1000 Lines
Develop a composition which in which one thousand lines respond to the cursor.