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 "seed7_05.s7i";
  include "draw.s7i";
  include "keybd.s7i";
 
const integer: SIZE is 300;
const integer: SCALE is 1;
 
const proc: genBrownianTree (in integer: fieldSize, in integer: numParticles) is func
  local
    var array array integer: world is 0 times 0 times 0;
    var integer: px is 0;
    var integer: py is 0;
    var integer: dx is 0;
    var integer: dy is 0;
    var integer: i is 0;
    var boolean: bumped is FALSE;
  begin
    world := fieldSize times fieldSize times 0;
    world[rand(1, fieldSize)][rand(1, fieldSize)] := 1;  # Set the seed
    for i range 1 to numParticles do
      # Set particle's initial position
      px := rand(1, fieldSize);
      py := rand(1, fieldSize);
      bumped := FALSE;
      repeat
        # Randomly choose a direction
        dx := rand(-1, 1);
        dy := rand(-1, 1);
        if dx + px < 1 or dx + px > fieldSize or dy + py < 1 or dy + py > fieldSize then
          # Plop the particle into some other random location
          px := rand(1, fieldSize);
          py := rand(1, fieldSize);
        elsif world[py + dy][px + dx] <> 0 then
          # Bumped into something
          world[py][px] := 1;
          rect(SCALE * pred(px), SCALE * pred(py), SCALE, SCALE, white);
          DRAW_FLUSH;
          bumped := TRUE;
        else
          py +:= dy;
          px +:= dx;
        end if;
      until bumped;
    end for;
  end func;
 
const proc: main is func
  begin
    screen(SIZE * SCALE, SIZE * SCALE);
    KEYBOARD := GRAPH_KEYBOARD;
    genBrownianTree(SIZE, 20000);
    readln(KEYBOARD);
  end func;