RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.Chord Method

Draws a closed figure represented by the intersection of a line and an ellipse.

Pascal
procedure Chord(X1: Integer; Y1: Integer; X2: Integer; Y2: Integer; X3: Integer; Y3: Integer; X4: Integer; Y4: Integer);
C++
__fastcall Chord(int X1, int Y1, int X2, int Y2, int X3, int Y3, int X4, int Y4);

Use Chord to create a shape that is defined by an arc and a line that joins the endpoints of the arc. The chord consists of a portion of an ellipse that is bounded by the points (X1,Y1) and (X2,Y2). The ellipse is bisected by a line that runs between the points (X3,Y3) and (X4,Y4).  

The perimeter of the chord runs counter clockwise from (X3, Y3), counterclockwise along the ellipse to (X4,Y4), and straight back to (X3,Y3). If (X3,Y3) and (X4,Y4) are not on the surface of the ellipse, the corresponding corners on the chord are the closest points on the perimeter that intersect the line. The outline of the chord is drawn using the value of Pen, and the shape is 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.
On NT, the drawing direction can be changed to clockwise using the Windows API call SetArcDirection.  

C++ Examples: 

 

/*
This code draws a chord on the top of an ellipse bounded by
the current window.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TRect R = GetClientRect();  //Get coordinates of the current window.
  Canvas->Chord(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);
}

 

Delphi Examples: 

{
This code draws a chord on the top of an ellipse bounded by
the current window.
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  R: TRect;
begin
  R := GetClientRect;  { Get coordinates of the current window. }
  Canvas.Chord(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);
end;

 

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