function setup() { createCanvas(400, 400); background(220); // test with different parameters body(240, 100, 80, 3); head(200, 100, 100); body(220, 200, 40, 6); head(200, 200, 50); body(204, 300, 8, 20); head(200, 300, 10); } function body(x, y, diam, repeat) { invert = 0; for (i = 0; i < repeat; i++) { if (invert == 0) { fill("rgb(0,200,0)"); invert = 1; } else { fill("rgb(0,255,0)"); invert = 0; } // shift x a bit for body part, make is a chain circle(x + i * diam * 0.8, y, diam); } } // x, y: the center of the head // diam: the diameter of the head function head(x, y, diam) { // [Your Code Here] fill("rgb(0,255,0)"); circle(x, y, diam); // eyes x_factor = diam * 0.15; y_factor = diam * 0.1; fill("rgb(0,0,0)"); circle(x - x_factor, y - y_factor, x_factor); fill("rgb(0,0,0)"); circle(x + x_factor, y - y_factor, x_factor); // mouths noFill(); arc(x, y + y_factor, x_factor * 2, x_factor * 2, 0, PI); }