These are functions for scripting a mouth using Ming PHP codes. There are 3 functions, one for the teeth (which is placed in the background behind the top lip), one for the top lip, and one for the bottom lip. These functions use bezier curves and allow you to change the size and color of the mouth and use these changes for animation. | |
TEETH FUNCTION function teeth($size,$w,$h){ $Teeth = new SWFShape(); $Teeth->setLine($size+2,255,255,255); $Teeth->movePenTo(0,$h); $Teeth->drawCurveTo(0,$h,$w/2,$h*2,$w,$h); $Teeth->setLine($size*1.3,0,0,0); $Teeth->movePenTo(0,$h+$size); $Teeth->drawCurveTo(0,$h+$size,$w/2,($h*2)+$size*2,$w,$h+$size); return $Teeth; } | This function is called with the following lines. $Teeth=$myMovie->add(teeth(linesize,width,height)); $Teeth->moveTo(x,y); It draws a white bezier and a black bezier. This code produces the image below: $Teeth=$myMovie->add(teeth(4,48,25)); $Teeth->moveTo(87,104); |
TOP LIP FUNCTION function toplip($size,$r,$g,$b,$w,$h){ $TopLip = new SWFShape(); $TopLip->setLine($size,0,0,0); $TopLip->movePenTo(0,$h); $TopLip->drawCurveTo(0,$h,$w/2,$h-$h*3,$w,$h); $TopLip->drawCurveTo($w,$h,$w+$w/2,$h-$h*3,$w*2,$h); $TopLip->setLine($size,$r,$g,$b); $TopLip->movePenTo(0,$h); $TopLip->drawCurveTo(0,$h,$w/2,$h-$h*2,$w,$h); $TopLip->drawCurveTo($w,$h,$w+$w/2,$h-$h*2,$w*2,$h); $TopLip->setLine($size,0,0,0); $TopLip->movePenTo(0,$h); $TopLip->drawCurveTo(0,$h,$w/2,$h-$h,$w,$h); $TopLip->drawCurveTo($w,$h,$w+$w/2,$h-$h,$w*2,$h); return $TopLip; } This function is called with the following lines. $TopLip=$myMovie->add(toplip(linesize,red,green,blue,width/2,curve-height)); $TopLip->moveTo(x,y); |
Combining the teeth and the top lip using this code: $Teeth=$myMovie->add(teeth(2,16,8)); $Teeth->moveTo(52,66); $TopLip=$myMovie->add(toplip(2,255,0,0,10,8)); $TopLip->moveTo(50,70); One thing to note is that the top lip writes 2 curves so the width should be half of what you really want the width to be...and the teeth draw 1 curve to the width is what you want. The teeth should be a little smaller than the lip. Using the code above the lip is 10 so 10+10=20 which is the overall width. The teeth are 16 which is 4 pixels smaller and the teeth are place 2 pixels further than the left and 4 pixels closer to the rop than the lip. |
BOTTOM LIP FUNCTION function botlip($size,$r,$g,$b,$w,$h){ $BotLip = new SWFShape(); $BotLip->setLine($size/1.2,0,0,0); $BotLip->movePenTo(0,$h); $BotLip->drawCurveTo(0,$h,$w/2,$h+($h*2),$w,$h); $BotLip->setLine($size,$r,$g,$b); $BotLip->movePenTo(0,$h); $BotLip->drawCurveTo(0,$h,$w/2,$h+($h*1.5),$w,$h); $BotLip->setLine($size/1.2,0,0,0); $BotLip->movePenTo(0,$h); $BotLip->drawCurveTo(0,$h,$w/2,$h+$h,$w,$h); return $BotLip; } This function is called with the following lines. $BotLip=$myMovie->add(botlip(linesize,red,green,blue,width,curve-height)); $BotLip->moveTo(x,y); |
Combining the teeth and the top lip using this code: $Teeth=$myMovie->add(teeth(2,16,8)); $Teeth->moveTo(52,66); $TopLip=$myMovie->add(toplip(2,255,0,0,10,8)); $TopLip->moveTo(50,70); $BotLip=$myMovie->add(botlip(2,255,0,0,20,8)); $BotLip->moveTo(50,70); The bottom lip should be twice the width of the top lip. |
This code swaps two different size lower lips to create movement. for($i=0;$i<10;$i++){ $myMovie->nextframe(); $Teeth->moveTo(87,104); $mouthB->moveTo(85,102); $myMovie->nextframe(); $mouthB->moveTo(-85,-102); $mouthB1->moveTo(85,102); $myMovie->nextframe(); $mouthB1->moveTo(-85,-102); $mouthB->moveTo(85,102); } See Full text |
Enlarge |
This script puts the top lip and teeth into a loop.
$myMovie->nextframe(); for($i=0;$i<30;$i++){ $myMovie->nextframe(); $Teeth->moveTo(87,105-$i/6); $mouthT2->moveTo(85,105-$i/6); } for($i=0;$i<30;$i++){ $myMovie->nextframe(); $Teeth->moveTo(87,100+$i/6); $mouthT2->moveTo(85,100+$i/6); } See full text |
Enlarge |
MAKE A SMILE This code has extra loops in it because it is the only movement on the page. for($i=0;$i<10;$i++){ $myMovie->nextframe(); $myMovie->nextframe(); $myMovie->nextframe(); $mouthT->moveTo(94,94-$i/3); $mouthB->moveTo(92,87+$i/2); } See full text |
Enlarge |