31 lines
621 B
JavaScript
31 lines
621 B
JavaScript
function setup() {
|
|
createCanvas(400, 400);
|
|
background(220);
|
|
|
|
// test with different parameters
|
|
head(200, 100, 100);
|
|
head(200, 200, 50);
|
|
head(200, 300, 10);
|
|
}
|
|
|
|
// 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);
|
|
|
|
// mouth
|
|
noFill();
|
|
arc(x, y + y_factor, x_factor * 2, x_factor * 2, 0, PI);
|
|
}
|