Java Applets Centre
Fill-Area Algorithm


Description
This applet demonstrates how the interior of a polygon is filled using a recursive four-connected fill algorithm.


Code (Recursive Fill Algorithm)

void boundaryFill(int x, int y){
  if(getPixel(x,y)==0){
   setPixel(x,y);
   boundaryFill(x+1,y);
   boundaryFill(x-1,y);
   boundaryFill(x,y+1);
   boundaryFill(x,y-1);
  }
}

Computer Graphics
Java Applets Centre


R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.