1#!/usr/bin/perl -w 2use strict; 3 4#use lib("/home/peter/ming3/lib/perl5/site_perl"); 5 6use SWF qw(:ALL); 7$|=1; 8SWF::setScale(1); 9 10# where are the fontfiles? 11my $dir = '../common/'; 12my $font= '_sans.fdb'; 13 14my $string = "ming!"; 15 16my $loc = {}; 17my $i1 = { r => 0xff, 18 g => 0x33, 19 b => 0x33, 20 a => 0xff, 21 rot => 900, 22 x => 1200, 23 y => 800, 24 scale => 0.03, 25 string => $string, 26 }; 27 28my $i2 = { r => 0x00, 29 g => 0x33, 30 b => 0xff, 31 a => 0x7f, 32 rot => -560, 33 x => 1200, 34 y => 800, 35 scale => 0.04, 36 string => $string, 37 }; 38 39my $i3 = { r => 0xff, 40 g => 0xff, 41 b => 0xff, 42 a => 0x9f, 43 rot => 180, 44 x => 1200, 45 y => 800, 46 scale => 0.001, 47 string => $string, 48 }; 49 50 51 52my $f = new SWF::Font($dir.$font); 53my $m = new SWF::Movie(); 54$m->setRate(24.0); 55$m->setDimension(2400, 1600); 56$m->setBackground(0xff, 0xff, 0x0); 57 58 59 60sub text{ 61 my $j = shift; 62 63 my $t = new SWF::Text(); 64 $t->setFont($f); 65 $t->setColor($j->{r}, $j->{g}, $j->{b}, $j->{a}); 66 $t->setHeight(960); 67 $t->moveTo(-($t->getWidth($string))/2, 220); 68 $t->addString($string); 69 70 my $i = $m->add($t); 71 $j->{x} = $j->{x}; 72 $j->{y} = $j->{y}; 73 $j->{rot} = $j->{rot}; 74 $j->{s} = $j->{scale}; 75 $i->rotateTo($j->{rot}); 76 $i->scale($j->{scale}, $j->{scale}); 77 78 $j->{item} = $i; 79 return $j; 80} 81 82sub step{ 83 my $j = shift; 84 my $oldrot = $j->{rot}; 85 $j->{rot} = 19*($j->{rot})/20; 86 $j->{x} = (19*$j->{x} + 1200)/20; 87 $j->{y} = (19*$j->{y} + 800)/20; 88 $j->{s} = (19*$j->{s} + 1.0)/20; 89 90 my $i = $j->{item}; 91 $i->rotateTo($j->{rot}); 92 $i->scaleTo($j->{s}, $j->{s}); 93 $i->moveTo($j->{x}, $j->{y}); 94 return $j; 95} 96 97 98$i1 = text($i1); 99$i2 = text($i2); 100$i3 = text($i3); 101 102for(my $i=1; $i<=100; ++$i){ 103 $i1 = step($i1); 104 $i2 = step($i2); 105 $i3 = step($i3); 106 $m->nextFrame(); 107} 108 109 110# decide if its called from commandline or as cgiscript 111if (exists $ENV{"REQUEST_URI"}){ 112 print "Content-type: application/x-shockwave-flash\n\n"; 113 $m->output(); 114} 115else { 116 $m->save("$0.swf"); 117 print "Generated file written to $0.swf\n"; 118} 119