Pentagram: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Modernize) |
|||
Line 513: | Line 513: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|rakudo| |
{{works with|rakudo|2018.08}} |
||
Generate an SVG file to STDOUT. Redirect to a file to capture and display it. |
Generate an SVG file to STDOUT. Redirect to a file to capture and display it. |
||
<lang perl6> |
<lang perl6>use SVG; |
||
⚫ | |||
constant $dim = 200; |
|||
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"> |
|||
⚫ | |||
⚫ | |||
END say '</svg>'; |
|||
my @vertices = map { 0.9 * $dim * cis($_ * τ / $sides) }, ^$sides; |
my @vertices = map { 0.9 * $dim * cis($_ * τ / $sides) }, ^$sides; |
||
my @points = map |*.reals.fmt("%0.3f"), |
|||
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")}" |
|||
⚫ | |||
⚫ | |||
:polyline[ :points(@points.join: ','), |
|||
⚫ | |||
⚫ | |||
STOP |
|||
⚫ | |||
⚫ | |||
], |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |