Pentagram: Difference between revisions

m
→‎{{header|Perl 6}}: Some simplifications and tweaks, add image link
(→‎{{header|Perl 6}}: various simplifications)
m (→‎{{header|Perl 6}}: Some simplifications and tweaks, add image link)
Line 229:
 
=={{header|Perl 6}}==
{{works with|rakudo|20152016-11-0201}}
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/STOP/;
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
<svg height="{$dim*2}" width="{$dim*2}" style="" xmlns="http://www.w3.org/2000/svg">
<rect height="100%" width="100%" style="fill:bisque;" />
STOP
END say '</svg>';
 
my @vertices = map { 0.9 * $dim * cis($_ * 2 * piτ / $sides) }, ^$sides;
 
@verticessay =pline map |*.reals, flat @vertices[0, 2 ... *], @vertices[1, 3 ... *];
 
say pline @vertices;
sub pline (*@q) {
for @vertices.rotor(4 => -2, :partial) -> @p {say pline @p};
sub pline (*@q) {
qq:to/STOP/;
<polyline points="{@q[|^@q, 0, 1].fmt("%0.3f")}"
style="fill:seashell; stroke:{<black red orange blue; purple green>[$++ % 6]};stroke-width:23;"
transform="translate($dim, $dim) rotate(180-18)" />
STOP
}</lang>
See [https://gist.github.com/thundergnat/70108a5160dd17dfe374#file-pentagram-svg Pentagram]
 
=={{header|PostScript}}==
10,333

edits