xxxxxxxxxx
153
let eyeSize = 50;
let leftEyeX = 200;
let rightEyeX = 300;
let eyeY = 225;
function setup() {
createCanvas(500, 500);
}
function draw() {
background('#6cccf5');
// Calculate distance from mouse to each eye separately
let distanceToLeftEye = dist(mouseX, mouseY, leftEyeX, eyeY);
let distanceToRightEye = dist(mouseX, mouseY, rightEyeX, eyeY);
// Change pupil size based on mouse distance
// Adjust the mapping so that the pupils start increasing from a smaller initial distance
let maxPupilSize = 50; // Maximum pupil size
let minDistanceForMaxSize = 450; // Adjust this distance for when the pupil reaches its maximum size
let pupilSize = map(min(min(distanceToLeftEye, distanceToRightEye), minDistanceForMaxSize), 0, minDistanceForMaxSize, maxPupilSize, 20);
pupilSize = constrain(pupilSize, 20, maxPupilSize); // Ensure pupilSize stays within a range
// cat body
push();
noStroke();
fill(80, 71, 70);
ellipse(250, 525, 400, 500);
pop();
// cat right ear (brown part)
push();
noStroke();
fill(80, 71, 70);
triangle(275, 127.5, 350, 75, 372.5, 225);
pop();
// cat left ear (brown part)
push();
noStroke();
fill(80, 71, 70)
triangle(127.5,225,150,75,225,127.5)
pop();
// ear foreground (pink part)
push();
noStroke();
fill(237, 175, 184);
// left
triangle(150, 200, 165, 115, 200, 150);
// right
triangle(300, 150, 335, 115, 350, 200);
pop();
// cat head
push();
fill(80, 71, 70);
circle(250, 250, 250);
pop();
// eye background
push();
noStroke();
fill(255, 255, 255);
// left
circle(leftEyeX, eyeY, 87.5);
// right
circle(rightEyeX, eyeY, 87.5);
// eye foreground
noStroke();
fill(59, 82, 73);
// left
circle(leftEyeX, eyeY, 65);
// right
circle(rightEyeX, eyeY, 65);
pop();
// eye pupil
fill(0);
ellipse(leftEyeX, eyeY, pupilSize, pupilSize);
ellipse(rightEyeX, eyeY, pupilSize, pupilSize);
// nose background color
push();
noStroke();
fill(237, 175, 184);
triangle(225, 275, 275, 275, 250, 300);
pop();
// nose
push();
stroke(0);
strokeWeight(4);
line(225, 275, 275, 275);
line(225, 275, 275, 325);
line(275, 275, 225, 325);
pop();
// whiskers
push();
stroke(0);
// left
line(100, 275 + mouseY / 8, 175, 285);
line(100, 300 + mouseY / 8, 175, 300);
line(100, 325 + mouseY / 8, 175, 315);
// right
line(325, 285, 400, 275 + mouseY / 8);
line(325, 300, 400, 300 + mouseY / 8);
line(325, 315, 400, 325 + mouseY / 8);
pop();
// cloud
push();
fill(255);
noStroke();
ellipse(1 + mouseX / 2, 40, 100, 50);
ellipse(40 + mouseX / 2, 50, 67, 32);
ellipse(70 + mouseX / 2, 51.5, 45, 24.5);
ellipse(mouseX / 2 - 50, 46.5, 60, 33.5);
pop();
// legs
stroke(64, 58, 57);
fill(80, 71, 70);
rect(137.5, 425, 50, 137.5, 50, 50, 25, 25); // left leg
// leg lines 1
push();
stroke(64, 58, 57);
strokeWeight(5);
line(177.5, 475, 177.5, 500);
line(162.5, 475, 162.5, 500);
line(147.5, 475, 147.5, 500);
pop();
// legs 2
stroke(64, 58, 57);
fill(80, 71, 70);
rect(312.5, 425, 50, 137.5, 50, 50, 25, 25); // right leg
// leg lines 2
push();
stroke(64, 58, 57);
strokeWeight(5);
line(322.5, 475, 322.5, 500);
line(337.5, 475, 337.5, 500);
line(352.5, 475, 352.5, 500);
pop();
}