Superellipse: Difference between revisions
m
→{{header|EasyLang}}
(add lambdatalk code) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 267:
closegraph();
}</syntaxhighlight>
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
[[File:DelphiSuperElipse.png|frame|none]]
<syntaxhighlight lang="Delphi">
procedure DrawSuperElipse(Image: TImage);
var Points: array of double;
const N = 2.5;
const Border = 10;
var A: integer;
var X: integer;
var W2,H2: integer;
begin
{Make elipse size and position based on window size}
W2:=Image.Width div 2;
H2:=Image.Height div 2;
A:=Min(W2,H2)-Border;
{Fill array with points}
SetLength(Points,A);
for X:=0 to High(Points) do
Points[X]:=Power(Power(A, N) - Power(X, N), 1 / N);
Image.Canvas.Pen.Color:=clRed;
Image.Canvas.Pen.Width:=2;
{Starting point}
Image.Canvas.MoveTo(W2+High(Points),trunc(H2-Points[High(Points)]));
{Draw Upper right}
for X:=High(Points) downto 0 do
begin
Image.Canvas.LineTo(W2+x, trunc(H2-Points[X]))
end;
{Draw Upper left}
for X:=0 to High(Points) do
begin
Image.Canvas.LineTo(W2-X, trunc(H2-Points[X]))
end;
{Draw Lower left}
for X:=High(Points) downto 0 do
begin
Image.Canvas.LineTo(W2-X, trunc(H2+Points[X]))
end;
{Draw Lower right}
for X:=0 to High(Points) do
begin
Image.Canvas.LineTo(W2+X, trunc(H2+Points[X]))
end;
{Connect back to beginning}
Image.Canvas.LineTo(W2+High(Points),trunc(H2-Points[High(Points)]));
Image.Repaint;
end;
</syntaxhighlight>
{{out}}
<pre>
Elapsed Time: 13.282 ms.
</pre>
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=Vc1LCsMgFEbh+V3FGbYJGLHYUV2MtqERgikomOw+2Bft6L9wPrgJh1FWfFutJbx3jmms8VYmtDJSpziPFC6O01kLsOJ4LBUfMtclUzgYBtKRDk9Hjvf0Ck1vPzrH9KfDRz9D0+03KwOWHqvZvmerhd6hlRUlOw== Run it]
<syntaxhighlight>
n = 2.5
a = 200
b = 200
linewidth 0.2
while t <= 360
x = pow abs cos t (2 / n) * a * sign cos t
y = pow abs sin t (2 / n) * b * sign sin t
line x / 5 + 50 y / 5 + 50
t += 0.5
.
</syntaxhighlight>
=={{header|EchoLisp}}==
Line 843 ⟶ 920:
}}}
-> superellipse
</syntaxhighlight>
We use SVG and the lib_plot library defining the SVG, AXES, stroke functions to draw four superellipses, a circle, a rounded square (as required), a square and an astroid.
<syntaxhighlight lang="scheme">
{{SVG 600 600}
{g {AXES 600 600}
{polyline
{@ points="{S.map
{stroke #f00 4}}}
{polyline
{@ points="{S.map
{stroke #0f0 4}}}
{polyline
{@ points="{S.map {
{stroke #888 2}}}
{polyline
{@ points="{S.map {
{stroke #888 2}}}
}}
Line 1,737 ⟶ 1,814:
{{libheader|DOME}}
Uses Go's drawing code but produces a more complex image.
<syntaxhighlight lang="
class Game {
|