Thanx Virus.
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
What exactly is confusing here?
Good luck.
Kurt
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.