Brownian tree: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Automated syntax highlighting fixup (second round - minor fixes) third times a charm) |
(1-based index) |
||
Line 1,005: | Line 1,005: | ||
[https://easylang.online/apps/_brownian-tree.html Run it] |
[https://easylang.online/apps/_brownian-tree.html Run it] |
||
<syntaxhighlight lang="text"> |
<syntaxhighlight lang="text"> |
||
color3 0 1 1 |
|||
len f[] 200 * 200 |
len f[] 200 * 200 |
||
move 50 50 |
move 50 50 |
||
Line 1,013: | Line 1,014: | ||
while i < n |
while i < n |
||
repeat |
repeat |
||
x = random 200 |
x = random 200 - 1 |
||
y = random 200 |
y = random 200 - 1 |
||
until f[y * 200 + x] <> 1 |
until f[y * 200 + x + 1] <> 1 |
||
. |
. |
||
while 1 = 1 |
while 1 = 1 |
||
xo = x |
xo = x |
||
yo = y |
yo = y |
||
x += random 3 - |
x += random 3 - 2 |
||
y += random 3 - |
y += random 3 - 2 |
||
if x < 0 or y < 0 or x >= 200 or y >= 200 |
if x < 0 or y < 0 or x >= 200 or y >= 200 |
||
break 1 |
break 1 |
||
. |
. |
||
if f[y * 200 + x] = 1 |
if f[y * 200 + x + 1] = 1 |
||
move xo / 2 yo / 2 |
move xo / 2 yo / 2 |
||
rect 0.5 0.5 |
rect 0.5 0.5 |
||
f[yo * 200 + xo] = 1 |
f[yo * 200 + xo + 1] = 1 |
||
i += 1 |
i += 1 |
||
if i mod 16 = 0 |
if i mod 16 = 0 |
||
Line 1,037: | Line 1,038: | ||
. |
. |
||
. |
. |
||
. |
|||
</syntaxhighlight> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
This example sets four spawn points, one in each corner of the image, giving the result a vague x-shaped appearance. For visual reasons, movement is restricted to diagonals. So be careful if you change the seed or spawns — they should all fall on the same diagonal. |
This example sets four spawn points, one in each corner of the image, giving the result a vague x-shaped appearance. For visual reasons, movement is restricted to diagonals. So be careful if you change the seed or spawns — they should all fall on the same diagonal. |