Superellipse: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
No edit summary
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 132:
→ (("x:auto" -400 400) ("y:auto" -400 400))
</lang>
 
=={{header|FreeBASIC}}==
<lang freebasic>' version 23-10-2016
Line 490 ⟶ 491:
}
}</lang>
 
=={{header|JavaScript}}==
<lang javascript>
Line 810 ⟶ 812:
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/superellipse.svg Superellipse] (offsite image)
 
=={{header|Perl 6}}==
{{works with|rakudo|2018-10}}
Generate an svg image to STDOUT. Redirect into a file to capture it.
<lang perl6>constant a = 200;
constant b = 200;
constant n = 2.5;
 
# y in terms of x
sub y ($x) { sprintf "%d", b * (1 - ($x / a).abs ** n ) ** (1/n) }
 
# find point pairs for one quadrant
my @q = flat map -> \x { x, y(x) }, (0, 1 ... 200);
 
# Generate an SVG image
INIT say qq:to/STOP/;
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="{b*2}" width="{a*2}" version="1.1" xmlns="http://www.w3.org/2000/svg">
STOP
END say '</svg>';
 
.put for
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) {
qq:to/END/;
<polyline points="{@q}"
style="fill:none; stroke:black; stroke-width:3" transform="translate({a}, {b})" />
END
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/superellipse.svg Superellipse] (offsite image)
 
=={{header|Phix}}==
Line 963 ⟶ 930:
(plot (isoline (superellipse 200 200 2.5) 1
-220 220 -220 220))</lang>
 
=={{header|Perl 6Raku}}==
(formerly Perl 6)
{{works with|rakudo|2018-10}}
Generate an svg image to STDOUT. Redirect into a file to capture it.
<lang perl6>constant a = 200;
constant b = 200;
constant n = 2.5;
 
# y in terms of x
sub y ($x) { sprintf "%d", b * (1 - ($x / a).abs ** n ) ** (1/n) }
 
# find point pairs for one quadrant
my @q = flat map -> \x { x, y(x) }, (0, 1 ... 200);
 
# Generate an SVG image
INIT say qq:to/STOP/;
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg height="{b*2}" width="{a*2}" version="1.1" xmlns="http://www.w3.org/2000/svg">
STOP
END say '</svg>';
 
.put for
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) {
qq:to/END/;
<polyline points="{@q}"
style="fill:none; stroke:black; stroke-width:3" transform="translate({a}, {b})" />
END
}</lang>
[https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/superellipse.svg Superellipse] (offsite image)
 
=={{header|REXX}}==
Line 1,237 ⟶ 1,240:
 
}</lang>
 
=={{header|Sidef}}==
{{trans|Perl 6}}
10,327

edits