//Crystal Xue
//15104-section B
//luyaox@andrew.cmu.edu
//Project_06
var eyeballSize = 180;
var eyeChange = 20;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(230, 194, 152);
frameRate(600);
var h = hour();
var m = minute();
var s = second();
var eyeWidth = 150;
//eyebag
translate(120, 400)
fill(210, 180, 152);
noStroke();
beginShape();
for (var i = - 1; i < 12; i++) {
curveVertex(0.1 * PI * eyeWidth * i - 50, sin(0.1 * i * PI) * (110 + m) - 50);
}
endShape();
//drawing the eye shape
translate(-50, - 100);
stroke(0);
strokeWeight(10);
fill(255);
//drawing upper half of the eye
beginShape();
for (var i = -1; i < 12; i++) {
curveVertex(0.1 * PI * eyeWidth * i, -sin(0.1 * i* PI) * (110 + m));
}
endShape();
//drawing lower half of the eye
fill(255);
beginShape();
for (var i = - 1; i < 12; i++) {
curveVertex(0.1 * PI * eyeWidth * i, sin(0.1 * i * PI) * (110 + m));
}
endShape();
//change of eyeball colors
var r1 = 200 + 25 * sin(millis() / 100.0 );
var g1 = 200 + 25 * sin(millis() / 100.0 + HALF_PI);
var b1 = 200 + 25 * sin(millis() / 100.0 - HALF_PI);
var eyeballX = 5 * h;
var eyeballY = 0;
x = sin(frameCount / 10) * eyeChange;
y = cos(frameCount / 10) * eyeChange;
//drawing eyeball
translate(200, 0);
noStroke();
fill(r1, g1, b1);
ellipse(eyeballX, eyeballY, eyeballSize + x, eyeballSize + y);
if (s % 2 == 0) {
fill(0);
ellipse(eyeballX, eyeballY, 100, 100);
fill(255);
ellipse(eyeballX + 20, eyeballY - 20, 10, 10);
}else {
fill(0);
ellipse(eyeballX, eyeballY, 130, 130);
fill(255);
ellipse(eyeballX + 20, eyeballY -20, 15, 15);
}
//closing lid and eye bag when tired
if (h < 8) {
translate(-200,0);
fill(230, 194, 152);
stroke(0);
strokeWeight(10);
beginShape();
for (var i = -1; i < 12; i++) {
curveVertex(0.1 * PI * eyeWidth * i, -sin(0.1 * i* PI)* (110 + m));
}
endShape();
}
}
This is a project represent a normal student eye in a day. The pupil is changing its size every second, and the eye size is increasing based on minutes. And the entire eyeball is moving from left to right based on hours. during sleeping hours (12:00 – 8:00 am) the top eyelid is closed because of fatigues.