PERL   22

animation-cgi

Guest on 3rd July 2022 04:55:46 PM

  1. #!/usr/bin/perl
  2. use strict;
  3.  
  4. # Were you looking for thw worst perl script?
  5. # Congradulations! you found it.
  6.  
  7. use SWF qw(:ALL);
  8.  
  9. use CGI;
  10. my $query = new CGI;
  11. my $string = $query->param('string') || "todbot";
  12. my $rotdem = $query->param('rotdem') || 20;
  13. my $rotnum = $query->param('rotnum') || 19;
  14. my $font   = $query->param('font') || 'test.fdb';
  15.  
  16. my $dir = 'fonts/';
  17.  
  18. print "Content-type: application/x-shockwave-flash\n\n";
  19.  
  20. my $loc = {};
  21. my $i1 = {
  22.   r      => 0xff,
  23.   g      => 0x33,
  24.   b      => 0x33,
  25.   a      => 0x3f,
  26.   rot    => 900,
  27.   x      => 1200,
  28.   y      => 800,
  29.   scale  => 0.03,
  30.   string => $string,
  31. };
  32.  
  33. my $i2 = {
  34.   r      => 0x33,
  35.   g      => 0x33,
  36.   b      => 0xff,
  37.   a      => 0x3f,
  38.   rot    => -560,
  39.   x      => 1200,
  40.   y      => 800,
  41.   scale  => 0.04,
  42.   string => $string,
  43. };
  44.  
  45. my $i3 = {
  46.   r      => 0x33,
  47.   g      => 0xff,
  48.   b      => 0x33,
  49.   a      => 0x3f,
  50.   rot    => 180,
  51.   x      => 1200,
  52.   y      => 800,
  53.   scale  => 0.001,
  54.   string => $string,
  55. };
  56.  
  57.  
  58. if( $font eq 'rand' ) {
  59.   opendir(DIR, $dir) || die "can't opendir $dir: $!";
  60.   my @fdbs = grep { /fdb$/ && -f "$dir/$_" } readdir(DIR);
  61.   closedir DIR;
  62.   print STDERR "got fdbs " , @fdbs , "\n";
  63.   my $randchoice = int rand scalar @fdbs;
  64.   $font = $fdbs[$randchoice];
  65.   print STDERR "choice $randchoice, so chose font $font\n";
  66. }
  67.  
  68.  
  69. my $f = new SWF::Font($dir.$font);
  70. my $m = new SWF::Movie();
  71. $m->setRate(20.0);
  72. $m->setDimension(2400, 1600);
  73. #$m->setBackground(0xff, 0xff, 0xff);
  74. $m->setBackground(0x00, 0x00, 0x00);
  75.  
  76.  
  77.  
  78. sub text {
  79.   my $j = shift;
  80.  
  81.   my $t = new SWF::Text();
  82.   $t->setFont($f);
  83.   $t->setColor($j->{r}, $j->{g}, $j->{b}, $j->{a});
  84.   $t->setHeight(960);
  85.   $t->moveTo(-($t->getWidth($string))/2, 220);
  86.   $t->addString($string);
  87.  
  88.   my $i = $m->add($t);
  89.   $j->{x} = $j->{x};
  90.   $j->{y} = $j->{y};
  91.   $j->{rot} = $j->{rot};
  92.   $j->{s} = $j->{scale};
  93.   $i->rotateTo($j->{rot});
  94.   $i->scale($j->{scale}, $j->{scale});
  95.  
  96.   $j->{item} = $i;
  97. #    $j->{text} = $t;
  98.   return $j;
  99. }
  100.  
  101. sub step {
  102.   my $j = shift;
  103.   my $oldrot = $j->{rot};
  104.   $j->{rot} = $rotnum*($j->{rot})/$rotdem;
  105.   $j->{x}   = (19*$j->{x} + 1200)/20;
  106.   $j->{y}   = (19*$j->{y} + 800)/20;
  107.   $j->{s}   = (19*$j->{s} + 1.0)/20;
  108.  
  109.   my $i = $j->{item};
  110.   $i->rotateTo($j->{rot});
  111.   $i->scaleTo($j->{s}, $j->{s});
  112.   $i->moveTo($j->{x}, $j->{y});
  113.   return $j;
  114. }
  115.  
  116. $i1 = text($i1);
  117. $i2 = text($i2);
  118. $i3 = text($i3);
  119.  
  120. for( my $i=1; $i<=105; ++$i) {
  121.   $i1 = step($i1);
  122.   $i2 = step($i2);
  123.   $i3 = step($i3);
  124.   $m->nextFrame();
  125. }
  126.  
  127. $m->nextFrame();
  128. $m->nextFrame();
  129. $m->nextFrame();
  130. $m->nextFrame();
  131. $m->nextFrame();
  132. $m->nextFrame();
  133. $m->nextFrame();
  134. $m->nextFrame();
  135. $m->nextFrame();
  136. $m->nextFrame();
  137. $m->nextFrame();
  138. $m->nextFrame();
  139.  
  140. $m->output();

Raw Paste


Login or Register to edit or fork this paste. It's free.