Animated Face

Code

int numFrames = 6;
int frame = 0;
int flap = 25;
int counter;
int red = 0;
int blue = 210;
void setup() {
size(300, 400);
smooth();
}

void draw() {

counter ++;

if (counter>=10&&counter<=60) {
flap = flap-1;
}
if (counter>=60&&counter<=110) {
flap = flap+1;
}
if (counter>=10&&counter<=70) {
red = red+3;
blue = blue-3;
}
if (counter>=70&&counter<=130) {
red = red-3;
blue = blue+3;
}

fill(red,0,blue);
ellipse(width/2, height/2, 200, 300); // head
fill(255);
ellipse(100, 180, 40, 40); // left eye
ellipse(186, 180, 40, 40); // right eye
fill(1);
ellipse(100, 180, flap, 10); // left pupil
ellipse(186, 180, 10, flap); // right pupil

fill(250,118,118);
ellipse(143, 280, 50, flap); // mouth

}

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