Einzelnen Beitrag anzeigen

Glados
(Gast)

n/a Beiträge
 
#9

AW: Kopieren-Animation in Painbox zeichnen

  Alt 5. Nov 2017, 15:50
So wirklich funktioniert es nicht

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
 Timer1.Interval := 50;
 iPosX := 0;
 bmp := TBitmap.Create;
 bmp.Width := PaintBox1.Width;
 bmp.Height := PaintBox1.Height;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 Timer1.Enabled := not Timer1.Enabled;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
 val: Integer;
begin
 Application.ProcessMessages;

 if iPosX >= PaintBox1.Width then
  Dec(iPosX);

 val := RandomRange(25, 45);

 bmp.Canvas.MoveTo(iPosX, bmp.Height - val);
 bmp.Canvas.LineTo(iPosX, bmp.Height);

 Inc(iPosX);

 PaintBox1.Repaint;
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
  TPaintBox(Sender).Canvas.Draw(0, 0, bmp);
end;
  Mit Zitat antworten Zitat