xxxxxxxxxx
27
/*
* Creative Coding Workshop #4 Demo - Face
*
* Jack B. Du (github@jackbdu.com)
*/
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// draw faces at different coordinates with different diameters
face(100,100,200);
face(300,100,100);
face(300,300,80);
face(100,300,50);
}
function face(x, y, d) {
// draw face contour at (x, y) with a specified contour diameter
circle(x,y,d);
// draw left eye based on (x, y) and specified contour diameter
circle(x-d/5,y-d/10,d/4);
// draw left eye based on (x, y) and specified contour diameter
circle(x+d/5,y-d/10,d/4);
}