Polygon Fill algorithm: Boundary fill algorithm
18
Eight-neighbouring points Algorithm:
Boundaryfill( x, y, fill_color, boundary_color)
Step 1− Obtain the current pixel attributes such as color
current = getpixel( x,y)
Step 2− Perform check and fill appropriate pixels
if( current != boundary_color) && (current != fill_color) then
setpixelcolor(x, y, fill_color)
call Boundaryfill( x+1, y, fill_color, boundary_color)
call Boundaryfill( x-1, y, fill_color, boundary_color)
call Boundaryfill( x, y+1, fill_color, boundary_color)
call Boundaryfill( x, y-1, fill_color, boundary_color)
call Boundaryfill( x+1, y+1, fill_color, boundary_color)
call Boundaryfill( x-1, y-1, fill_color, boundary_color)
call Boundaryfill( x+1, y-1, fill_color, boundary_color)
call Boundaryfill( x-1, y+1, fill_color, boundary_color)
Step 3− Stop