Create eyes using symmetry;
to create the symmetric position of the right eye;
we must start from the x position of head (xh) + width of the head (headW) - distance to head side (35)
Draw mouth;
Now we can work on the style and get benefit from randomness to create variations of the existing attributes.
Try to determine min-max values that can change....
Let's move the mask into the center of the canvas.
To do that we can use push, translate, and pop methods again to move all parts of the mash without editing individual x and y positions of each variable.
line 44- push()
line 45- translate to the middle of the screen
line57- pop()
xxxxxxxxxx
// Head variables
let headW=150;
let headH=200;
let xh = 0;
let yh = 0;
// Eyes variables
let ye;
let xe;
let we;
let he;
// Ears variables
let xEar;
let yEar;
let wEar;
let hEar;
// Nose variables
let xn;
let yn;
let wn;
let hn;
// Mouth variables
let xm;
let ym;
let wm;
let hm;
// Array to hold colors
let colors = ["#5AAA95", "#087F8C", "#095256", "#86A873", "#BB9F06"]
function setup() {
createCanvas(600, 600);
background(255);
noLoop();
}
function draw() {
noStroke();
// Draw head
// fill the rect with the first color by setting index 0
fill(colors[0]);
// With additional 4 parameters
// 40:set roundness of the top-left corner of the rect
// 40:set roundness of the top-right corner of the rect
// 70:set roundness of the bottom-right corner of the rect
// 70:set roundness of the bottom-left corner of the rect
rect(xh, yh, headW, headH, 40, 40, 70, 70);
}