-
Notifications
You must be signed in to change notification settings - Fork 0
/
STORECD.PAS
438 lines (376 loc) · 12.5 KB
/
STORECD.PAS
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
program GraphicsByCode;
{Special advantages to storing by code: (vs pixel)
1) Excellent Speed
2) Very Small Storage file
3) Ability to "draw over" other pictures
Disadvantages:
1) Much longer program code
(yet just 3 or 4 pictures makes this better than actual coding)}
uses crt, graph;
type
stringtype=string[20];
stringline=string[80];
var
lineoftext : stringline;
ch : char;
var
device,mode:integer;
r,x,y,max:integer;
loop,count:integer;
color:byte;
dosname:string[12];
pasfile:text;
location:string[80];
xpos,ypos:integer;
marker,size:byte;
sizex,sizey:integer;
{********************************* CODES ***********************************}
{ COMMAND CODE
(all non-capital letters are numbers)
bar(x1,y1,x2,y2) B x1 y1 x2 y2
ellipse(x,y,startangle,endangle,xrad,yrad) E x y sa ea xr yr
fillellipse(x,y,xrad,yrad) FE x y xr yr
floodfill(x,y,bordercolor) F x y bc
line(x1,y1,x2,y2) L x1 y1 x2 y2
putpixel(x,y,color) P x y c
rectangle(x1,y1,x2,y2) R x1 y1 x2 y2
setcolor(color) S c
setfillstyle(pattern,color) SF p c
setlinestyle(style,pattern,thickness) SL s p t
settextstyle(font,direction,size) ST f d s
outtextxy(x,y,st) O x y st
NUMBERS
(colors)
black 0 brown 6 lightcyan 11
blue 1 lightgray 7 lightred 12
green 2 darkgray 8 lightmagenta 13
cyan 3 lightblue 9 yellow 14
red 4 lightgreen 10 white 15
magenta 5
(fill patterns)
EmptyFill 0 Uses background color
SolidFill 1 Uses draw color
LineFill 2 --- fill
LtSlashFill 3 /// fill
SlashFill 4 /// thick fill
BkSlashFill 5 \\\ thick fill
LtBkSlashFill 6 \\\ fill
HatchFill 7 Light hatch fill
XHatchFill 8 Heavy cross hatch
InterleaveFill 9 Interleaving line
WideDotFill 10 Widely spaced dot
CloseDotFill 11 Closely spaced dot
UserFill 12 User-defined fill
(line styles, use case)
solidln 0 centerln 2
dottedln 1 dashedln 3
line pattern: 0
(line thickness)
normwidth 1
thickwidth 3
(text font)
default font 0 sanseri 3
triplex 1 gothic 4
small 2
(text direction)
horizontal 0
verticle 1
text size: 0 or greater
}
{***************************************************************************}
{---------------------------------------------------------------------------}
procedure DRAWPICTUREBYCODE(beginx,beginy:integer;dosname:stringtype);
{dosname = name of the file, including extention
beginx, beginy = the coordinates of where the upper left hand corner
of where the picture will be.}
var
pasfile : text;
color : integer;
cd : char;
{..........................................................................}
procedure barcode(beginx,beginy:integer);
var
bx1 : integer;
bx2 : integer;
by1 : integer;
by2 : integer;
begin
read(pasfile,cd);
read(pasfile,bx1);
read(pasfile,cd);
read(pasfile,by1);
read(pasfile,cd);
read(pasfile,bx2);
read(pasfile,cd);
read(pasfile,by2);
bx1:=bx1 + beginx;
bx2:=bx2 + beginx;
by1:=by1 + beginy;
by2:=by2 + beginy;
bar(bx1,by1,bx2,by2);
end;
{..........................................................................}
procedure ellipsecode(beginx,beginy:integer);
var
ex : integer;
ey : integer;
esa : integer;
eea : integer;
exr : integer;
eyr : integer;
begin
read(pasfile,cd);
read(pasfile,ex);
read(pasfile,cd);
read(pasfile,ey);
read(pasfile,cd);
read(pasfile,esa);
read(pasfile,cd);
read(pasfile,eea);
read(pasfile,cd);
read(pasfile,exr);
read(pasfile,cd);
read(pasfile,eyr);
ex:=ex + beginx;
ey:=ey + beginy;
ellipse(ex,ey,esa,eea,exr,eyr);
end;
{..........................................................................}
procedure fillellipsecode(beginx,beginy:integer);
var
fex : integer;
fey : integer;
fexr : integer;
feyr : integer;
begin
read(pasfile,cd);
read(pasfile,fex);
read(pasfile,cd);
read(pasfile,fey);
read(pasfile,cd);
read(pasfile,fexr);
read(pasfile,cd);
read(pasfile,feyr);
fex:=fex + beginx;
fey:=fey + beginy;
fillellipse(fex,fey,fexr,feyr);
end;
{..........................................................................}
procedure floodfillcode(beginx,beginy:integer);
var
fx : integer;
fy : integer;
fbc : integer;
begin
read(pasfile,fx);
read(pasfile,cd);
read(pasfile,fy);
read(pasfile,cd);
read(pasfile,fbc);
fx:=fx + beginx;
fy:=fy + beginy;
floodfill(fx,fy,fbc);
end;
{..........................................................................}
procedure linecode(beginx,beginy:integer);
var
lx1 : integer;
ly1 : integer;
lx2 : integer;
ly2 : integer;
begin
read(pasfile,cd);
read(pasfile,lx1);
read(pasfile,cd);
read(pasfile,ly1);
read(pasfile,cd);
read(pasfile,lx2);
read(pasfile,cd);
read(pasfile,ly2);
lx1:=lx1 + beginx;
lx2:=lx2 + beginx;
ly1:=ly1 + beginy;
ly2:=ly2 + beginy;
line(lx1,ly1,lx2,ly2);
end;
{..........................................................................}
procedure putpixelcode(beginx,beginy:integer);
var
px : integer;
py : integer;
begin
read(pasfile,cd);
read(pasfile,px);
read(pasfile,cd);
read(pasfile,py);
read(pasfile,cd);
read(pasfile,color);
px:=px + beginx;
py:=py + beginy;
putpixel(px,py,color);
end;
{..........................................................................}
procedure rectanglecode(beginx,beginy:integer);
var
rx1 : integer;
ry1 : integer;
rx2 : integer;
ry2 : integer;
begin
read(pasfile,cd);
read(pasfile,rx1);
read(pasfile,cd);
read(pasfile,ry1);
read(pasfile,cd);
read(pasfile,rx2);
read(pasfile,cd);
read(pasfile,ry2);
rx1:=rx1 + beginx;
rx2:=rx2 + beginx;
ry1:=ry1 + beginy;
ry2:=ry2 + beginy;
rectangle(rx1,ry1,rx2,ry2)
end;
{..........................................................................}
procedure setcolorcode;
begin
read(pasfile,color);
setcolor(color);
end;
{..........................................................................}
procedure setfillstylecode;
var
sfp : byte;
begin
read(pasfile,cd);
read(pasfile,sfp);
read(pasfile,cd);
read(pasfile,color);
setfillstyle(sfp,color);
end;
{..........................................................................}
procedure setlinestylecode;
var
sls : byte;
slp : byte;
slt : byte;
begin
read(pasfile,cd);
read(pasfile,sls);
read(pasfile,cd);
read(pasfile,slp);
read(pasfile,cd);
read(pasfile,slt);
setlinestyle(sls,slp,slt);
end;
{..........................................................................}
procedure settextstylecode;
var
stf : integer;
std : integer;
sts : integer;
begin
read(pasfile,cd);
read(pasfile,stf);
read(pasfile,cd);
read(pasfile,std);
read(pasfile,cd);
read(pasfile,sts);
settextstyle(stf,std,sts);
end;
{..........................................................................}
procedure outtextcode(beginx,beginy:integer);
var
ox : integer;
oy : integer;
ost : string;
begin
read(pasfile,cd);
read(pasfile,ox);
read(pasfile,cd);
read(pasfile,oy);
read(pasfile,cd);
ost:='';
while not eoln(pasfile) do
begin
read(pasfile,cd);
ost:=ost + cd;
end;
ox:=ox + beginx;
oy:=oy + beginy;
outtextxy(ox,oy,(ost));
end;
{..........................................................................}
begin
assign(pasfile,dosname);
reset(pasfile);
readln(pasfile,lineoftext);
if(lineoftext='FORMAT=CODE')then
begin
while not eof(pasfile) do
begin
read(pasfile,cd);
case cd of
'B':barcode(beginx,beginy);
'E':ellipsecode(beginx,beginy);
'F':begin
read(pasfile,cd);
case cd of
' ':floodfillcode(beginx,beginy);
'E':fillellipsecode(beginx,beginy);
end;
end;
'L':linecode(beginx,beginy);
'P':putpixelcode(beginx,beginy);
'R':rectanglecode(beginx,beginy);
'S':begin
read(pasfile,cd);
case cd of
' ':setcolorcode;
'F':setfillstylecode;
'L':setlinestylecode;
'T':settextstylecode;
end;
end;
'O':outtextcode(beginx,beginy);
end;
readln(pasfile);
end;
end;
close(pasfile);
end;
{---------------------------------------------------------------------------}
procedure GFILESLOC(var gdriver,gmode:integer;gpath:string);
var
error : integer;
begin
clrscr;
repeat
gdriver:=detect;
initgraph(gdriver,gmode,gpath);
error:=graphresult;
if(error<>grOK)then
begin
writeln('Graphics error: ',grapherrormsg(error));
if(error=grfilenotfound)then
begin
writeln;
writeln(' Cannot find graphics driver.');
write(' Please enter directory path for the driver: ');
readln(gpath);
writeln;
end
else
halt(1);
end;
until(error=grOK);
end;
{---------------------------------------------------------------------------}
begin
write('filename: ');
readln(dosname);
gfilesloc(device,mode,'c:\tp\bgi');
setcolor(magenta);
DRAWPICTUREBYCODE(0,0,dosname);
ch:=readkey;
end.