RAD Studio VCL Reference
|
Fills an area of the canvas using the current brush.
procedure FloodFill(X: Integer; Y: Integer; Color: TColor; FillStyle: TFillStyle);
__fastcall FloodFill(int X, int Y, TColor Color, TFillStyle FillStyle);
Use FloodFill to fill a possibly non-rectangular region of the image with the value of Brush. The boundaries of the region to be filled are determined by moving outward from the point (X,Y) until a color boundary involving the Color parameter is encountered.
X and X are the coordinates on the canvas where filling starts.
Color is the color that defines the boundary of the region to fill. Its interpretation depends on the value of FillStyle.
FillStyle specifies whether the region is defined by all pixels with the same value as Color, or all points with a different value.
C++ Examples:
/* The following code floodfills from the center point of Form1's client area until the color black is encountered: */ void __fastcall TForm1::Button1Click(TObject *Sender) { Canvas->Brush->Color = clBlue; Canvas->Brush->Style = bsDiagCross; Canvas->FloodFill( ClientWidth/2, ClientHeight/2, clBlack, fsBorder); } void __fastcall TForm1::Button2Click(TObject *Sender) { int ewidth = 400; int eheight = 200; Canvas->Brush->Color = clRed; Canvas->Pen->Color = clBlack; Canvas->Ellipse( (ClientWidth - ewidth)/2, (ClientHeight - eheight)/2, ewidth, eheight); }
Delphi Examples:
{ The following code floodfills from the center point of Form1's client area until the color black is encountered: } procedure TForm1.Button1Click(Sender: TObject); begin Canvas.Brush.Color := clBlue; Canvas.Brush.Style := bsDiagCross; Canvas.FloodFill( ClientWidth div 2, ClientHeight div 2, clBlack, fsBorder); end; procedure TForm1.Button2Click(Sender: TObject); var ewidth, eheight: integer; begin ewidth := 400; eheight := 200; Canvas.Brush.Color := clRed; Canvas.Pen.Color := clBlack; Canvas.Ellipse( (ClientWidth - ewidth) div 2, (ClientHeight - eheight) div 2, ewidth, eheight); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|