# Superellipse

```perl
my (\a, \b, \n) = 200, 200, 2.5;

# y in terms of x
sub y ($x) { floor b × (1 - ($x/a).abs ** n ) ** (1/n) }

# find point pairs for one quadrant
my @q = flat map -> \x { x, y(x) }, ^(a+1);

my $out = open('superellipse.svg', :w);
$out.print: [~] qq|<svg height="{b×2}" width="{a×2}" xmlns="https://www.w3.org/2000/svg">\n|,
  pline( @q ),
  pline( @q «×» < 1 -1> ), # flip and mirror
  pline( @q «×» <-1 -1> ), # for the other
  pline( @q «×» <-1  1> ), # three quadrants
  '</svg>';

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

[Superellipse](https://github.com/SqrtNegInf/Rosettacode-Perl6-Smoke/blob/master/ref/superellipse.svg) (offsite image)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/s/superellipse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
