www.pudn.com > CG2Programs.rar > floodFill.c
/* floodFill, Chapter 3, p. 130 */
#include "device.h"
/* EXAMPLE STARTS HERE */
void floodFill4 (int x, int y, int fillColor, int oldColor)
{
if (getPixel (x, y) == oldColor) {
setColor (fillColor);
setPixel (x, y);
floodFill4 (x+1, y, fillColor, oldColor);
floodFill4 (x-1, y, fillColor, oldColor);
floodFill4 (x, y+1, fillColor, oldColor);
floodFill4 (x, y-1, fillColor, oldColor);
}
}
/* EXAMPLE ENDS HERE */