PERL   57

sparks cgi

Guest on 3rd July 2022 05:08:27 PM

  1. #!/usr/bin/perl -w
  2. use strict;
  3.  
  4. use SWF qw(:ALL);
  5. use SWF::Constants qw(:Fill);
  6.  
  7. use CGI;
  8. my $query = new CGI;
  9. my $string = $query->param('string') || "todbot";
  10.  
  11. my $width=320;
  12. my $height=240;
  13.  
  14. my $m = new SWF::Movie();
  15. $m->setDimension($width,$height);
  16. $m->setBackground(0x00, 0x00, 0x00);
  17.  
  18. $m->add(new SWF::Action("
  19.  
  20. //_quality = 'LOW';
  21. frames._visible = false;
  22. sparks = [];
  23.  
  24.  "));
  25.  
  26. my $g = new SWF::Gradient();
  27. $g->addEntry(0, 0xff, 0xff, 0xff, 0xff);
  28. $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff);
  29. $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f);
  30. $g->addEntry(1.0, 0xff, 0xff, 0xff, 0);
  31.  
  32. # gradient shape thing
  33. my $s = new SWF::Shape();
  34. my $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT);
  35. $f->scaleTo(0.03);
  36. $s->setRightFill($f);
  37. $s->movePenTo(-30, -30);
  38. $s->drawLine(60, 0);
  39. $s->drawLine(0, 60);
  40. $s->drawLine(-60, 0);
  41. $s->drawLine(0, -60);
  42.  
  43. my $font = new SWF::Font("fonts/test.fdb");
  44. my $text = new SWF::Text();
  45. $text->setFont($font);
  46. $text->setColor(0x0,0x0,0x0);
  47. $text->setHeight(10);
  48. $text->addString($string);
  49.  
  50. # need to make this a sprite so we can multColor it
  51. my $p = new SWF::Sprite();
  52. $p->add($s);
  53. my $texti = $p->add($text);
  54. $texti->move( $text->getWidth($string)/2 - $text->getWidth($string), 0 );
  55. $p->nextFrame();
  56.  
  57. # put the shape in here, each frame a different color
  58. my $q = new SWF::Sprite();
  59. $q->add(new SWF::Action("gotoFrame(random(7)+1); stop();"));
  60. my $i = $q->add($p);
  61.  
  62. $i->multColor(1.0, 1.0, 1.0);
  63. $q->nextFrame();
  64. $i->multColor(1.0, 0.5, 0.5);
  65. $q->nextFrame();
  66. $i->multColor(1.0, 0.75, 0.5);
  67. $q->nextFrame();
  68. $i->multColor(1.0, 1.0, 0.5);
  69. $q->nextFrame();
  70. $i->multColor(0.5, 1.0, 0.5);
  71. $q->nextFrame();
  72. $i->multColor(0.5, 0.5, 1.0);
  73. $q->nextFrame();
  74. $i->multColor(1.0, 0.5, 1.0);
  75. $q->nextFrame();
  76.  
  77. # finally, this one contains the action code
  78. $p = new SWF::Sprite();
  79. $i = $p->add($q);
  80. $i->setName('frames');
  81. $p->add(new SWF::Action("
  82.  
  83. dx = _root.dx/3 + random(10)-5;
  84. dy = _root.dy/3;
  85. x = (_root._xmouse<=0) ? $width/2 : _root._xmouse;
  86. y = (_root._ymouse<=0)  ? $height/2 : _root._ymouse;
  87. alpha = 100;
  88.  
  89.  "));
  90. $p->nextFrame();
  91.  
  92. $p->add(new SWF::Action("
  93.  
  94. this._x = x;
  95. this._y = y;
  96. this._alpha = alpha;
  97. x += dx;
  98. y += dy;
  99. dy += 3;
  100. alpha -= 8;
  101.  
  102.  "));
  103. $p->nextFrame();
  104.  
  105. $p->add(new SWF::Action("prevFrame(); play();"));
  106. $p->nextFrame();
  107.  
  108. $i = $m->add($p);
  109. $i->setName('frames');
  110. $m->nextFrame();
  111.  
  112. $m->add(new SWF::Action("
  113.  
  114. dx = _xmouse - lastx;
  115. dy = _ymouse - lasty;
  116.  
  117. lastx = _xmouse;
  118. lasty = _ymouse;
  119.  
  120. if(++num == 11)
  121.  num = 1;
  122.  
  123. if(sparks[num])
  124.  removeMovieClip(sparks[num]);
  125.  
  126. duplicateMovieClip('frames', 'char'+num, num);
  127. sparks[num] = this['char'+num];
  128.  
  129.  "));
  130.  
  131. $m->nextFrame();
  132. $m->add(new SWF::Action("prevFrame(); play();"));
  133.  
  134. print "Content-type: application/x-shockwave-flash\n\n";
  135.  
  136. $m->output();

Raw Paste


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