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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
| uses crt,graph;
type
k=object
color : word;
size:integer;
procedure init(const x1,y1,c1:word);
procedure draw(acolor:word);
procedure show;
procedure Hide;
procedure Moveto(dx, dy: integer);
procedure done(var x1,y1,c1:word);
end;
s=object(k)
c : word;
s:integer;
procedure draw(acolor:word);
end;
v=object(k)
c : word;
s:integer;
procedure draw(acolor:word);
end;
var
x,y,i,j,dx,dy,r,u,l,x1,y1: integer;
m,m1:char;
q,z:real;
c,c1:word;
k1:k;
s1:s;
v1:v;
procedure k.init;
begin
x:=x1;
y:=y1;
c:=c1;
end;
procedure k.draw;
var r,u:word;
begin r:=100;
u:=4;
setcolor(getbkcolor);
SetFillStyle (1,color);
moveto(round(r*cos((pi/2)/u))+x,-round(r*sin((pi/2)/u))+y);
for l:=0 to u do
begin
q:=r*cos((pi/2+2*pi*l)/u);
z:=r*sin((pi/2+2*pi*l)/u);
lineto(round(q)+x,-round(z)+y);
end;
{setcolor(getbkcolor);
line(x-30,y-30,x+30,y-30); line(x+30,y-30,x+30,y+30);
line(x+30,y+30,x-30,y+30); line(x-30,y+30,x-30,y-30);
setFillStyle(1,getbkcolor); }
end;
procedure k.show;
begin;
draw(red);
end;
procedure k.hide;
begin;
draw(getbkcolor);
end;
procedure k.moveto;
{var c: word; }
begin
hide;
if ((x+dx)>getmaxx) then begin if ((x+dx)<0) then begin
if ((y+dy)>getmaxx) then begin if ((y+dy)<0) then begin
x:=x+dx; y:=y+dy;
show; end; end;end;end
end;
procedure k.done;
begin x1:=x;
y1:=y;
c1:=c;
end;
procedure s.draw;
begin r:=100;
u:=6;
setcolor(getbkcolor);
SetFillStyle (1,color);
moveto(round(r*cos((pi/2)/u))+x,-round(r*sin((pi/2)/u))+y);
for l:=0 to u do
begin
q:=r*cos((pi/2+2*pi*l)/u);
z:=r*sin((pi/2+2*pi*l)/u);
lineto(round(q)+x,-round(z)+y);
end;
end;
procedure v.draw;
begin r:=100;
u:=8;
setcolor(getbkcolor);
SetFillStyle (1,color);
moveto(round(r*cos((pi/2)/u))+x,-round(r*sin((pi/2)/u))+y);
for l:=0 to u do
begin
q:=r*cos((pi/2+2*pi*l)/u);
z:=r*sin((pi/2+2*pi*l)/u);
lineto(round(q)+x,-round(z)+y);
end;
end;
BEGIN
i:=detect;
initgraph (i,j,' ');
c1:=(1);
x:=(Getmaxx div 2);
y:=Getmaxy div 2;
m1:=#0;
repeat
if keypressed then
begin
m:=readkey;
if m=#0 then m:=readkey;
case m of
#9: begin
k1.show;
end;
#45: begin
if u=4 then v1.show;
if u=6 then k1.show;
if u=8 then s1.show;
end;
#43: begin
if u=4 then s1.show;
if u=6 then v1.show;
if u=8 then k1.show;
end;
#80: begin
k1.moveto(0,5);
s1.moveto(0,5);
v1.moveto(0,5);
end;
#72:begin
k1.moveto (0,-5);
s1.moveto (0,-5);
v1.moveto (0,-5);
end;
#77:begin
k1.moveto(5,0) ;
s1.moveto(5,0) ;
v1.moveto(5,0);
end;
#75:begin
k1.moveto(-5,0);
s1.moveto(-5,0);
v1.moveto(-5,0);
end;
#27: exit;
end;
end;
m1:=m;
until m=#27;
closegraph;
END. |