#!/usr/bin/perl -w # # Example 9-3. An example using SWF::Shape() use strict; use SWF::Shape; SWF::setScale(1.0); my $s = new SWF::Shape(); # Create a new Shape object $s->setLineStyle(1, 255, 0, 0); my @dx = (1, 1, -1, -1); my @dy = (1, -1, -1, 1); my ($x, $y) = (0, 0); my ($x1, $y1) = (0, 0); my $w = 100; my ($cx, $cy); $s->movePenTo($x, $y); for(my $i=0; $i <= 10; $i++) { $x1 = $x1 + $dx[$i%4] * $w; $y1 = $y1 + $dy[$i%4] * $w; if ($i % 2) { # An odd turn ($cx, $cy) = ($x1, $y); } else { # An even turn ($cx, $cy) = ($x, $y1); } $s->drawCurveTo($cx, $cy, $x1, $y1); # Add a curve segment to the Shape $x = $x1; # Set the current point. $y = $y1; $w = $w * .618034; # The width of the bounding box for the next curve segment # is determined by the Golden Mean } # Create a Movie to hold the Shape my $m = new SWF::Movie(); $m->setDimension(300,300); $m->add($s)->moveTo(0,10); $m->nextFrame(); $m->save("example9-3.swf");