Face Animation

 

int pupilX = 0;
int pupilY = 0;
int mouth = 1;
int step = 0;
int counter;
int intervalCounter = 3;
int intervalMove = 1;
int intervalColor = 20;
int intervalBck = 10;
float transBlsh = 0;
float transBck = 0;
void setup() {
size(300, 400);
smooth();
}
void draw() {
background (0);
noStroke();
fill (204, 0, 0, transBck);
rect (0, 0, 300, 400);
stroke(0);
fill(255, 218, 185);
ellipse(width/2, height/2, 200, 300); // head
fill(255);
ellipse(100, 180, 40, 40); // left eye
ellipse(186, 180, 40, 40); // right eye
stroke(78,46,40);
strokeWeight (2);
fill(0);
ellipse(pupilX+100, pupilY+180, 10, 10); // left pupil
ellipse(pupilX+186, pupilY+180, 10, 10); // right pupil

strokeWeight(1);
stroke(0);
fill(255);
ellipse(143, 280, 20, mouth); // mouth

noStroke();
fill (255, 192, 203, transBlsh);
ellipse (100, 225, 50, 25);
ellipse (190, 225, 50, 25);

counter ++;
if (counter >= intervalCounter) {
counter = 0;
step ++;
if (step > 50){
step = 0;
pupilX = 0;
pupilY = 0;
transBlsh = 0;
transBck = 0;
}
if (step == 0) {
pupilX = pupilX + intervalMove;
}
if (step == 1) {
pupilX = pupilX + intervalMove;
}
if (step == 2) {
pupilX = pupilX + intervalMove;
}
if (step == 3) {
pupilX = pupilX + intervalMove;
}
if (step == 4) {
pupilX = pupilX + intervalMove;
}
if (step == 5) {
pupilX = pupilX + intervalMove;
}
if (step == 6) {
pupilX = pupilX + intervalMove;
}
if (step == 7) {
pupilX = pupilX + intervalMove;
}
if (step == 8) {
pupilX = pupilX + intervalMove;
}
if (step == 9) {
pupilX = pupilX + intervalMove;
}
if (step == 10) {
pupilX = pupilX + intervalMove;
}
if (step == 11) {
pupilX = pupilX + intervalMove;
}
if (step == 12) {
pupilX = pupilX + intervalMove;
}
if (step == 13) {
pupilX = pupilX + intervalMove;
}
if (step == 14) {
pupilX = pupilX + intervalMove;
}
if (step == 15) {
pupilX = pupilX + intervalMove;
}
if (step == 16) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBck = transBck + intervalBck;
}
if (step == 17) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBck = transBck + intervalBck;
}
if (step == 18) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBck = transBck + intervalBck;
}
if (step == 19) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBck = transBck + intervalBck;
}
if (step == 20) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBck = transBck + intervalBck;
}
if (step == 21) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
}
if (step == 22) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 23) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 24) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 25) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 26) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 27) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 28) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 29) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 30) {
pupilX = pupilX – intervalMove;
pupilY = pupilY + intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth + intervalMove;
}
if (step == 31) {
pupilX = pupilX – intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 32) {
pupilX = pupilX – intervalMove;
transBlsh = transBlsh + intervalColor;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 33) {
pupilX = pupilX – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 34) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 35) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 36) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 37) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 38) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
if (step == 39) {
pupilX = pupilX – intervalMove;
pupilY = pupilY – intervalMove;
transBck = transBck + intervalBck;
mouth = mouth – intervalMove;
}
}
}

 

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

One Response to Face Animation

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