Pentagram: Difference between revisions
Added Perl example
SqrtNegInf (talk | contribs) (Added Perl example) |
|||
Line 523:
Return
::requires RxMath Library</lang>
=={{header|Perl}}==
<lang perl>use SVG;
my $tau = 2 * 4*atan2(1, 1);
my $dim = 200;
my $sides = 5;
for $v (0, 2, 4, 1, 3, 0) {
push @vx, 0.9 * $dim * cos($tau * $v / $sides);
push @vy, 0.9 * $dim * sin($tau * $v / $sides);
}
my $svg= SVG->new( width => 2*$dim, height => 2*$dim);
my $points = $svg->get_path(
x => \@vx,
y => \@vy,
-type => 'polyline',
);
$svg->rect (
width => "100%",
height => "100%",
style => {
'fill' => 'bisque'
}
);
$svg->polyline (
%$points,
style => {
'fill' => 'seashell',
'stroke' => 'blue',
'stroke-width' => 3,
},
transform => "translate($dim,$dim) rotate(-18)"
);
open $fh, '>', 'pentagram.svg';
print $fh $svg->xmlify(-namespace=>'svg');
close $fh;</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/pentagram.svg Pentagram] (offsite image)
=={{header|Perl 6}}==
|