unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled:=true;
end;

{$J+}
procedure TForm1.Timer1Timer(Sender: TObject);
const x1:integer=0;
      y1:integer=100;
      krok:integer=5;
begin
  //kasowanie obiektu
  Canvas.Brush.color:=Color;  //kolor formularza
  Canvas.Pen.color:=Color;    //kolor pióra
  Form1.Canvas.Ellipse(x1,y1,x1+30,y1+30);
  //rysowanie kółka kolorem czerwonym
  Canvas.Brush.color:=clRed;
  x1:=x1+krok;
  Canvas.Ellipse(x1,y1,x1+30,y1+30);
  if x1+30>= Clientwidth then krok:=-krok;
  if x1<=0 then krok:=-krok;
end;

end.
