_floodfill, _floodfill_w

Description

Fill an area of a display using the current color and fill mask.

#include <graph.h>

short __far _floodfill( short x, short y, short boundary );

short __far _floodfill_w( double wx, double wy, short boundary );

x, y Start point  
wx, wy Start point  
boundary Boundary color of area to be filled  

Remarks

The functions in the _floodfill family fill an area of the display, using the current color and fill mask. The _floodfill routine begins filling at the view-coordinate point (x, y). The _floodfill_w routine begins filling at the window-coordinate point (wx, wy).

If this point lies inside the figure, the interior is filled; if it lies outside the figure, the background is filled. The point must be inside or outside the figure to be filled, not on the figure boundary itself. Filling occurs in all directions, stopping at the color of boundary.

Return Value

The _floodfill functions return a nonzero value if the fill is successful. They return 0 if the fill could not be completed, the starting point lies on the boundary color, or the start point lies outside the clipping region.

Compatibility

Standards:None

16-Bit:DOS

32-Bit:None

See Also

_ellipse functions, _getcolor, _getfillmask, _grstatus, _pie functions, _setfillmask, _setcliprgn, _setcolor

Example

/* FLOODFIL.C: This program draws a series of nested rectangles in

* different colors, constantly changing the background color.

*/

#include <conio.h>

#include <stdlib.h>

#include <graph.h>

void main( void )

{

int loop;

int xvar, yvar;

/* find a valid graphics mode */

if( !_setvideomode( _MAXCOLORMODE ) )

exit( 1 );

for( xvar = 163, loop = 0; xvar < 320; loop++, xvar += 3 )

{

_setcolor( loop % 16 );

yvar = xvar * 5 / 8;

_rectangle( _GBORDER, 320-xvar, 200-yvar, xvar, yvar );

_setcolor( rand() % 16 );

_floodfill( 0, 0, loop % 16 );

}

_getch();

_setvideomode( _DEFAULTMODE );

}