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. 



include c:\cxpl\codes;  \intrinsic 'code' declarations
def W=128, H=W;         \width and height of field
int X, Y;
[SetVid($13);           \set 320x200 graphic video mode
Point(W/2, H/2, 6\brown\);               \place seed in center of field
loop    [repeat X:= Ran(W);  Y:= Ran(H); \inject particle
        until   ReadPix(X,Y) = 0;        \ in an empty location
        loop    [Point(X, Y, 6\brown\);  \show particle
                if ReadPix(X-1,Y) or ReadPix(X+1,Y) or \particle collided
                   ReadPix(X,Y-1) or ReadPix(X,Y+1) then quit;
                Point(X, Y, 0\black\);   \erase particle
                X:= X + Ran(3)-1;        \(Brownian) move particle
                Y:= Y + Ran(3)-1;
                if X<0 or X>=W or Y<0 or Y>=H then quit; \out of bounds
                ];
        if KeyHit then [SetVid(3);  quit]; \restore text mode
        ];
]