Pentagram: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
m (→{{header|Red}}) |
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
||
Line 174:
ExitApp
Return</lang>
=={{header|C}}==
Interactive program which takes the side lengths of the pentagram's core, it's arms and the colours for filling the background, drawing the figure and then filling it in. Requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library.
Line 685 ⟶ 686:
close $fh;</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/pentagram.svg Pentagram] (offsite image)
=={{header|Perl 6}}==▼
{{works with|rakudo|2018.08}}▼
Generate an SVG file to STDOUT. Redirect to a file to capture and display it.▼
<lang perl6>use SVG;▼
constant $dim = 200;▼
constant $sides = 5;▼
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(▼
svg => [▼
:width($dim*2), :height($dim*2),▼
:rect[:width<100%>, :height<100%>, :style<fill:bisque;>],▼
:polyline[ :points(@points.join: ','),▼
:style("stroke:blue; stroke-width:3; fill:seashell;"),▼
:transform("translate($dim,$dim) rotate(-90)")▼
],▼
],▼
);</lang>▼
See [https://github.com/thundergnat/rc/blob/master/img/pentagram-perl6.svg Pentagram] (offsite svg image)▼
Ever wondered what a regular 7 sided star looks like? Change $sides to 7 and re-run.▼
See [https://github.com/thundergnat/rc/blob/master/img/heptagram-perl6.svg Heptagram]▼
=={{header|Phix}}==
Line 979 ⟶ 952:
(star-polygon 100 5 2 "outline" (make-pen "blue" 4 "solid" "round" "round"))
(star-polygon 100 5 2 "solid" "cyan"))</lang>
(formerly Perl 6)
▲{{works with|rakudo|2018.08}}
▲Generate an SVG file to STDOUT. Redirect to a file to capture and display it.
▲<lang perl6>use SVG;
▲constant $dim = 200;
▲constant $sides = 5;
▲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(
▲ svg => [
▲ :width($dim*2), :height($dim*2),
▲ :rect[:width<100%>, :height<100%>, :style<fill:bisque;>],
▲ :polyline[ :points(@points.join: ','),
▲ :style("stroke:blue; stroke-width:3; fill:seashell;"),
▲ :transform("translate($dim,$dim) rotate(-90)")
▲ ],
▲ ],
▲);</lang>
▲See [https://github.com/thundergnat/rc/blob/master/img/pentagram-perl6.svg Pentagram] (offsite svg image)
▲Ever wondered what a regular 7 sided star looks like? Change $sides to 7 and re-run.
▲See [https://github.com/thundergnat/rc/blob/master/img/heptagram-perl6.svg Heptagram]
=={{header|Red}}==
Line 1,310 ⟶ 1,312:
}</lang>
=={{header|Sidef}}==
{{trans|Perl 6}}
Line 1,408 ⟶ 1,411:
End With
End Sub</lang>
=={{header|zkl}}==
{{trans|Perl 6}}
|