Pentagram: Difference between revisions

m
Line 513:
 
=={{header|Perl 6}}==
{{works with|rakudo|2016-012018.08}}
Generate an SVG file to STDOUT. Redirect to a file to capture and display it.
<lang perl6>constantuse $dim = 200SVG;
constant $sides = 5;
 
constant $dim = 200;
INIT say qq:to/STOP/;
constant $sides = 5;
<?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($_ * τ / $sides) }, ^$sides;
 
saymy pline@points = map |*.reals, flat @vertices[.fmt("%0, 2 ... *]3f"), @vertices[1, 3 ... *];
flat @vertices[0, 2 ... *], @vertices[1, 3 ... *], @vertices[0];
 
say SVG.serialize(
sub pline (@q) {
svg => [
qq:to/STOP/;
:width($dim*2), :height($dim*2),
<polyline points="{@q[^@q, 0, 1].fmt("%0.3f")}"
<rect height=" :rect[:width<100%">, width=":height<100%">, :style="<fill:bisque;" />],
style="fill:seashell; stroke:blue; stroke-width:3;"
:polyline[ :points(@points.join: ','),
transform="translate($dim, $dim) rotate(-18)" />
:style=("fill:seashell; stroke:blue; stroke-width:3; fill:seashell;"),
STOP
:transform=("translate($dim, $dim) rotate(-18)" />)
}</lang>
],
See [https://gist.github.com/thundergnat/70108a5160dd17dfe374#file-pentagram-svg Pentagram]
STOP],
});</lang>
See [https://gist.github.com/thundergnat/70108a5160dd17dfe374#file-rc/blob/master/img/pentagram-perl6.svg Pentagram] (offsite svg image)
 
=={{header|Phix}}==
10,327

edits