xxxxxxxxxx
84
let eyex1, eyex2, eyey1, eyey2;
let br, bb, gr;
function setup() {
createCanvas(400, 400);
eyex1 = 172;
eyex2 = 262;
eyey = 180;
//reating a new random color for the clothes everytime the sketch was run
br = random (255);
bb = random (255);
bg = random (255);
}
function draw() {
background(random(200), 60, 219);
//Body
fill(br, bb, bg);
noStroke();
rectMode(CENTER);
rect(200, 370, 230, 130, 40);
//Neck
fill(204, 138, 53);
rectMode(CENTER);
rect(200, 300, 70, 40, 20);
//Face
fill(235, 159, 61);
rectMode(CENTER);
rect(200, 200, 170, 200, 20, 20, 70, 70);
//Eyes
fill(255);
ellipse(160, 180, 40);
ellipse(250, 180, 40);
//Eye balls
fill(0);
ellipse(eyex1, eyey, 15);
ellipse(eyex2, eyey, 15);
//moving the eyeballs with mouse
eyex1 = constrain(mouseX, 147, 172);
eyex2 = constrain(mouseX, 237, 262);
eyey = constrain(mouseY, 167.5, 192.5);
//Eyebrows
noFill();
stroke(0);
strokeWeight(10);
arc(160, 155, 40, 40, 35, 50);
arc(250, 155, 40, 40, 35, 50);
//Mouth
strokeWeight(5);
//showing a smilling face when mouse is in the canvas
if (mouseX > width | mouseY > height) {
arc(200, 280, 80, 70, 16, 12);
} else {
arc(200, 230, 80, 70, 120, 166);
}
//Hair
fill(0);
noStroke();
triangle(115, 120, 115, 60, 170, 100);
triangle(200, 50, 115, 100, 200, 100);
triangle(230, 40, 145, 100, 250, 100);
triangle(260, 40, 145, 100, 270, 100);
triangle(285, 60, 240, 100, 285, 120);
//Arms
stroke(255);
strokeWeight(4);
line(130, 350, 130, 400);
line(280, 350, 280, 400);
}