xxxxxxxxxx
145
let value = 'Dancing Eggy';
function setup() {
createCanvas(400, 400);
frameRate(5);
angleMode(DEGREES);
}
function draw() {
background(220);
//BACKDROP
let r = random(50, 255);
let g = random(0, 255);
let b = random(30, 255);
//background(random(100,200))
background(r, g, b);
// background(220);
fill(106, 73, 64);
push();
stroke(0);
rect(290, 170, 100, 60, 20, 25, 25, 5);
rect(10, 170, 100, 60, 25, 15, 10, 25);
pop();
push();
stroke(80);
strokeWeight(4);
fill(50);
ellipse(200, 200, 330);
fill(120);
ellipse(200, 200, 280);
pop();
//face
let c1 = random(150, 200);
let c2 = random(c1, 230);
let r1 = random(30, 70);
let r2 = random(r1, 100);
let dia = r2 + r1;
if (c2 - c1 >= dia) {
r1 = r1 + r2;
}
let faceHeight = r2 + r1;
let faceWidth = r2;
let eye1X = c2 + r2 - r1 - faceHeight / 4;
let eye2X = c2 + r2 - r1 + faceWidth / 4;
let eye1Y = c2 - r2 / 4;
let eyeSize = random(faceWidth / 6, faceWidth / 4);
let light1X = eye1X - eyeSize / 6;
let light1Y = eye1Y - eyeSize / 6;
let light2X = eye2X - eyeSize / 6;
let light2Y = eye1Y - eyeSize / 6;
let lightSize = eyeSize / 3;
let mouthX = eye1X + faceWidth / 4;
let mouthY = eye1Y + faceWidth / 4 - 2;
let mouthSize = random(faceHeight / 6, faceHeight / 6);
let mouthDegree = random(mouseX / 10, mouseX / 20);
noStroke();
baigan(c1, c2, r1, r2);
//eye1
fill(0);
ellipse(eye1X, eye1Y, eyeSize);
//eye2
fill(0);
ellipse(eye2X, eye1Y, eyeSize);
//light1
fill(255);
ellipse(light1X + 1.5, light1Y + 1, lightSize, lightSize + 3);
//light2
fill(255);
ellipse(light2X + 1.5, light2Y + 1, lightSize, lightSize + 3);
//mouth
push();
stroke(220, 20, 60);
strokeWeight(2 + mouseX / 200 + mouseY / 120);
//fill(180, 240, 190);
fill(245, 105, 145);
rect(
mouthX,
mouthY,
mouthSize,
mouthSize,
mouthDegree,
0,
mouthDegree + 30,
mouthDegree
);
//arc(mouthX, mouthY, mouthSize, mouthSize, 0+mouthDegree, PI-mouthDegree);
pop();
text(value, 300, 350);
}
// character
function baigan(c1, c2, r1, r2) {
let col1 = (133, 106, 141);
let col2 = (148, 0, 211);
push();
noSmooth();
// fill(133, 106, 141);
fill(100, 40, 144);
ellipseMode(RADIUS);
ellipse(c1, c1, r1);
ellipse(c2, c2, r2);
pop();
//stem
push();
stroke(30, 200, 21);
strokeWeight(6);
noFill();
arc(c1, c1, 2 * r1, 2 * r1, 170, 240);
ellipse(c1 - r1 / 2, c1 - r1 + 2, 6, 8);
ellipse(c1 - r1, c1 - r1 / 2 + 2, 6, 8);
ellipse(c1 - r1 - 5, c1 + 10, 8, 6);
pop();
//color
push();
// noFill();
// stroke(180, 80, 211);
stroke(112, 77, 209);
strokeWeight(6);
// fill(208,180,208,99);
fill(138, 109, 217);
arc(c2 - 10, c2 + 15, r2 + 10, r2 + 10, 70, 160, OPEN);
pop();
}
function mousePressed() {
if (value == "Dancing Eggplant") {
value = "Eggplant Dancing";
} else value = "Dancing Eggplant";
}