Einzelnen Beitrag anzeigen

Alex_ITA01

Registriert seit: 22. Sep 2003
1.115 Beiträge
 
Delphi 12 Athens
 
#14

Re: Ein Pfeil um 360° drehen können ohne den Ursprung zu änd

  Alt 21. Apr 2005, 07:55
Moin Moin erstmal,
ich habe es jetzt so gelöst:

Delphi-Quellcode:
function Angle(const p1, p2: TPoint; const InDeg: Boolean = true): Single;
begin
  if p2.X = p1.X then
  begin
    if p1.Y < p2.Y then
      Result := pi / 2
    else
      Result := 3 * pi / 2
  end
  else
  begin
    Result := Arctan((p2.Y - p1.Y) / (p2.X - p1.X));
    if p2.x < p1.x then
      Result := Result + pi;
    if Result < 0 then
      Result := Result + 2 * pi;
  end;
  if InDeg then
    Result := RadToDeg(Result);
end;
Im MouseMove meiner Komponente:
Delphi-Quellcode:
    Canvas.Pen.Color := clLime;
    pt.X := Width div 2;
    pt.Y := Height div 2;
    Alpha := Angle(pt, Point(x, y), False);
    Canvas.MoveTo(Width div 2, Height div 2);
    Canvas.LineTo(Width div 2+ Round(Radius*cos(alpha)), Height div 2+ Round(Radius*sin(alpha)));
Jetzt habe ich nur noch das Problem, dass der "Pfeil" zwar gezeichnet wird aber der "alte" Pfeil nicht gelöscht wird. Ich kann also die Maus ganz langsam bewegen und habe dann irgendwann mal ein "voll ausgezeichneten Kreis"...
Könntet ihr mir da nochmal helfen?
Wäre echt hilfreich...

MFG Alex
Let's fetz sprach der Frosch und sprang in den Mixer
  Mit Zitat antworten Zitat