Hola RSC9421.
No veo la dificultad en borrar y dibujar una linea ante la presión de una tecla como por ejemplo hago en este código:
Código Delphi
[-]
...
implementation
const
INCR = PI / 15;
var
Center: TPoint;
Posic : TPoint;
Radio : Integer;
Cont : Single;
procedure TForm1.FormCreate(Sender: TObject);
begin
Canvas.Pen.Style:= psSolid;
Canvas.Pen.Color:= clBlack;
Center:= Point(Width div 2, Height div 2);
Posic:= Point(0, 0);
Radio:= 100;
Cont:= PI;
KeyPreview:= True;
end;
procedure DrawLine(CV: TCanvas; const Ini,Fin: TPoint; const aColor: TColor);
begin
CV.Pen.Color:= aColor;
CV.MoveTo(Ini.X,Ini.Y);
CV.LineTo(Fin.X, Fin.Y);
CV.Ellipse(Fin.X-5,Fin.Y-5,Fin.X+5,Fin.Y+5);
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
DrawLine(Canvas, Center, Posic, clBtnFace);
Posic.X:= Center.X + Trunc(Radio * sin(Cont));
Posic.Y:= Center.Y + Trunc(Radio * cos(Cont));
DrawLine(Canvas, Center, Posic, clBlack);
if Key = VK_RIGHT then
Cont:= Cont - INCR
else if Key = VK_LEFT then
Cont:= Cont + INCR;
end;
...
Saludos