26 lines
1.2 KiB
Text
26 lines
1.2 KiB
Text
fill: procedure (x, y, fill_color) recursive; /* 12 May 2010 */
|
|
declare (x, y) fixed binary;
|
|
declare fill_color bit (24) aligned;
|
|
|
|
if x <= lbound(image, 2) | x >= hbound(image, 2) then return;
|
|
if y <= lbound(image, 1) | y >= hbound(image, 1) then return;
|
|
|
|
pixel_color = image (x,y); /* Obtain the color of the current pixel. */
|
|
if pixel_color ^= area_color then return;
|
|
/* the pixel has already been filled with fill_color, */
|
|
/* or we are not within the area to be filled. */
|
|
image(x, y) = fill_color; /* color the desired area. */
|
|
|
|
pixel_color = image (x,y-1); /* Obtain the color of the pixel to the north. */
|
|
if pixel_color = area_color then call fill (x, y-1, fill_color);
|
|
|
|
pixel_color = image (x-1,y); /* Obtain the color of the pixel to the west. */
|
|
if pixel_color = area_color then call fill (x-1, y, fill_color);
|
|
|
|
pixel_color = image (x+1,y); /* Obtain the color of the pixel to the east. */
|
|
if pixel_color = area_color then call fill (x+1, y, fill_color);
|
|
|
|
pixel_color = image (x,y+1); /* Obtain the color of the pixel to the south. */
|
|
if pixel_color = area_color then call fill (x, y+1, fill_color);
|
|
|
|
end fill;
|