Anonymous user
Pentagram: Difference between revisions
→{{header|Perl 6}}: style
(→{{header|Perl 6}}: style : using phasers, complex numbers and infinite sequences) |
(→{{header|Perl 6}}: style) |
||
Line 229:
=={{header|Perl 6}}==
{{works with|rakudo|2015-11-02}}
Generate an SVG file to STDOUT. Redirect to a file to capture and display it.
<lang perl6>constant $dim = 200;
constant $sides = 5;
INIT say qq:to
<?xml version="1.0" standalone="no" ?>
<svg height="{$dim*2}" width="{$dim*2}" xmlns="http://www.w3.org/2000/svg">
STOP
END say '</svg>';
my @vertices = map { 0.9 * $dim * cis($_ * 2 * pi / $sides) }, ^$sides;
@vertices =
@vertices.push(@vertices[0,1]);
say pline
for @vertices.rotor(4 => -2, :partial) -> @p {say pline
sub pline (*@q) {
qq:to/STOP/;
style="fill:seashell;stroke:{<black red orange blue purple green>[state $++ % 6]};stroke-width:2"
transform="translate($dim, $dim) rotate(180)" />
STOP
}</lang>
|