Superellipse: Difference between revisions

m
→‎{{header|Raku}}: redundant 'flat's
(→‎{{header|Raku}}: simplified)
m (→‎{{header|Raku}}: redundant 'flat's)
Line 1,313:
 
# y in terms of x
sub y ($x) { floor b × (1 - ($x / a).abs ** n ) ** (1/n) }
 
# find point pairs for one quadrant
Line 1,320:
my $out = open('superellipse.svg', :w);
$out.print: [~] qq|<svg height="{b×2}" width="{a×2}" xmlns="http://www.w3.org/2000/svg">\n|,
pline( flat @q ),
pline( flat @q «×» (< 1, -1)> ), # flip and mirror
pline( flat @q «×» (<-1, -1)> ), # for the other
pline( flat @q «×» (<-1, 1)> ), # three quadrants
'</svg>';
;
 
sub pline (@q) {
2,392

edits