RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.Ellipse Method (Integer, Integer, Integer, Integer)

Draws the ellipse defined by a bounding rectangle on the canvas.

Pascal
procedure Ellipse(X1: Integer; Y1: Integer; X2: Integer; Y2: Integer); overload;
procedure Ellipse(const Rect: TRect); overload;
C++
__fastcall Ellipse(int X1, int Y1, int X2, int Y2);
__fastcall Ellipse(const TRect Rect);

Call Ellipse to draw a circle or ellipse on the canvas. Specify the bounding rectangle either by giving  

The top left point at pixel coordinates (X1, Y1) and the bottom right point at (X2, Y2).  

A TRect value. 

If the bounding rectangle is a square, a circle is drawn. 

The ellipse is outlined using the value of Pen, and filled using the value of Brush.

Note: On Windows 9x or Windows ME, the sums X1 + X2 and Y1 + Y2 cannot exceed 32768. Also, the sum X1 + X2 + Y1 + Y2 cannot exceed 32768.
 

C++ Examples: 

 

/*
The following example paints a cross-hatched ellipse onto 
Image1 which is a TImage on the form when the user clicks on
Button1.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TCanvas *pCanvas = Image1->Canvas;
  pCanvas->Brush->Color = clRed;
  pCanvas->Brush->Style = bsDiagCross;
  pCanvas->Ellipse(0, 0, Image1->Width, Image1->Height);
}

 

Delphi Examples: 

{
The following example paints a cross-hatched ellipse onto 
Image1 which is a TImage on the form when the user clicks on
Button1.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  with Image1 do begin
    Canvas.Brush.Color := clRed;
    Canvas.Brush.Style := bsDiagCross;
    Canvas.Ellipse(0, 0, Image1.Width, Image1.Height);
  end;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!