Interactive Authoring-Animated Face

 

Code:

int counter;
int interval=200;
int intervalC=300;
int intervalB=50;
int Reyeheight=40;
int LeyeX=100;
int ReyeX=186;
int Leyeheight=40;
int eyeY=180;
int pheight=10;
int Mheight=1;
int Mwidth=50;
PFont font;

void setup() {
size(300, 400);
smooth();
font= createFont(“Times”, 20);
}
void draw() {
background(100);
text (counter, 20, 20);
fill(255);
counter ++;

if (counter >= intervalB &&counter <= intervalB+30 &&eyeY <= 186 ) {//pupils move down

eyeY=eyeY+1;
}
if (counter >= intervalB+100 && eyeY>=180 ) { //pupils move back in place
eyeY=eyeY-1;
}
if (counter >= interval && ReyeX<=190 && LeyeX<=104 && counter <= interval+30) { //pupils move right

ReyeX=ReyeX+1;
LeyeX=LeyeX+1;
}
if (counter >= interval && Leyeheight<=40 &&Leyeheight>=30 && counter <= interval+30) {//Left eye squints
Leyeheight=Leyeheight-1;
}

if (counter >= interval && Reyeheight<=40 &&Reyeheight<=90 && counter <= interval+30) {//Right eye gets big
Reyeheight = Reyeheight+1;
}

if (counter >= intervalC) {
if (ReyeX >= 182 && LeyeX >= 96 && counter <= intervalC+30) { //pupils move left

ReyeX = ReyeX-1;
LeyeX = LeyeX-1;
if (Leyeheight<=45 && counter <= intervalC+30) {//Left eye gets big
Leyeheight=Leyeheight+1;
if (Reyeheight>=30 && counter <= intervalC+30) {
Reyeheight = Reyeheight-1;
}
}
}
}
if (counter >= intervalC+100) {
if (Reyeheight <= 40) {
Reyeheight = Reyeheight+1;
}
if (ReyeX <= 186 && LeyeX <= 100 && counter >= intervalC+100) {
ReyeX = ReyeX+1;
LeyeX = LeyeX+1;
}
}
if (counter >= intervalC+200) {
if (eyeY >= 174) {
eyeY = eyeY-1;
}
if (Mwidth <= 80 && Mheight <= 95 && counter <= intervalC+230) {
Mwidth=Mwidth+1;
Mheight=Mheight+1;
}
if (Mwidth >= 50 && Mheight >= 1 && counter >= intervalC+250) {
Mwidth=Mwidth-1;
Mheight=Mheight-1;
}
if (counter >= intervalC+300) {
counter=0;
}
}
fill (247, 228, 184);
ellipse(width/2, height/2, 200, 300); // head
fill (255);
ellipse(100, 180, 40, Leyeheight); // left eye
ellipse(186, 180, 40, Reyeheight); // right eye
fill(1);
ellipse(LeyeX, eyeY, 10, pheight); // left pupil
ellipse(ReyeX, eyeY, 10, 10); // right pupil

fill(255);
ellipse(143, 280, Mwidth, Mheight); // mouth
}

Advertisements
This entry was posted in Interactive 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