Superellipse: Difference between revisions
→{{header|Raku}}: simplified
(Added Processing implementation) |
SqrtNegInf (talk | contribs) (→{{header|Raku}}: simplified) |
||
Line 1,310:
=={{header|Raku}}==
(formerly Perl 6)
▲<lang perl6>constant a = 200;
# y in terms of x
sub y ($x) {
# find point pairs for one quadrant
my @q = flat map -> \x { x, y(x) }, ^(
my $out = open('superellipse.svg', :w);
$out.print: [~]
pline( flat @q ),▼
▲ <svg height="{b*2}" width="{a*2}" version="1.1" xmlns="http://www.w3.org/2000/svg">
;
▲pline( @q ),
▲pline( @q «*» ( 1,-1) ), # flip and mirror
▲pline( @q «*» (-1,-1) ), # for the other
▲pline( @q «*» (-1, 1) ); # three quadrants
sub pline (@q) {
style="fill:none;stroke:black;stroke-width:3"
▲ <polyline points="{@q}"
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/superellipse.svg Superellipse] (offsite image)
|