void setup() { size(300, 400); ladder(50, 50, 20, 200, 10); ladder(100, 50, 40, 300, 30); ladder(175, 200, 80, 80, 3); } /* Render a ladder with the following characteristics. It should have top-left corner at (x,y), width w and total height h, and then n evenly spaced rungs */ void ladder(int x, int y, int w, int h, int n) { line(x, y, x, y+h); line(x+w, y, x+w, y+h); float gap = 1.0 * h / (1+n); // with n rungs, we consider n+1 gaps for (int r=1; r <= n; r++) { line(x, y+r*gap, x+w, y+r*gap); } }