1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x1, y1, x2, y2, px, py : integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
//canvas.ellipse((self.ClientWidth div 2) - 15, (self.ClientHeight div 2) - 15 ,(self.ClientWidth div 2) + 15, (self.ClientHeight div 2) + 15 );
//canvas.Pixels[self.clientWidth div 2,self.ClientHeight div 2]:=clRed;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
x1:=0;
y1:=0;
x2:=10;
y2:=10;
py:=1;
px:=1;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
canvas.Pen.Color:=clred;
//canvas.Brush.Color:=clblue;
x1:=x1+px;
y1:=y1+py;
x2:=x2+px;
y2:=y2+py;
canvas.Ellipse(x1, y1, x2, y2);
if (x2>=clientwidth) or (x1<= 0) then
px:=-px
else
if (y2>=clientheight) or (y1<=0) then
py:=-py;
end;
end. |
Partager