FloodFill用法记述

函数说明如下:

{x,y:当前坐标
Color:针对该色彩执行填充事件
FillStyle:fsBorder(从当前位置开始填充,直到遇到Color),fsSurFace(当前底色和color相同时填充) } procedure TCanvas.FloodFill(X, Y: Integer; Color: TColor; FillStyle: TFillStyle);
 
  

示例代码

procedure TForm15.btn1Click(Sender: TObject);
const
  Points1: array[0..2] of TPoint =
    ((X:0; Y:0), (X:100; Y:100), (X:15; Y:50));
  Points2: array[0..2] of TPoint =
    ((X:0; Y:200), (X:100; Y:300), (X:50; Y:350));
begin
  self.Repaint;
  
  Canvas.Pen.Color := clred;
  canvas.Brush.Color:=clred;
  Canvas.Polygon(Points1);

  canvas.Brush.Color:=clgreen;
  Canvas.FloodFill(0,0,clred,fsSurface);


  Canvas.Pen.Color := clred;
  Canvas.Polygon(Points2);

  canvas.Brush.Color:=clgreen;
  Canvas.FloodFill(50,250,clred,fsBorder);

end;

procedure TForm15.btn2Click(Sender: TObject);
const
  Points3: array[0..3] of TPoint =
    ((X:0; Y:0), (X:100; Y:100), (X:15; Y:50), (X:0; Y:0));
  Points4: array[0..3] of TPoint =
    ((X:0; Y:200), (X:100; Y:300), (X:50; Y:350), (X:0; Y:200));
begin
  self.Repaint;

  Canvas.Pen.Color := clred;
  Canvas.Pen.Width := 2;
  Canvas.Polyline(Points3);
  canvas.Brush.Color:=clgreen;
  Canvas.FloodFill(0,0,clred,fsSurface);

  Canvas.Pen.Color := clred;
  Canvas.Polyline(Points4);
  canvas.Brush.Color:=clgreen;
  Canvas.FloodFill(50,280,clred,fsBorder);
end;


你可能感兴趣的:(Delphi)