FloodFill (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code flood-fills, from the center point of Form1's client area, until the color black is encountered.

Code

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;

Uses

Personal tools
Assistance