TCanvasAngleArc (C++)
Description
The following example exercises TCanvas.AngleArc and illustrates graphically how the parameters are used in the construction of the arc section.
Code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Extended Sin, Cos;
int X1 = StrToInt(Edit1->Text);
int Y1 = StrToInt(Edit2->Text);
Extended Radius = StrToInt(Edit3->Text);
Extended StartAngle = StrToFloat(Edit4->Text);
Extended SweepAngle = StrToFloat(Edit5->Text);
Repaint();
Canvas->Pen->Color = clDefault;
Canvas->MoveTo(X1-Radius, Y1-Radius); // Bounding box of the circle
Canvas->LineTo(X1+Radius, Y1-Radius);
Canvas->LineTo(X1+Radius, Y1+Radius);
Canvas->LineTo(X1-Radius, Y1+Radius);
Canvas->LineTo(X1-Radius, Y1-Radius);
Canvas->MoveTo(X1, Y1);
SinCos(((StartAngle+SweepAngle)*2*M_PI)/360, Sin, Cos); // Angle has to be radians
Canvas->LineTo(X1+Floor(Radius*Cos), Y1-Floor(Radius*Sin)); // Sweep is relative to Start
Canvas->MoveTo(X1, Y1);
SinCos((StartAngle*2*M_PI)/360, Sin, Cos);
Canvas->LineTo(X1+Floor(Radius*Cos), Y1-Floor(Radius*Sin));
Canvas->Pen->Color = clRed;
Canvas->AngleArc(X1, Y1, Radius, StartAngle, SweepAngle);
Canvas->LineTo(300, 300); // Show where AngleArc left the current position.
}
Uses
- Vcl.Graphics.TCanvas.AngleArc ( fr | de | ja )
- System.Math.SinCos ( fr | de | ja )