Timed Animated Face

 

PFont text;
int s;
float leftX = 100;
float leftY = 180;
float rightX = 186;
float rightY = 180;
float mouth = 280;
float open;
float blink;
float rectX = 135;
float rectY = 250;
float eyes;
float expand = 40;

void setup() {
text = createFont(“Vernada”, 24);
textFont(text);
size(300, 400);
smooth();
}

void draw() {
s = second();
background(255);
fill(50);
text(s, 20, 20);

fill(240,200,255);
ellipse(width/2, height/2, 200, 300); // head

// Blinking Eyes —————–

stroke(0);
fill(eyes);
ellipse(100, 180, expand, blink); // left eye
if (s >= 0){
blink = 10;
}
if (s >= 1){
blink = 40;
}
if (s >= 0){
eyes = 255;
}
if (s >= 20){
eyes = random(255);
}
if (s >= 22){
expand = expand + 1;
}
if (s >= 23){
expand = 40;
}

stroke(0);
fill(eyes);
ellipse(186, 180, expand, blink); // right eye
if (s >= 0){
blink = 10;
}
if (s >= 1){
blink = 40;
}
if (s >= 0){
eyes = 255;
}
if (s >= 20){
eyes = random(255);
}
if (s >= 22){
expand = expand + 1;
}
if (s >= 23){
expand = 40;
}

// Moving pupils —————–

fill(1);
ellipse(leftX, leftY, 10, 10); // left pupil
if (s >= 5){
leftX = leftX + 0.25;
leftY = leftY + 0.25;
}
if (s >= 6){
leftX = 100;
leftY = 180;
}
fill(1);
ellipse(rightX, rightY, 10, 10); // right pupil
if (s >= 5){
rightX = rightX – 0.25;
rightY = rightY + 0.25;
}
if (s >= 6){
rightX = 186;
rightY = 180;
}

// Mouth Opening —————–

fill(240, 0, 0);
noStroke();
ellipse(143, mouth, 50, open); // mouth
if (s >= 5){
mouth = mouth – 0.5;
}
if (s >= 6){
mouth = 280;
}
if (s >= 10){
open = open + 1;
}
if (s < 10){
open = 1;
}
if (s >= 12){
open = 1;
}

}

Advertisements
This entry was posted in Interactive, Time Based and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s