home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
189.img
/
TCS120S.ZIP
/
TCSGRAPH.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-03-02
|
4KB
|
183 lines
{$R-,S-,I-,D-,F+,V-,B-,N-,L+,O+ }
{$M 65500,0,0 }
unit tcsgraph;
interface
uses crt,dos,graph,
gentypes,configrt,modem,statret,gensubs,subs1,windows,subs2,textret,
mailret,userret,flags,mainr1,ansiedit,lineedit,chatstuf,
mainr2,overret1;
procedure initialize;
function randcolor:word;
procedure drawborder;
procedure fullport;
procedure mainwindow (header:string);
procedure exitproggraphics;
procedure tcsgraphic1;
procedure tcsgraphic2;
implementation
const
{ The five fonts available }
fonts:array[0..4] of string[13] =
('DefaultFont', 'TriplexFont', 'SmallFont', 'SansSerifFont', 'GothicFont');
{ The five predefined line styles supported }
linestyles:array[0..4] of string[9] =
('SolidLn', 'DottedLn', 'CenterLn', 'DashedLn', 'UserBitLn');
{ The twelve predefined fill styles supported }
fillstyles:array[0..11] of string[14] =
('EmptyFill', 'SolidFill', 'LineFill', 'LtSlashFill', 'SlashFill',
'BkSlashFill', 'LtBkSlashFill', 'HatchFill', 'XHatchFill',
'InterleaveFill', 'WideDotFill', 'CloseDotFill');
{ The two text directions available }
textdirect:array[0..1] of string[8] = ('HorizDir', 'VertDir');
{ The Horizontal text justifications available }
horizjust:array[0..2] of string[10] = ('LeftText', 'CenterText', 'RightText');
{ The vertical text justifications available }
vertjust:array[0..2] of string[10] = ('BottomText', 'CenterText', 'TopText');
var
graphdriver,graphmode,errorcode:integer;
maxx,maxy,maxcolor:word;
oldexitproc,pregraphexitproc:pointer;
procedure myexitproc;
begin
exitproc:=oldexitproc;
closegraph;
end;
{
procedure mygetmem (var p:pointer; size:word);
begin
getmem (p,size);
end;
procedure myfreemem (var p:pointer; size:word);
begin
if p <> nil then begin
freemem (p,size);
p:=nil;
end;
end;
procedure domemstuff;
begin
pregraphexitproc:=exitproc;
exitproc:=@myexitproc;
graphgetmemptr:=@mygetmem;
graphfreememptr:=@myfreemem;
end;
}
procedure initialize;
var
ingraphicsmode:boolean;
pathtodriver:string;
begin
directvideo:=false;
oldexitproc:=exitproc;
exitproc:=@myexitproc;
pathtodriver:=forumdir;
{ domemstuff; }
repeat
graphdriver:=detect;
initgraph (graphdriver,graphmode,pathtodriver);
errorcode:=graphresult;
if errorcode <> grok then
begin
writeln ('Graphics Error: ',grapherrormsg (errorcode));
if errorcode=grfilenotfound then
begin
writeln ('Enter full path to BGI driver or type <Ctrl-Break> to Quit.');
write ('─> ');
readln (pathtodriver);
writeln;
end
else
Halt(1);
end;
until ErrorCode = grok;
randomize;
maxcolor:=getmaxcolor;
maxx := getmaxx;
maxy := getmaxy;
end;
function randcolor:word;
{ Returns a Random non-zero color value that is within the legal
color range for the selected device driver and graphics mode.
MaxColor is set to GetMaxColor by Initialize }
begin
randcolor:=random(maxcolor)+1;
end;
procedure drawborder;
{ Draw a border around the current view port }
var
ViewPort : ViewPortType;
begin
setcolor (maxcolor);
setlinestyle (solidln,0,normwidth);
getviewsettings (viewport);
with viewport do
rectangle (0,0,x2-x1,y2-y1);
end;
procedure fullport;
begin
setviewport (0,0,maxx,maxy,clipon);
end;
procedure mainwindow (header:string);
begin
setcolor (maxcolor);
graph.cleardevice;
settextstyle (defaultfont,horizdir,1);
settextjustify (centertext,toptext);
fullport;
OutTextXY(MaxX div 2,2,header);
{ Draw main window }
SetViewPort (0, TextHeight('M')+4, MaxX, MaxY-(TextHeight('M')+4), ClipOn);
DrawBorder;
{ Move the edges in 1 pixel on all sides so border isn't in the view port }
SetViewPort(1, TextHeight('M')+5, MaxX-1, MaxY-(TextHeight('M')+5), ClipOn)
end;
procedure exitproggraphics;
var i,x,y:integer;
pausetime:word;
klux:char;
begin
clrscr;
initialize;
for i:=1 to 1000 do begin
{ klux:=readkey; }
if keypressed then exit;
putpixel (random(maxx),random(maxy),randcolor);
end;
x:=maxx div 2;
y:=maxy div 2;
pausetime:=70;
end;
procedure tcsgraphic1;
begin
end;
procedure tcsgraphic2;
begin
end;
begin
end.