Brownian tree

You are encouraged to solve this task according to the task description, using any language you may know.



Task

Generate and draw a   Brownian Tree.



A Brownian Tree is generated as a result of an initial seed, followed by the interaction of two processes.

 The initial "seed" is placed somewhere within the field. Where is not particularly important; it could be randomized, or it could be a fixed point.
 Particles are injected into the field, and are individually given a (typically random) motion pattern.
 When a particle collides with the seed or tree, its position is fixed, and it's considered to be part of the tree.

Because of the lax rules governing the random nature of the particle's placement and motion, no two resulting trees are really expected to be the same, or even necessarily have the same general shape. 



'[RC]Brownian motion tree
    nomainwin
    dim screen(600,600)
    WindowWidth = 600
    WindowHeight = 600
    open "Brownian" for graphics_nsb_nf as #1
    #1 "trapclose [quit]"
    #1 "down ; fill blue"
    rad=57.29577951
    particles=500
 
    'draw starting circle and mid point
    for n= 1 to 360
            x=300-(200*sin(n/rad))
            y=300-(200*cos(n/rad))
            #1, "color white ; set ";x;" ";y
            screen(x,y)=1
    next n
    #1, "color white ; set 300 300"
    screen(300,300)=1
 
    'set up initial particles
    dim particle(particles,9)'x y deltax deltay rotx roty
    for n = 1 to particles
        gosub [randomparticle]
    next
 
    'start timed drawing loop
    timer 17, [draw]
    wait
 
 
    [draw]
    #1 "discard"
    scan
    for n = 1 to particles
        oldx=particle(n,1)
        oldy=particle(n,2)
 
        'erase particle
        if not(screen(oldx,oldy)) then
            #1 "color blue ; set ";oldx;" ";oldy
        end if
 
        'move particle x
        particle(n,1)=particle(n,1)+int((sin(particle(n,6)/rad)*10)+particle(n,3))
        particle(n,5)=particle(n,5)+6 mod 360
        if particle(n,1)>599 or particle(n,1)<1 then gosub [randomparticle]
 
        'move particle y
        particle(n,2)=particle(n,2)+int((sin(particle(n,5)/rad)*10)+particle(n,4))
        particle(n,6)=particle(n,6)+6 mod 360
        if particle(n,2)>599 or particle(n,2)<1 then gosub [randomparticle]
 
        'checkhit
        x=particle(n,1)
        y=particle(n,2)
        if screen(x-1,y-1) or screen(x-1,y) or screen(x-1,y+1)_
        or screen(x,y-1) or screen(x,y) or screen(x,y+1)_
        or screen(x+1,y-1) or screen(x+1,y) or screen(x+1,y+1) then
            #1 "color white ; set ";particle(n,1);" ";particle(n,2)
            screen(particle(n,1),particle(n,2))=1
        else
            #1 "color red ; set ";particle(n,1);" ";particle(n,2)
        end if
    next
    wait
 
 
 
    [randomparticle]
    particle(n,1)=int(rnd(0)*599)+1
    particle(n,2)=int(rnd(0)*599)+1
    particle(n,3)=int(2-rnd(0)*4)
    particle(n,4)=int(2-rnd(0)*4)
    particle(n,5)=int(rnd(0)*360)
    particle(n,6)=int(rnd(0)*360)
    return
 
    [quit]
    timer 0
    close #1
    end