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?
|