(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: Kreisbogen direkt zeichnen (ohne canvas.arc)
19. Mär 2008, 19:34
Hallo,
Falls du English kannst, lies dir doch mal den Artikel Draw an Arc with ActionScript durch.
Die Delphi Umsetzung würde etwa so aussehen:
Delphi-Quellcode:
procedure drawArc(Canvas: TCanvas; centerX, centerY, radius, startAngle, arcAngle: Real; steps: Word);
var
angleStep, angle, twoPI, xx, yy: Real;
i: Word;
begin
//
// For convenience, store the number of radians in a full circle.
twoPI := 2 * PI;
//
// To determine the size of the angle between each point on the
// arc, divide the overall angle by the total number of points.
angleStep := arcAngle / steps;
//
// Determine coordinates of first point using basic circle math.
xx := centerX + cos(startAngle * twoPI) * radius;
yy := centerY + sin(startAngle * twoPI) * radius;
//
// Move to the first point.
Canvas.moveTo(Trunc(xx), Trunc(yy));
//
// Draw a line to each point on the arc.
for i := 1 to steps - 1 do
begin
//
// Increment the angle by "angleStep".
angle := startAngle + i * angleStep;
//
// Determine next point's coordinates using basic circle math.
xx := centerX + cos(angle * twoPI) * radius;
yy := centerY + sin(angle * twoPI) * radius;
//
// Draw a line to the next point.
Canvas.lineTo(Trunc(xx), Trunc(yy));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
drawArc(Canvas, 250, 250, 200, 45 / 360, -90 / 360, 20);
end;
Thomas
|
|
Zitat
|