superellipse
Draw a super ellipse
superellipse(
x,
y,
xradius,
yradius,
exp,
[draw=true],
[stroke=#000000],
[fill=#FFFFFF],
[weight=1.00]
)
Draw a super ellipse
Syntaxe
superellipse(x=150, y=150, xradius=120, yradius=120, exp=4.5, stroke="#000000", fill="#FFA000", weight=4);
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
x | yes | - | x-coordinate | |
y | yes | - | y-coordinate | |
xradius | yes | - | radiusX | |
yradius | yes | - | radiusY | |
exp | yes | - | exposant (n<2=sharp, n>2=squircle) | |
draw | - | true | If false, return a list of points, and don't draw (stroke, fill & weight are ignored) | |
stroke | - | #000000 | Stroke color | |
fill | - | #FFFFFF | Fill color | |
weight | - | 1.00 | Stroke weight (thickness) |
Full example
canvas(width=500, height=200);
fill("#FFA000");
var mini = 0.2;
var maxi = 3.8;
var step = 0.15;
var radius = 30;
var startX = 10 + radius;
var startY = 10 + radius;
var nCols = 8;
var nRows = ceil((maxi - mini) / step / nCols);
for (var yIndex = 0; yIndex < nRows; yIndex++) {
for (var xIndex = 0; xIndex < nCols; xIndex++) {
var x = startX + xIndex * radius * 2;
var y = startY + yIndex * radius * 2;
var idx = yIndex * nCols + xIndex;
var eVal = mini + idx * step;
if (eVal <= maxi) {
superellipse(x, y, radius-5, radius-5, eVal);
}
}
}
save(whoami(png=true));
var p = superellipse(x=150, y=150, xradius=120, yradius=120, exp=4.5, draw=false);
console(p); // [270, 150, 269.9918767313, 169.8510557841, 269.967505275...]
