Sierpinski square curve: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) m (→{{header|11l}}: new way of specifying file open mode) |
(Added Easylang) |
||
Line 324: | Line 324: | ||
{{out}} |
{{out}} |
||
[[Media:Sierpinski_square_cpp.svg]] |
[[Media:Sierpinski_square_cpp.svg]] |
||
=={{header|EasyLang}}== |
|||
[https://easylang.online/show/#cod=jVLRasMgFH33Kw4SxoZE0nYdjOFrviFQ+iCJXYVUg2Zt8vfDxiRN28Feop57zrl6chtnS6iukaZCrc6qBofstD0lcD+18sluD04AHKxDjdYOrIAAkCaBAKXxGDhlAm3gW1cepfPRK9YjRUNgBd+qBuvB0UzNZiYAfRhxvYdAmSyqsf+LmEhgWC0dVO3VH6I7N04etuPqL7IZQ5HmKuOEkyZEVzl5mWvf4IOq1kZddNUekfFNADoIbDN8oYfAOgvQyZ4VOvTkH8npQygL0JzO9+zABErrUWk3o31AvTZLNFxobHbNZXJMbxwr7SDwGpY0POcNJ1th85E9ythzGXsm42NkMajwDlbkLHwomeZMYAdaUNAiT3OWp5Ex7Cn2JM7p+/2Ektu/8JkR8gs= Run it] |
|||
<syntaxhighlight> |
|||
proc expand level . axiom$ rules$[] . |
|||
for l to level |
|||
an$ = "" |
|||
for c$ in strchars axiom$ |
|||
for i = 1 step 2 to len rules$[] |
|||
if rules$[i] = c$ |
|||
an$ &= rules$[i + 1] |
|||
else |
|||
an$ &= c$ |
|||
. |
|||
. |
|||
. |
|||
swap axiom$ an$ |
|||
. |
|||
. |
|||
proc draw axiom$ ang . . |
|||
linewidth 0.3 |
|||
x = 50 ; y = 20 |
|||
move x y |
|||
for c$ in strchars axiom$ |
|||
if c$ = "F" |
|||
x += cos dir |
|||
y += sin dir |
|||
line x y |
|||
elif c$ = "-" |
|||
dir = (dir - ang) mod 360 |
|||
elif c$ = "+" |
|||
dir = (dir + ang) mod 360 |
|||
. |
|||
. |
|||
. |
|||
axiom$ = "F+XF+F+XF" |
|||
rules$[] = [ "X" "XF-F+F-XF+F+XF-F+F-X" ] |
|||
expand 4 axiom$ rules$[] |
|||
draw axiom$ 90 |
|||
</syntaxhighlight> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |