For this project, I wanted to make something cuter than last week’s face, so I mapped everything out in illustrator and then translated the shapes to js. This workflow was much more efficient and allowed me to create cartoon facial expressions since I wasn’t focused on generating the coordinates or RGB codes for every shape. Unfortunately wordpress cuts a bit of the right side off 🙁
sketch
var r=170;
var g=204;
var b=170;
var x= 300;
var dir= 1;
var speed= 5;
var mouth= 1;
function setup() {
createCanvas(640, 480);
text("p5.js vers 0.9.0 test.", 10, 15);
}
function mousePressed() {
mouth += 1;
if ( mouth > 3) {
mouth = 1;
}
}
function draw() {
if (mouth == 1) {
background(r, g, b);
fill(107,77,38); strokeWeight(0);
rect(111,168,374,329,45); fill(57,91,63); rect(94,509,411,168,100); fill(244,212,189); stroke(168,125,80) strokeWeight(2); rect(244,422,120,127,50); ellipse(478,286,60); ellipse(120,286,60); rect(130,130,340,340,150); fill(182,95,65); ellipse(300,394,104,85); strokeWeight(0);
fill(244,212,189); rect(220,334,160,52) stroke(168,125,80) strokeWeight(2); fill(255); rect(248,386,104,11); fill(244,212,189); ellipse(303,335,41,26); strokeWeight(0);
rect(254,307,52,63); fill(96,57,19); ellipse(218,279,91,83); ellipse(381,279,91,83); fill(255); ellipse(222,280,88,83); fill(119,119,75); ellipse(222,280,52,49); fill(0); ellipse(222,280,31,29); fill(255); ellipse(232,272,10,17); fill(255); ellipse(377,280,88,83); fill(119,119,75); ellipse(377,280,52,49); fill(0); ellipse(377,280,31,29); fill(255); ellipse(387,272,10,17); fill(244,212,189); ellipse(201,324,133,83); ellipse(402,324,133,83); fill(242,200,189); ellipse(203,338,107,83); ellipse(396,338,107,83); fill(96,57,19); triangle(165,280,174,279,173,286); triangle(168,273,175,273,174,278); triangle(435,280,426,279,426,285); triangle(425,273,425,278,431,273); fill(107,77,38); ellipse(300,140,300,83); ellipse(139,202,57,115); ellipse(459,202,57,115); ellipse(213,165,180,105); ellipse(385,165,180,105); }
if (mouth == 2) {
background(221,168,181);
fill(107,77,38); strokeWeight(0);
rect(111,168,374,329,45); fill(57,91,63); rect(94,509,411,168,100); fill(244,212,189); stroke(168,125,80) strokeWeight(2); rect(244,422,120,127,50); ellipse(478,286,60); ellipse(120,286,60); rect(130,130,340,340,150); fill(182,95,65); ellipse(300,394,104,85); strokeWeight(0);
fill(244,212,189); rect(220,344,160,57); stroke(168,125,80); strokeWeight(2); line(249,400,351,400); fill(244,212,189); ellipse(303,335,41,26); strokeWeight(0);
rect(254,307,52,63); fill(96,57,19); ellipse(218,279,91,83); ellipse(381,279,91,83); fill(255); ellipse(224,280,82,83); fill(119,119,75); ellipse(222,275,52,49); fill(0); ellipse(222,275,31,29); fill(255); ellipse(232,272,10,17); fill(255); ellipse(375,280,82,83); fill(119,119,75); ellipse(377,275,52,49); fill(0); ellipse(377,275,31,29); fill(255); ellipse(387,272,10,17); fill(244,212,189); ellipse(210,320,133,83); ellipse(393,320,133,83); fill(250,200,189); ellipse(203,338,107,83); ellipse(396,338,107,83); fill(96,57,19); triangle(165,280,174,279,173,286); triangle(168,273,175,273,174,278); triangle(435,280,426,279,426,285); triangle(425,273,425,278,431,273); fill(107,77,38); ellipse(300,140,300,83); ellipse(139,202,57,115); ellipse(459,202,57,115); ellipse(213,165,180,105); ellipse(385,165,180,105); fill(221,168,181); ellipse(300,450,44,39); fill(182,95,65); ellipse(300,418,63,33); strokeWeight(0);
fill(124,54,36); ellipse(306,431,12,24) ellipse(294,431,12,24) fill(221,168,181); rect(287,433,26,14); strokeWeight(3);
stroke(182,95,65); line(300,434,300,458) } else if (mouth == 3){
background(200,200,255); fill(107,77,38); strokeWeight(0);
rect(111,168,374,329,45); fill(57,91,63); rect(94,509,411,168,100); fill(244,212,189); stroke(168,125,80) strokeWeight(2); rect(244,422,120,127,50); ellipse(478,286,60); ellipse(120,286,60); rect(130,130,340,340,150); fill(244,212,189); ellipse(303,335,41,26); strokeWeight(0);
rect(254,307,52,63); fill(96,57,19); ellipse(218,279,91,83); ellipse(381,279,91,83); fill(255); ellipse(222,280,92,87); fill(119,119,75); ellipse(222,280,52,49); fill(0); ellipse(222,280,31,29); fill(255); ellipse(232,272,10,17); fill(255); ellipse(377,280,92,87); fill(119,119,75); ellipse(377,280,52,49); fill(0); ellipse(377,280,31,29); fill(255); ellipse(387,272,10,17); fill(244,212,189); ellipse(201,330,133,83); ellipse(402,330,133,83); fill(242,200,189); ellipse(203,338,107,83); ellipse(396,338,107,83); fill(96,57,19); triangle(165,280,174,279,173,286); triangle(168,273,175,273,174,278); triangle(435,280,426,279,426,285); triangle(425,273,425,278,431,273); fill(107,77,38); ellipse(300,140,300,83); ellipse(139,202,57,115); ellipse(459,202,57,115); ellipse(213,165,180,105); ellipse(385,165,180,105); stroke(168,125,80); strokeWeight(2);
fill(182,95,65); ellipse(300,412,40,53); }
if (mouseX > width/2 & mouseY > height/2){
strokeWeight(4);
stroke(119,119,75); line(583,300,583,350); fill(57,91,63); strokeWeight(0);
rect(548,411,69,138,20); fill(244,212,189); stroke(168,125,80); strokeWeight(2); rect(584,335,21,60,20); rect(552,349,60,21,20); rect(552,369,60,21,20); rect(552,390,60,21,20); strokeWeight(0);
rect(583,350,21,60,20); fill('white'); rect(583,292,19,19,19); rect(564,292,19,19,19); rect(559,275,19,19,19); rect(573,266,19,19,19); rect(588,275,19,19,19); fill(255,206,0); rect(573,281,19,19,19); }
if( mouseX > width/2 & mouseY < height/2){
strokeWeight(4);
stroke(119,119,75); line(583,300,583,350); fill(57,91,63); strokeWeight(0);
rect(548,411,69,138,20); fill(244,212,189); stroke(168,125,80); strokeWeight(2); rect(584,335,21,60,20); rect(552,349,60,21,20); rect(552,369,60,21,20); rect(552,390,60,21,20); strokeWeight(0);
rect(583,350,21,60,20); fill(240,230,255); rect(583,292,19,19,19); rect(564,292,19,19,19); rect(559,275,19,19,19); rect(573,266,19,19,19); rect(588,275,19,19,19); fill('white'); rect(573,281,19,19,19); }
if( mouseX < width/2 & mouseY > height/2){
fill(57,91,63); strokeWeight(0);
rect(548,411,69,138,20); fill(244,212,189); stroke(168,125,80); strokeWeight(2); rect(584,315,21,60,20); rect(552,349,60,21,20); rect(552,369,60,21,20); rect(552,390,60,21,20); strokeWeight(0);
rect(583,350,21,60,20);
}
else if (mouseX < width/2 & mouseY < height/2){
strokeWeight(0);
fill(57,91,63); rect(548,411,69,138,20); fill(244,212,189); stroke(168,125,80); strokeWeight(2); rect(584,335,21,60,20); rect(552,349,60,21,20); rect(552,369,60,21,20); rect(552,390,60,21,20); strokeWeight(0);
rect(583,350,21,60,20); fill('white'); rect(547,259,63,90,30); rect(556,217,12,58,30); rect(588,217,12,58,30); strokeWeight(4);
stroke(0);
fill(0);
point(563,282); point(592,282); triangle(577,290,580,299,574,299); strokeWeight(2);
line(577,299,577,308); line(577,308,583,312); line(577,308,569,312); }
}