unit
grid_;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, jpeg, pngimage;
type
TForm1 =
class
(TForm)
PaintBox1: TPaintBox;
Image1: TImage;
Button1: TButton;
CheckBox1: TCheckBox;
Image2: TImage;
Image3: TImage;
procedure
PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y:
Integer
);
procedure
PaintBox1Paint(Sender: TObject);
private
public
end
;
var
M:
Array
[
1..600
]
of
Array
[
1..600
]
of
Byte
;
Form1: TForm1;
x0,y0:
integer
;
dx,dy:
integer
;
h,w:
integer
;
x,y:
integer
;
lx,ly:
real
;
dlx,dly:
real
;
cross:
integer
;
dcross:
integer
;
i,j:
Integer
;
implementation
{$R *.DFM}
Procedure
UstSob;
Var
i,j,z1:
Integer
;
begin
For
i:=
1
To
600
Do
For
j:=
1
To
600
Do
M[i,j]:=
0
;
M[
1
,
1
]:=
$1
;
M[
30
,
20
]:=
$2
;
end
;
procedure
TForm1
.
PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y:
Integer
);
var
h1:
integer
;
Const
a =
33
;
b =
20
;
begin
UstSob;
Image2
.
Left:= a*(X
div
a);Image2
.
Top:= b*(Y
div
b)+
111
;
if
M[(X
div
a)+
1
,(Y
div
b)+
1
] =
$1
Then
begin
Image3
.
Left:= a*(X
div
a);Image3
.
Top:= b*(Y
div
b)+
111
;
end
;
if
M[(X
div
a)+
1
,(Y
div
b)+
1
] =
$2
Then
begin
Image3
.
Left:= a*(X
div
a);Image3
.
Top:= b*(Y
div
b)+
111
;
end
;
end
;
procedure
TForm1
.
PaintBox1Paint(Sender: TObject);
begin
x0:=
0
; y0:=
400
;
dx:=
33
; dy:=
20
;
dcross:=
1
;
dlx:=
1
;
dly:=
1.0
;
h:=
400
;
w:=
991
;
with
PaintBox1
.
Canvas
do
begin
cross:=dcross;
Pen
.
Color:=clMaroon;
MoveTo(x0,y0); LineTo(x0,y0-h);
MoveTo(x0,y0); LineTo(x0+w,y0);
x:=x0+dx;
lx:=dlx;
repeat
cross:=cross-
1
;
if
cross =
0
then
begin
cross:=dcross;
end
;
Pen
.
Style:=psSolid;
MoveTo(x,y0);LineTo(x,y0-h);
Pen
.
Style:=psSolid;
lx:=lx+dlx;
x:=x+dx;
until
(x>x0+w);
y:=y0-dy;
ly:=dly;
repeat
Pen
.
Style:=psSolid;
Pen
.
Color:=clMaroon;
MoveTo(x0,y); LineTo(x0+w,y);
Pen
.
Style:=psSolid;
y:=y-dy;
ly:=ly+dly;
until
(y<y0-h);
end
;
end
;
end
.