var eyeSize=20;
var eyeSkin=20;
var faceWidth = 120;
var faceHeight = 150;
var noseSize=20;
var noseDiff=7;
var word=0;
var wordNum=0;
var bodySize=200;
function setup() {
createCanvas(640, 480);
}
function draw() {
background(244,187,84);
//ears
stroke(156,171,50);
strokeWeight(15);
var x1=width/2-faceWidth/2-15;
var x2=width/2+faceWidth/2+15;
var y=height/2-noseDiff;
line(x1,y,x2,y);
fill(156,171,50);
noStroke();
triangle(x1+25,y,x1-10,y-15,x1-10,y+15);
triangle(x2-25,y,x2+10,y+15,x2+10,y-15);
//body
fill(220,220,200);
ellipse(width/2,height,bodySize*1.5,bodySize*2);
fill(68,63,52);
rectMode(CENTER);
rect(width/2,height,bodySize,bodySize);
//face size
noStroke();
fill(156,171,50);
ellipse(width/2,height/2,faceWidth,faceHeight);
//eye
fill(0);
var eyeL=width/2-faceWidth/4;
var eyeR=width/2+faceWidth/4;
var ibagL=width/2-faceWidth/4;
var ibagR=width/2+faceWidth/4;
ellipse(eyeL,height/2,eyeSize+2,eyeSize);
ellipse(eyeR,height/2,eyeSize+2,eyeSize);
fill(156,171,50);
ellipse(ibagL,height/2+5,eyeSize+8,eyeSize);
ellipse(ibagR,height/2+5,eyeSize+8,eyeSize);
//nose
fill(0);
ellipse(width/2,height/2+noseDiff-2,noseSize,noseSize);
fill(156,171,50);
ellipse(width/2,height/2+noseDiff,noseSize,noseSize);
//words
var word = int(wordNum);
if (word == 1) {
textSize(24);
noStroke();
fill(156,171,50);
text("ogres are like onions", width/2, height/4);
} else if (word == 2){
noStroke();
textSize(24);
fill(156,171,50);
text("ogres are onions",width/2, height/4);
} else if (word == 3){
noStroke();
textSize(24);
fill(156,171,50);
text("ogre onions", width/2, height/4);
}
}
function mousePressed(){
faceWidth=random(100,150);
faceHeight=random(100,170);
eyeSize=random(10,30);
noseSize=random(10,25);
bodySize=random(190,250);
word=random(1,4);
wordNum=random(1,4);
}
this was a fun project! I didn’t know what I was going to do when I first started but somehow I ended up with Shrek. I hope in the future I get to code more Shrek related projects.