my $a = 200;
my $b = 200;
my $n = 2.5;


sub y_from_x {
    my($x) = @_;
    int $b * abs(1 - ($x / $a) ** $n ) ** (1/$n)
}


push @q, $_, y_from_x($_) for 0..200;


open  $fh, '>', 'superellipse.svg';
print $fh
  qq|<svg height="@{[2*$b]}" width="@{[2*$a]}" xmlns="http://www.w3.org/2000/svg">\n|,
  pline( 1, 1, @q ),
  pline( 1,-1, @q ), 
  pline(-1,-1, @q ), 
  pline(-1, 1, @q ), 
  '</svg>';

sub pline {
  my($sx,$sy,@q) = @_;

  for (0..$
    $q[  2*$_] *= $sx;
    $q[1+2*$_] *= $sy;
  }

  qq|<polyline points="@{[join ' ',@q]}"
  style="fill:none;stroke:black;stroke-width:3"
  transform="translate($a, $b)" />\n|
}