Brownian tree: Difference between revisions

1-based index
m (Automated syntax highlighting fixup (second round - minor fixes) third times a charm)
(1-based index)
Line 1,005:
[https://easylang.online/apps/_brownian-tree.html Run it]
 
<syntaxhighlight lang="text">color3 0 1 1
color3 0 1 1
len f[] 200 * 200
move 50 50
Line 1,013 ⟶ 1,014:
while i < n
repeat
x = random 200 - 1
y = random 200 - 1
until f[y * 200 + x + 1] <> 1
.
while 1 = 1
xo = x
yo = y
x += random 3 - 12
y += random 3 - 12
if x < 0 or y < 0 or x >= 200 or y >= 200
break 1
.
if f[y * 200 + x + 1] = 1
move xo / 2 yo / 2
rect 0.5 0.5
f[yo * 200 + xo + 1] = 1
i += 1
if i mod 16 = 0
Line 1,037 ⟶ 1,038:
.
.
.
.</syntaxhighlight>
 
=={{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.
2,078

edits