var
Form1: TForm1;
fi:
array
[
0..2
]
of
TMyClass;
implementation
{$R *.dfm}
constructor
TMyClass
.
Create(img:TImage);
begin
m_a:=
50
;
m_alpha:=
60
;
m_beta:=
30
;
m_image:=img;
m_color:=clBlack;
m_image
.
Canvas
.
Brush
.
Color:=m_color;
end
;
function
TMyClass
.
GetBgColor:TColor;
begin
result:=m_color;
end
;
procedure
TMyClass
.
SetBgColor(color:TColor);
begin
m_color:=color;
end
;
procedure
var
pts:
array
[
1..4
]
of
TPoint;
begin
with
m_image
.
Canvas
do
begin
Brush
.
Color:=m_color;
pts[
1
].X:=m_pos
.
X + trunc(m_a*cos(m_alpha*Pi/
360
)*cos(m_beta*Pi/
180
)+
0.5
);
pts[
1
].Y:=m_image
.
Height - (m_pos
.
Y+trunc(m_a*cos(m_alpha*Pi/
360
)*sin(m_beta*Pi/
180
)+
0.5
));
pts[
2
].X:=m_pos
.
X - trunc(m_a*sin(m_alpha*Pi/
360
)*cos((
90
-m_beta)*Pi/
180
)+
0.5
);
pts[
2
].Y:=m_image
.
Height - (m_pos
.
Y+trunc(m_a*sin(m_alpha*Pi/
360
)*sin((
90
-m_beta)*Pi/
180
)+
0.5
));
pts[
3
].X:=m_pos
.
X-trunc(m_a*cos(m_alpha*Pi/
360
)*cos(m_beta*Pi/
180
)+
0.5
);
pts[
3
].Y:=m_image
.
Height - (m_pos
.
Y-trunc(m_a*cos(m_alpha*Pi/
360
)*sin(m_beta*Pi/
180
)+
0.5
));
pts[
4
].X:=m_pos
.
X + trunc(m_a*sin(m_alpha*Pi/
360
)*cos((
90
-m_beta)*Pi/
180
)+
0.5
);
pts[
4
].Y:=m_image
.
Height - (m_pos
.
Y-trunc(m_a*sin(m_alpha*Pi/
360
)*sin((
90
-m_beta)*Pi/
180
)+
0.5
));
Polygon(pts);
end
;
end
;
procedure
TMyClass
.
SetAB(A,Alpha,Beta:
integer
);
begin
m_a:=A;
m_alpha:=Alpha;
m_beta:=Beta;
end
;
procedure
TMyClass
.
GetAB(
var
A,Alpha,Beta:
integer
);
begin
a:=m_A;
Alpha:=m_Alpha;
Beta:=m_beta;
end
;
function
TMyClass
.
GetPos:TPoint;
begin
result:=m_pos;
end
;
procedure
TMyClass
.
SetPos(pos:TPoint);
begin
m_pos:=pos;
end
;
procedure
TForm1
.
FormCreate(Sender: TObject);
var
a,alpha,beta,i:
integer
;
pos:TPoint;
begin
randomize;
for
i:=
0
to
2
do
begin
fi[i]:=TMyClass
.
Create(Image1);
pos
.
X:=
100
+
75
*i;
pos
.
Y:=
50
*i+
100
;
fi[i].SetPos(pos);
fi[i].SetBgColor(RGB(random(
255
),random(
255
),random(
255
)));
fi[i].drow;
end
;
fi[
0
].GetAB(a,alpha,beta);
pos:= fi[
0
].GetPos;
LabeledEdit1
.
Text:=inttostr(A);
LabeledEdit2
.
Text:=inttostr(Alpha);
LabeledEdit3
.
Text:=inttostr(Beta);
LabeledEdit5
.
Text:=inttostr(Pos
.
X);
LabeledEdit6
.
Text:=inttostr(Pos
.
Y);
Edit1
.
TExt:=ColorToString(fi[
0
].GetBgColor);
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
a,alpha,beta,i:
integer
;
tmp:TPoint;
begin
A:=StrToInt(LabeledEdit1
.
Text);
Alpha:=StrToInt(LabeledEdit2
.
Text);
Beta:=StrToInt(LabeledEdit3
.
Text);
if
(Alpha <
0
)
then
Alpha:=
0
;
if
(Beta <
0
)
then
Beta:=
0
;
fi[RadioGroup1
.
ItemIndex].SetAB(A,ALPHA,Beta);
tmp
.
x:=StrToInt(LabeledEdit5
.
Text);
tmp
.
Y:=StrToInt(LabeledEdit6
.
Text);
fi[RadioGroup1
.
ItemIndex].SetPos(tmp);
fi[RadioGroup1
.
ItemIndex].SetBgColor(StrToInt(Edit1
.
TExt));
Image1
.
Canvas
.
Brush
.
Color:=clWhite;
Image1
.
Canvas
.
Rectangle(-
1
,-
1
,Image1
.
Width+
1
,Image1
.
Height+
1
);
for
i:=
0
to
2
do
fi[i].drow;
end
;
procedure
TForm1
.
RadioGroup1Click(Sender: TObject);
var
a,alpha,beta:
integer
;
begin
fi[RadioGroup1
.
ItemIndex].GetAB(a,alpha,beta);
LabeledEdit1
.
Text:=inttostr(A);
LabeledEdit2
.
Text:=inttostr(Alpha);
LabeledEdit3
.
Text:=inttostr(Beta);
LabeledEdit5
.
Text:=inttostr(fi[RadioGroup1
.
ItemIndex].GetPos
.
X);
LabeledEdit6
.
Text:=inttostr(fi[RadioGroup1
.
ItemIndex].GetPos
.
Y);
Edit1
.
TExt:=ColorToString(fi[RadioGroup1
.
ItemIndex].GetBgColor);
end
;
end
.