Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use FloodFill?

870 views
Skip to first unread message

Martin Kolka

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to
I don't know use command FloodFill.
Help me somebody.

Thanx Virus.


Earl F. Glynn

unread,
Mar 1, 1999, 3:00:00 AM3/1/99
to

Martin Kolka wrote in message <01be630a$9e55d2c0$8dce...@P25-1.utc.sk>...

>I don't know use command FloodFill.
>Help me somebody.

Here's an example using the fsSurface parameter -- this will fill an area that has the color specified by the Color parameter.
Flood fill stops when another color is encountered.


// Floodfill as much as possible at given point
procedure TFormMazeMaker.ImageMazeMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
VAR
Color: TColor;
begin
Color := ImageMaze.Canvas.Pixels[X,Y];
ImageMaze.Canvas.Brush.Color := ShapeColor.Brush.Color;
ImageMaze.Canvas.FloodFill(X,Y, Color, fsSurface)
end;

The other possible FillStyle is fsBorder. This will fill an area that does not have the color specified, stopping when the Color is
encountered.

efg
_________________________________
efg's Computer Lab: www.efg2.com/lab
Delphi Books: www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn E-Mail: Earl...@att.net
Overland Park, KS USA


Kurt Barthelmess (TeamB)

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
It's pretty straight forward. You set the Canvas' Brush property to
what you want to fill the area with, and you pick a starting point,
and the color of the pixel where you want to stop. Then you do it.

What exactly is confusing here?

Good luck.

Kurt

acdhirr

unread,
Mar 30, 1999, 3:00:00 AM3/30/99
to Martin Kolka
Martin Kolka wrote:
>
> I don't know use command FloodFill.
> Help me somebody.
>
> Thanx Virus.

Floodfill fills an area that is determined by either a border (fsBorder)
or a solid region with a fixed color (fsSurface).
it fills the area with the current Canvas.Brush color till it encounters
the border or till the outer bounds of the region.
Compare it to the paintbucket tool in many photo/graphical applications
(i.e. PhotoShop).

This draws a circle with a green border:

X := 50;
Y := 50;
Canvas.Brush.Color := clGreen;
Canvas.Pen.Width := 1;
Canvas.Ellipse(X-3, Y-3, X+3, Y+3);

And this fills the entire area included by that green border with white:

Canvas.Brush.Color := clWhite;
canvas.FloodFill(X, Y, clGreen, fsBorder);

Try it.

Good luck,

Richard.

0 new messages