home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
beehive
/
utilitys
/
pudd.arc
/
PUDD-02.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-08-11
|
12KB
|
471 lines
procedure HeadLine;
begin
ClrScr;
GoToXY(2,1);
write('Line Style is ');
write(vLineStyle);
write(', color is ');
write(vLineColor);
GoToXY(2,2);
write('Fill Style is ');
write(vFillStyle);
write(', mode is ');
write(vWriteMode);
write(' with and index of ');
writeln(vFillIndex);
GoToXY(2,3);
write('Current curser position is X = ');
write(Xpoz);
write(', Y = ');
write(Ypoz);
write(' Speed is ');
write(speed);
GoToXY(2,4);
write('Current screen position is X = ');
write(x1);
write(', Y = ');
write(y1);
write(' Curser is ');
case Size of
5: write('regular');
0: write('off');
63: write('big');
end; {....case }
GoToXY(2,5);
write('Please select......');
GoToXY(1,7);
writeln(' FROM HERE IN GRAPHICS');
writeln(' (H)elp (R)eturn to main menu c(U)rves ');
writeln(' (G)raphic screen (D)raw w/ update point ');
writeln(' (F)iles (L)ine w/o update ');
writeln(' (C)hange status (P)oint set ');
writeln(' (P)rint screen e(X)tensive drawing ');
writeln(' (Q)uit (F)ill an area ');
writeln(' (W)rite (E)rase an area ');
writeln(' (B)lock create/fill ');
writeln(' (R)eturn to main menu ');
writeln(' (S)peed set ');
writeln(' also 5 sets speed ');
writeln(' (W)ipe screen ');
writeln(' (A)rrow ');
writeln(' (T)ext ');
writeln(' (C)hange defaults ');
end;
procedure SetSpeed(var speed:integer);
var response :char;
junk :integer;
begin
alphamode;
clrscr;
gotoXY(10,10);
write('Please enter the new curser movement speed...');
read(kbd,response);
val(response,speed,junk);
gotoXY(10,24);
ClrEol;
initgraph
end;
procedure eXtensive( size :integer;
var x1,y1 :integer;
var Xpoz,Ypoz :integer);
var direction :char;
begin
PointSet(size,x1,y1,Xpoz,Ypoz);
repeat
read(kbd,direction);
direction := UpCase(direction);
if (direction = '5') or (direction = 'S') then
SetSpeed(speed)
else
begin
MoveCross(size,speed,direction,Xpoz,Ypoz);
DrawNext(size,x1,y1,Xpoz,Ypoz);
end;
until direction = 'X';
end;
procedure ClrSomeScr(Here,there:integer);
var i: integer;
begin
for i := here to there do
begin
gotoXY(1,i);
ClrEol;
end;
end;
procedure Set1(var vLineStyle:DefTypes);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Line styles available.......');
gotoXY(15,13);
write('1) Solid');
gotoXY(15,14);
write('2) Dashed');
gotoXY(15,15);
write('3) Dotted');
gotoXY(15,16);
write('4) Dash-Dot');
gotoXY(15,17);
write('5) Long-Dash');
gotoXY(15,18);
write('6) Short-Dash');
gotoXY(15,19);
write('7) Dot-Dot-Dash');
gotoXY(15,20);
write('8) Long-Dot');
gotoXY(41,18);
write('choice ?');
read(kbd,response);
case response of
'1':vLineStyle := 'Solid';
'2':vLineStyle := 'Dashed';
'3':vLineStyle := 'Dotted';
'4':vLineStyle := 'Dash-Dot';
'5':vLineStyle := 'Long-Dash';
'6':vLineStyle := 'Short-Dash';
'7':vLineStyle := 'Dot-Dot-Dash';
'8':vLineStyle := 'Long-Dot';
end; {......case }
end;
procedure Set2(var vLineColor:DefTypes);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Line colors can be.......');
gotoXY(15,13);
write('1) White');
gotoXY(15,14);
write('2) Black');
gotoXY(41,18);
write('choice ?');
read(kbd,response);
case response of
'1':vLineColor := 'White';
'2':vLineColor := 'Black';
end; {......case }
end;
procedure Set3(var vFillStyle:DefTypes);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Fill Styles are.......');
gotoXY(15,13);
write('1) Hollow');
gotoXY(15,14);
write('2) Solid');
gotoXY(15,15);
write('3) Pattern');
gotoXY(15,16);
write('4) Hatched');
gotoXY(41,18);
write('choice ?');
read(kbd,response);
case response of
'1':vFillStyle := 'Hollow';
'2':vFillStyle := 'Solid';
'3':vFillStyle := 'Pattern';
'4':vFillStyle := 'Hatched';
end; {......case }
end;
procedure Set4(var vFillIndex:Integer);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Fill Indices effect style as....... index (pattern) or (hatched)');
gotoXY(15,13);
write('0) Intensity 0 or Vertical ');
gotoXY(15,14);
write('1) Intensity 1 or Horizontal');
gotoXY(15,15);
write('2) Intensity 2 or Diagonal positive');
gotoXY(15,16);
write('3) Intensity 3 or Diagonal negative');
gotoXY(15,17);
write('4) Intensity 4 or Vert/Horz');
gotoXY(15,18);
write('5) Intensity 5 or Vert/Diag +');
gotoXY(15,19);
write('6) Intensity 6 or Vert/Diag -');
gotoXY(15,20);
write('7) Intensity 7 or Diag +/Diag -');
gotoXY(61,18);
write('choice ?');
read(kbd,response);
case response of
'0':vFillIndex := 0;
'1':vFillIndex := 1;
'2':vFillIndex := 2;
'3':vFillIndex := 3;
'4':vFillIndex := 4;
'5':vFillIndex := 5;
'6':vFillIndex := 6;
'7':vFillIndex := 7;
end; {......case }
end;
procedure Set5(var vFillColor:DefTypes);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Fill colors can be.......');
gotoXY(15,13);
write('1) White');
gotoXY(15,14);
write('2) Black');
gotoXY(41,18);
write('choice ?');
read(kbd,response);
case response of
'1':vFillColor := 'White';
'2':vFillColor := 'Black';
end; {......case }
end;
procedure Set6(var vWriteMode:DefTypes);
var response :char;
begin
ClrSomeScr(12,24);
gotoXY(10,12);
write('Write Modes are.......');
gotoXY(15,13);
write('1) Replace');
gotoXY(15,14);
write('2) Fill');
gotoXY(15,15);
write('3) OverWrite');
gotoXY(15,16);
write('4) Reverse');
gotoXY(41,18);
write('choice ?');
read(kbd,response);
case response of
'1':vWriteMode := 'Replace';
'2':vWriteMode := 'Fill';
'3':vWriteMode := 'OverWrite';
'4':vWriteMode := 'Reverse';
end; {......case }
end;
procedure Set7(var size:integer);
var NewSize :integer;
begin
NewSize := size;
ClrSomeScr(12,24);
gotoXY(10,12);
write('You can have .......');
gotoXY(15,13);
write('1) Regular crosshair');
gotoXY(15,14);
write('2) Big crosshair');
gotoXY(15,15);
write('3) No Crosshair');
gotoXY(51,18);
write('choice ?');
read(kbd,response);
case response of
'1':begin
NewSize := 5;
end;
'2':begin
NewSize := 63;
end;
'3':begin
NewSize := 0;
end;
end; {......case }
offXhair(size,xPoz,yPoz);
size := NewSize;
initXhair(size,xpoz,ypoz);
end;
procedure Status; {..... a lot of global var's here }
var response :char;
begin
alphamode;
response := '?';
repeat
ClrScr;
gotoXY(1,1);
write(' Variable Current Value ');
writeln;
write(' 1) LineStyle ');writeln(vLineStyle);
write(' 2) LineColor ');writeln(vLineColor);
write(' 3) FillStyle ');writeln(vFillStyle);
write(' 4) FillIndex ');writeln(vFillIndex);
write(' 5) FillColor ');writeln(vFillColor);
write(' 6) FillMode ');writeln(vWriteMode);
write(' 7) CrossHair ');
case size of
5:writeln('regular');
0:writeln('is turned off');
63:writeln('big');
end; {....case }
writeln;
write('Enter value to change.......');
read(kbd,response);
case response of
'1':Set1(vLineStyle);
'2':Set2(vLineColor);
'3':Set3(vFillStyle);
'4':Set4(vFillIndex);
'5':Set5(vFillColor);
'6':Set6(vWriteMode);
'7':Set7(size);
end; {.....case }
until not(response in ['1','2','3','4','5','6','7']);
SetTypes;
end;
procedure CleanUp;
var response :char;
begin
alphamode;
clrscr;
gotoXY(10,10);
write('Are you sure you want to erase screen ? ');
read(kbd,response);
response := UpCase(response);
if response = 'Y' then
begin
ClearGraph;
InitXhair(size,xpoz,yPoz);
end;
gotoXY(10,24);
ClrEol;
initgraph
end;
{*****************************************************************************}
{* text will put text on the graphic screen. It checks for space above and *}
{* to the right before writing. It also checks to the left before a DEL *}
{*****************************************************************************}
procedure text(var xPoz,yPoz:integer);
var next :char;
begin
charcolor(1);
offXhair(size,xPoz,yPoz);
if (yPoz < 233) and (yPoz > 2) then {.......if there's vertical room }
begin
repeat
read(kbd,next);
if (next = chr(127)) or (next = chr(8)) then { ...if backspace or del }
if xPoz < 8 then {.....too close to left side to backspace}
write(^G)
else {.....do a backspace }
begin
next := ' ';
xPoz := xPoz - 8;
MoveTo(xPoz,yPoz);
CharGraph(next);
end
else
if next <> chr(13) then {......if no CR then..}
if xPoz > 629 then {...if there's no room}
write(^G) {ring the bell }
else {..else write the charactor }
begin
MoveTo(xPoz,yPoz);
charGraph(next); {....write }
xPoz := xPoz + 8;
end;
if xPoz > 629 then {....unless too far to the right}
begin
next := chr(13);
write(^G);
end;
until next = chr(13);
end
else {.......no room for charactor above line or descenders below}
write(^G);
initXhair(size,xPoz,yPoz);
end;
procedure Arrow(size,x1,y1,xPoz,yPoz:integer);
{.....comments: theta is the angle from 0 to 2 pie of the line that
is drawn. Gamma is the interior angle of the arrowhead. Beta is the
difference. To make the arrow longer change the length which is really
the height or centerline of the arrowhead. To make the head fatter change
the loop which sets gamma. Comments below assume Xhair is origin of an
alternate frame of reference. }
const length = 10.0; {.... yields length of arrow }
var theta,gamma,beta :real; {......trig type stuff }
i :integer;
Lx,Ly :integer;
begin
if (xPoz-x1 = 0) then {....vertical line }
if (yPoz > y1) then
theta := 1.5707963 {.......which points up }
else
theta := -1.5707936 {.......which points down }
else
theta := arctan((2*(yPoz-y1))/(xPoz-x1));
if (xPoz < x1) then {....angle is greater than 90 }
begin
begin
theta := 3.1415927 + theta; {...in 2nd or 3rd quardents }
end
end;
if (theta < 0) then
theta := theta + 6.2831853;
DrawNext(size,x1,y1,xPoz,yPoz);
offXhair(size,xPoz,yPoz);
SetLine(1); { draw a white arrow }
for i := 1 to 46 do
begin
gamma := 0.3 - i * 0.015;
beta := theta - gamma;
Lx := round(2*(length * cos(beta)));
Ly := round(length * sin(beta));
if (x1-Lx > -1) and (x1-Lx < 640) and (y1-Ly > -1) and (y1-Ly < 240) then
begin
DrawTo((x1-Lx),(y1-Ly));
MoveTo(x1,y1);
end;
end;
SetTypes; { return previous settings }
initXhair(size,xPoz,yPoz);
end;