TCanvasAngleArc (Delphi)
From RAD Studio Code Examples
Description
The following example exercises TCanvas.AngleArc and illustrates graphically how the parameters are used in the construction of the arc section.
Code
procedure TForm1.Button1Click(Sender: TObject); var X1, Y1, Radius: Integer; StartAngle, SweepAngle: Extended; Sin, Cos: Extended; begin X1:= StrToInt(Edit1.Text); Y1:= StrToInt(Edit2.Text); Radius:= StrToInt(Edit3.Text); StartAngle:= StrToFloat(Edit4.Text); 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*Pi)/360, Sin, Cos); // Angle has to be radians Canvas.LineTo(X1+Round(Radius*Cos), Y1-Round(Radius*Sin)); // Sweep is relative to Start Canvas.MoveTo(X1, Y1); SinCos((StartAngle*2*Pi)/360, Sin, Cos); Canvas.LineTo(X1+Round(Radius*Cos), Y1-Round(Radius*Sin)); Canvas.Pen.Color := clRed; Canvas.AngleArc(X1, Y1, Radius, StartAngle, SweepAngle); Canvas.LineTo(300, 300); // Show where AngleArc left the current position. end;
Uses
- Vcl.Graphics.TCanvas.AngleArc ( fr | de | ja )
- System.Math.SinCos ( fr | de | ja )