Fill East

    private void fillEast(int x, int y, int fill, int old) {
        if (x >= raster.width) return;
        if (raster.getPixel(x, y) == old) {
            raster.setPixel(fill, x, y);
            fillEast(x+1, y, fill, old);
            fillSouth(x, y+1, fill, old);
            fillNorth(x, y-1, fill, old);
        }
    }
	
Note:
    There is only one clipping test, and only three subsequent calls.
    Why?
    How much faster do you expect this algorithm to be?
Lecture 4   Slide 15   6.837 Fall '00