xxxxxxxxxx
74
//Part 1: Organize the portrait into functions
//Part 2: Make at least one function that takes arguments.
//Call this function as many times as you need to.
//Part 3 Extra: Look for a pattern or patterns and use a loop
function setup() {
createCanvas(400, 360);
}
function draw() {
background(240);
head();
eyes(100,40,20);
brows();
neck();
jaw();
nose(120,225,190);
mouth(150,190,250);
}
function head(){
fill(180, 100);
strokeWeight(2);
circle(200, 100, 150);
}
function eyes(x,y,z){
strokeWeight(2);
ellipse(x, x-20, y, z);
strokeWeight(1);
ellipse(210, x, y, z);
strokeWeight(3);
point(110, x-20);
point(220, x);
}
function brows(){
strokeWeight(1);
for (let i=0; i<4; i++){
line(90+10*i, 65, 100+10*i, 45);
}
//line(90, 65, 100, 45);
//line(100, 65, 110, 45);
//line(110, 65, 120, 45);
//line(120, 65, 130, 45);
line(195, 85, 205, 65);
line(205, 85, 215, 65);
line(215, 85, 225, 65);
line(225, 85, 235, 65);
}
function neck(){
strokeWeight(2);
triangle(160, height, 263, 202, 263, height);
}
function jaw(){
strokeWeight(1);
arc(175, 200, 175, 175, 0, HALF_PI, PIE);
}
function nose(x,y,z){
strokeWeight(1);
triangle(x, y, z, x-20, z, y);
}
function mouth(x,y,z){
strokeWeight(3);
line(x, z-5, y, z);
line(x+5, z+10, y, z);
}