PERL   81

sparks0 cgi

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

Raw Paste


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