home *** CD-ROM | disk | FTP | other *** search
- { ********************************************************************** }
- { }
- { TURBO Pascal Library of Kaypro Screen Graphics Routines - adapted }
- { from the SBASIC originals by : John Lucas 27 Sept. 1984 }
- { }
- { ********************************************************************** }
-
- procedure seton (att : integer);
- begin
- write(chr(27),'B',chr(att))
- end;
-
- procedure setoff (att : integer);
- begin
- write(chr(27),'C',chr(att))
- end;
-
- procedure pixon (vert,horz : integer);
- begin
- write(chr(27),'*',chr((vert + 31)),chr((horz + 31)))
- end;
-
- procedure pixoff (vert,horz : integer);
- begin
- write(chr(27),' ',chr(vert + 31),chr(horz + 31))
- end;
-
- procedure lineon (v1,h1,v2,h2 : integer);
- begin
- write(chr(27),'L',chr(v1 + 31),chr(h1 + 31),chr(v2 + 31),chr(h2 + 31))
- end;
-
- procedure lineoff (v1,h1,v2,h2 : integer);
- begin
- write(chr(27),'D',chr(v1 + 31),chr(h1 + 31),chr(v2 +31),chr(h2 + 31))
- end;
-
- function sroot (n : integer): integer;
- var
- root1,root2 : integer;
- begin
- root1 := n; root2 := 1;
- while (root1 > root2) do
- begin
- root1 := trunc((root1 + root2)/2);
- root2 := trunc(n/root1)
- end;
- sroot := root1
- end;
-
- procedure circle (horz,vert,radius : integer);
- var
- x,y,offset : integer;
- begin
- offset := trunc((radius * 100)/141);
- pixon((horz + radius - 1),vert);
- pixon((horz - radius + 1),vert);
-
- for x := 1 to offset do
- begin
- y := sroot(sqr(radius) - sqr(x));
- pixon((horz + y),(vert + x));
- pixon((horz + y),(vert - x));
- pixon((horz - y),(vert + x));
- pixon((horz - y),(vert - x));
- end;
-
- pixon(horz,(vert + radius - 1));
- pixon(horz,(vert - radius + 1));
-
- for y := 1 to offset do
- begin
- x := sroot(sqr(radius) - sqr(y));
- pixon((horz + y),(vert + x));
- pixon((horz + y),(vert - x));
- pixon((horz - y),(vert + x));
- pixon((horz - y),(vert - x));
- end;
- end;
-
- procedure rectangle (y,x,ht,wd : integer);
- begin
- lineon(y,x,(y + ht),x);
- lineon(y,(x + wd),(y + ht),(x + wd));
- lineon(y,x,y,(x + wd));
- lineon((y + ht),x,(y + ht),(x + wd));
- end;
-
- procedure square (y,x,side : integer);
- begin
- rectangle(y,x,side,side)
- end;
-
- procedure bar (refy,refx,ht,wd,depth,inside,vertp,horzp : integer);
- var
- i,temp,empty,full,x,y : integer;
- ref,center,rear : array[1..2] of integer;
- begin
- x := 1; y := 2; full := 1; empty := 0;
- ref[x] := refx; ref[y] := refy;
- center[x] := refx + (wd * horzp);
- center[y] := refy + (ht * vertp);
- rear[x] := center[x] + (depth * horzp);
- rear[y] := center[y] + (depth * vertp);
-
- if (inside = empty) then
- begin
- for i := ref[x] to center[x] do
- if (i mod horzp) = 0 then
- lineoff(ref[y],i,center[y],i);
-
- for i := 0 to (wd * horzp) do
- if (i mod horzp) = 0 then
- lineoff(center[y],(center[x] - i),rear[y],(rear[x] - i));
-
- for i := 0 to (ht * vertp) do
- if (i mod vertp) = 0 then
- lineoff((center[y] - i),center[x],(rear[y] - i),rear[x]);
-
- lineon(ref[y],ref[x],center[y],ref[x]);
- lineon(ref[y],ref[x],ref[y],center[x]);
- lineon(center[y],center[x],center[y],ref[x]);
- lineon(center[y],center[x],ref[y],center[x]);
-
- lineon(center[y],center[x],rear[y],rear[x]);
-
- lineon(ref[y],center[x],(rear[y] - ht * vertp),rear[x]);
- lineon(center[y],ref[x],rear[y],(rear[x] - wd * horzp));
-
- lineon(rear[y],rear[x],(rear[y] - ht * vertp),rear[x]);
- lineon(rear[y],rear[x],rear[y],(rear[x] - wd * horzp))
- end;
-
- if (inside = full) then
- begin
- for i := ref[x] to center[x] do
- if (i mod horzp) = 0 then
- lineon(ref[y],i,center[y],i);
-
- for i := 0 to (wd * horzp) do
- if (i mod horzp) = 0 then
- lineon(center[y],(center[x] - i),rear[y],(rear[x] - i));
-
- for i := 0 to (ht * vertp) do
- if (i mod vertp) = 0 then
- lineon((center[y] - i),center[x],(rear[y] - i),rear[x]);
-
- lineoff(center[y],center[x],center[y],ref[x]);
- lineoff(center[y],center[x],ref[y],center[x]);
-
- lineoff(center[y],center[x],rear[y],rear[x]);
-
- end;
- end;