RosettaCodeData/Task/Brownian-tree/Run-BASIC/brownian-tree.basic

22 lines
613 B
Plaintext

numParticles = 3000
dim canvas(201,201)
graphic #g, 200,200
#g fill("blue")
canvas(rnd(1) * 100 , rnd(1) * 200) = 1 'start point
for i = 1 To numParticles
x = (rnd(1) * 199) + 1
y = (rnd(1) * 199) + 1
while canvas(x+1, y+1)+canvas(x, y+1)+canvas(x+1, y)+canvas(x-1, y-1)+canvas(x-1, y)+canvas(x, y-1) = 0
x = x + (rnd(1)* 2) + 1
y = y + (rnd(1)* 2) + 1
If x < 1 Or x > 200 Or y < 1 Or y > 200 then
x = (rnd(1) * 199) + 1
y = (rnd(1) * 199) + 1
end if
wend
canvas(x,y) = 1
#g "color green ; set "; x; " "; y
next i
render #g
#g "flush"