Einzelnen Beitrag anzeigen

DaCoda

Registriert seit: 21. Jul 2006
Ort: Hamburg
123 Beiträge
 
Delphi 12 Athens
 
#14

AW: Canvas.Arc Problem

  Alt 20. Sep 2024, 12:41
Ich hatte das so probiert, ich denke aber das ist auch nicht richtig gedacht von mir:

Code:

procedure TGCodeRenderer.DrawArc(CX, CY, Radius, StartAngle, EndAngle: Double; Clockwise: Boolean; Color: TColor);
var
  StartX, StartY, EndX, EndY: Double;
  ArcRect: TRect;
begin
  StartX := CX + Radius * Cos(StartAngle);
  StartY := CY + Radius * Sin(StartAngle);
  EndX := CX + Radius * Cos(EndAngle);
  EndY := CY + Radius * Sin(EndAngle);

  (* DIESEN TEIL HATTE ICH MAL GETESTET, IST ABER SICHER AUCH WIEDER FALSCH *)

  if (Round(StartX * FScale) = Round(EndX * FScale)) or (Round(StartY * FScale) = Round(EndY * FScale)) then begin
    FCurrentX := EndX;
    FCurrentY := EndY;
    Exit;
  end;
  *)

  (**************************************************************************)

  ArcRect := Rect(
    Round((CX - Radius) * FScale),
    Round((CY - Radius) * FScale),
    Round((CX + Radius) * FScale),
    Round((CY + Radius) * FScale)
    );

  FCanvas.Pen.Color := Color;

  if Clockwise then begin
    FCanvas.Arc(ArcRect.Left, Round(AdjustY(ArcRect.Top)), Round(ArcRect.Right), Round(AdjustY(ArcRect.Bottom)), Round(EndX * FScale), Round(AdjustY(EndY * FScale)), Round(StartX * FScale), Round(AdjustY(StartY * FScale)));
  end else begin
    FCanvas.Arc(ArcRect.Left, Round(AdjustY(ArcRect.Top)), Round(ArcRect.Right), Round(AdjustY(ArcRect.Bottom)), Round(StartX * FScale), Round(AdjustY(StartY * FScale)), Round(EndX * FScale), Round(AdjustY(EndY * FScale)));
  end;

  FCurrentX := EndX;
  FCurrentY := EndY;
end;
Debuggers don’t remove bugs, they only show them in slow-motion.
  Mit Zitat antworten Zitat