void setup() { size(1000,500); drawScene(0, 0, 1000, 500, 255); save("recursiveScene.jpg"); } // draw scene having width w and height h, anchored with // top left corner at (x,y). Shading controls background color void drawScene(float x, float y, float w, float h, float shading) { if (h > 5) { noStroke(); fill(shading); rect(x, y, w, h); // white background // screen on wall float pad = 0.005*w; stroke(0); strokeWeight(2*pad); fill(112, 128, 144); rect(x+0.17*w, y+0.06*h, 0.5*w, 0.5*h); // fill(0,255,0); // rect(x+0.17*w+pad, y+0.06*h+pad, 0.5*w-2*pad, 0.5*h-2*pad); drawScene(x+0.17*w+pad, y+0.06*h+pad, 0.5*w-2*pad, 0.5*h-2*pad, 0.9*shading); // people drawPerson(x+0.55*w, y+h/2, h/16, color(255,0,0)); drawPerson(x+0.75*w, y+h/2, h/16, color(0,0,255)); // sofa stroke(0); strokeWeight(0.005*w); fill(222, 184, 135); rect(x+0.29*w, y+0.7*h, 2*w/3, 4*h/15); } } // draw person with head centered at (x,y) having radius r void drawPerson(float x, float y, float r, color c) { noStroke(); fill(c); ellipse(x, y, 2*r, 2*r); // head stroke(c); strokeWeight(0.12*r); line(x,y,x,y+4*r); line(x, y+2*r, x-2*r, y); line(x, y+2*r, x+2*r, y); }