Superellipse: Difference between revisions
Content added Content deleted
(→{{header|jq}}: link to offsite graph) |
(add lambdatalk code) |
||
Line 826: | Line 826: | ||
} |
} |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
=={{header|Lambdatalk}}== |
|||
Drawing four super-ellipses, a circle, a rounded square, a square, an astroid. |
|||
<syntaxhighlight lang="scheme"> |
|||
{def superellipse |
|||
{def sgn {lambda {:n} {if {< :n 0} then - else +}}} |
|||
{lambda {:a :n :t} |
|||
{let { {:a :a} {:n {/ 2 :n}} |
|||
{:cost {cos {* {PI} :t}}} |
|||
{:sint {sin {* {PI} :t}}} |
|||
} {sgn :cost}{* :a {pow {abs :cost} :n}} |
|||
{sgn :sint}{* :a {pow {abs :sint} :n}} |
|||
}}} |
|||
-> superellipse |
|||
{{SVG 600 600} |
|||
{g {AXES 600 600} |
|||
{polyline |
|||
{@ points="{S.map {lambda {:i} {superellipse 200 2.5 :i} } |
|||
{S.serie -1 1.01 0.01}}" |
|||
{stroke #f00 4}}} |
|||
{polyline |
|||
{@ points="{S.map {lambda {:i} {superellipse 200 0.5 :i} } |
|||
{S.serie -1 1.01 0.01}}" |
|||
{stroke #0f0 4}}} |
|||
{polyline |
|||
{@ points="{S.map {lambda {:i} {superellipse 200 1 :i} } |
|||
{S.serie -1 1.01 0.01}}" |
|||
{stroke #888 2}}} |
|||
{polyline |
|||
{@ points="{S.map {lambda {:i} {superellipse 200 2 :i} } |
|||
{S.serie -1 1.01 0.01}}" |
|||
{stroke #888 2}}} |
|||
}} |
|||
</syntaxhighlight> |
|||
The output can be seen in http://lambdaway.free.fr/lambdawalks/?view=super_ellipse |
|||
=={{header|Liberty BASIC}}== |
=={{header|Liberty BASIC}}== |