FloodFill (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code floodfills from the center point of Form1's client area until the color black is encountered.

Code

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);
}

Uses

Personal tools
Assistance