xxxxxxxxxx
85
let blinkTimer = 0;
let blinking = false;
let earWiggle = 0;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// Face
fill(255, 220, 180);
ellipse(200, 220, 300, 280);
// Ears
push();
translate(200, 220);
rotate(sin(earWiggle) * 0.1);
fill(255, 200, 160);
triangle(-100, -100, -140, -180, -40, -130);
pop();
push();
translate(200, 220);
rotate(-sin(earWiggle) * 0.1);
fill(255, 200, 160);
triangle(100, -100, 140, -180, 40, -130);
pop();
// Eyes
fill(255);
if (blinking) {
ellipse(150, 180, 60, 10);
ellipse(250, 180, 60, 10);
} else {
ellipse(150, 180, 60, 70);
ellipse(250, 180, 60, 70);
// Pupils
fill(30, 120, 50);
ellipse(150 + map(mouseX, 0, width, -10, 10), 180 + map(mouseY, 0, height, -10, 10), 30, 35);
ellipse(250 + map(mouseX, 0, width, -10, 10), 180 + map(mouseY, 0, height, -10, 10), 30, 35);
// Light reflections
fill(255);
ellipse(145 + map(mouseX, 0, width, -10, 10), 175 + map(mouseY, 0, height, -10, 10), 10, 10);
ellipse(245 + map(mouseX, 0, width, -10, 10), 175 + map(mouseY, 0, height, -10, 10), 10, 10);
}
// Nose
fill(255, 150, 150);
triangle(200, 240, 180, 260, 220, 260);
// Mouth
noFill();
stroke(0);
strokeWeight(2);
arc(200, 290, 80, 40, 0.1, PI - 0.1);
// Whiskers
line(140, 250, 60, 230);
line(140, 260, 60, 260);
line(140, 270, 60, 290);
line(260, 250, 340, 230);
line(260, 260, 340, 260);
line(260, 270, 340, 290);
// Blink logic
blinkTimer++;
if (blinkTimer > 180 && !blinking) {
blinking = true;
blinkTimer = 0;
} else if (blinking && blinkTimer > 10) {
blinking = false;
blinkTimer = 0;
}
// Ear wiggle when "petting"
if (dist(mouseX, mouseY, 200, 220) < 150) {
earWiggle += 0.2;
} else {
earWiggle = 0;
}
}