//  Flood fill tool that uses a slow recursive algorithm
//  that frequently causes the stack to overflow. 

  var debug = false;

 macro "Flood Fill Tool -C009o33bb" {
        requires("1.30k");
        getCursorLoc(x, y, z, flags);
        floodFill(x, y, getPixel(x, y));
     }

  function floodFill(x, y, color) {
      if (getPixel(x,y)==color) { 
          drawLine(x, y, x, y);
          if (debug) {updateDisplay(); wait(10);}
          floodFill(x+1, y, color); 
          floodFill(x, y+1, color); 
          floodFill(x-1, y, color); 
          floodFill(x, y-1, color); 
      } 
  }

