home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
pgraph2.zip
/
DEMOPG.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-11-19
|
14KB
|
468 lines
program gdat;
uses Os2Base;
{&cdecl+}
{$IFDEF DYNAMIC_VERSION}
{$Dynamic System}
{$L VPRTL.LIB}
{$ENDIF}
label 0,1,2,3,4,5,6;
{$I E:\VP11\PGRAPH2.INC}
var c,b: byte;
x,y,xx,yy: integer;
txt: string[35];
i: word;
j,k,l,m:longint;
d: double;
p: array[1..8] of pointtype;
po: pointer;
dx,dy:byte;
cx,cy:integer;
ch:char;
procedure RGB(s:s127);
const p:array[0..15] of byte = (0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63);
var i,j,k,n:integer; b1,b2,b3:byte; sb:text;
begin
assign(sb,getgfdir+s); reset(sb);
if ioresult>0 then begin
restorecrtmode; writeln('File '+getgfdir+s+' was not found!'); halt end;
readln(sb,b1,b2,b3);
for n:=0 to 15 do begin
readln(sb,i,j,k); setrgbpalette(p[n],i,j,k) end;
close(sb)
end;
procedure PE;
begin gotoxyg(65,18); writeg('... press Enter'); gotoxyg(1,1) end;
procedure SWY(b:byte);
begin fbc(15,b); gotoxyg(73,1); writeg(' SW Yes'); gotoxyg(1,1) end;
procedure SWN(b:byte);
begin fbc(15,b); gotoxyg(73,1); writeg(' SW No '); gotoxyg(1,1) end;
begin
case GraphInit(paramstr(1)) of
1: begin write('Wrong path to the font files'); halt end;
2: begin write('Cannot access video screen selector'); halt end;
3: begin write('VGA display required'); halt end
end;
ch:=klic;
GrafFont(24);
setrst(170);
fbc(1,8); fillrectangle(20,78,400,348);
setliwi(3);
setcolor(6); rectangle(20,78,400,348);
fbc(15,1);
gotoxyg(11, 6); writeg('Demonstration of PGRAPH functions');
gotoxyg( 7, 8); writeg('Any improvements, advices and suggestions');
gotoxyg(11, 9); writeg('are invited in the e-mail address:');
gotoxyg(17,11); writeg('geogas@gggn.anet.cz');
fbc(15,0);
graffont(14);
gotoxyg(1,25);
writegn('"SW Yes" in the upper right corner of the screen indicates,');
writegn('you may press task switching keys'); writegn('');
writegn('"SW No" in the upper right corner of the screen indicates,');
writegn('you may not press task switching keys');
graffont(24);
pe; swy(2);
ch:=klic;
0: fbc(15,0); pe; swn(4); fbc(15,0);
writegn('Putpixel demonstration');
writegn('^^^^^^^^^^^^^^^^^^^^^^');
randomize;
repeat
c:=random(15);
x:=random(420);
y:=random(310);
putpixel(x,y+58,c)
until keypressed;
ch:=readkey;
cleardevice; pe; swy(2); fbc(15,0);
writegn('Demonstration of font sizes');
writegn('^^^^^^^^^^^^^^^^^^^^^^^^^^^'); writegn('');
graffont(14); writegn('Font - size 14');
graffont(16); writegn('Font - size 16');
graffont(24); writegn('Font - size 24');
writegn(''); writegn('');
writegn('Demonstration of text and number editing');
writegn('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^');
writegn('Edit the following text and press Enter');
setcolor(14); backcolor(1);
txt:='Test of edited text';
editg(10,46,13,txt);
setcolor(15); backcolor(0);
gotoxyg(1,18); writeg('Enter new number:');
d:=3.1415927; setcolor(14); backcolor(1);
num(20,18,d,'d',11,7);
fbc(15,0); cleardevice; pe; swy(2); fbc(15,0);
writegn('Demonstration of various text outputs');
writegn('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^');
writegn(''); backcolor(1);
writegn('Superfast text output using LineMode_on procedure');
writegn('');
gotoxyg(getwhx+7,getwhy);
setcolor(11); backcolor(8);
writegn('Slow text output using PutPixel porcedure');
graffont(16);
setcolor(0); backcolor(10);
cestextc(10,465,'Slow text output can have two directions',false);
ch:=klic;
fbc(15,0); cleardevice; graffont(24);
pe; swy(2); fbc(15,0);
writegn('Demonstration of line font');
writegn('^^^^^^^^^^^^^^^^^^^^^^^^^^');
setliwi(1); setcolor(11); linefont(0);
cesltext(10,70,'Test of CesLText procedure',2,true);
setliwi(1); setcolor(14); linefont(1);
cesltext(10,110,'in different size,',1,true);
setcolor(13);
cesltext(10,190,'different colors,',3,true);
setliwi(3); setcolor(15);
cesltext(10,250,'different thickness',3,true);
setliwi(3); setcolor(12);
cesltext(400,450,'and different direction',3,false);
ch:=klic;
cleardevice; setliwi(2); setcolor(11); setrst(170);
vline(15,5,400);
hline(15,541,5);
setliwi(1); setcolor(15); ellipse(320,240,317,237);
setcolor(1); fillellipse(300,200,50,50);
setliwi(2); setcolor(14); ellipse(300,200,50,50);
setdot(true); setcolor(10);
setliwi(1); rectangle(400,180,468,104);
setliwi(2); rectangle(410,200,478,114);
setliwi(3); rectangle(420,220,488,124);
setliwi(1); setdot(false);
fillellipse(520,340,19,25);
setcolor(14); ellipse(520,340,19,25);
setcolor(11); fillrectangle(470,276,340,245);
setcolor(12); setliwi(2); rectangle(470,276,340,245);
setcolor(15);
gotoxyg(19,3); writeg('Demonstration of line width, ellipse drawing,');
gotoxyg(19,4); writeg('XORput and fill capabilities');
setcolor(14);
setliwi(1);
moveto(35,50);
lineto(55,45);
lineto(115,135);
lineto(120,186);
lineto(185,190);
lineto( 5,350);
setliwi(2);
moveto(40,40);
lineto(60,35);
lineto(120,125);
lineto(125,176);
lineto(190,180);
lineto(10,340);
setliwi(3);
moveto(45,30);
lineto(65,25);
lineto(125,115);
lineto(130,166);
lineto(195,170);
lineto(15,330);
fbc(15,0); swy(2); fbc(15,0);
setcolor(11); fillrectangle(79,367,462,297);
setcolor(12); setliwi(2); rectangle(79,367,462,297);
graffont(16); setcolor(0); backcolor(11);
gotoxyg(12,18); writeg(' Use arrow keys to move cross, ');
gotoxyg(12,19); writeg(' 1,2,3 or 4 to change speed of cross movement ');
gotoxyg(12,20); writeg(' or press Enter to contnue ');
gotoxyg(45,15); writeg('X='); gotoxyg(53,15); writeg('Y=');
MoveCross(#0,true);
1:
cx:=getcrx; cy:=getcry;
gotoxyg(47,15); writenum(cx,'i',3,0);
gotoxyg(55,15); writenum(cy,'i',3,0);
ch:=klic;
if not (ch in [#27,#13]) then begin MoveCross(ch,getfkl); goto 1 end;
setliwi(1); graffont(24);
fbc(15,0); cleardevice; ch:='t';
2: i:=0; setcolor(15); graffont(24);
swn(4); fbc(15,0); writegn('Figure drawing demonstration');
writeg('Use "e","r" or "t" key to change figure, or press Enter to continue');
graffont(14);
repeat
c:=random(15); x:=random(63); y:=random(63);
inc(i); setcolor(15); gotoxyg(70,3); writenum(i,'w',5,0); setcolor(c);
case ch of
'e': ellipse(80+x*7+c*5,100+c*10+y*5,x*3,y*2);
'r': rectangle(100+c*13+x*7,100+x*2+y*6,100+y*4+x,100+c*7+y);
't': triangle(60+x*7,70+c*13,200+y*3,400+c*5,100+y*9,150+x*3);
end;
until keypressed;
ch:=klic; pixelmode_off;
if ch=#13 then begin
graffont(24); swy(2);
setcolor(15); gotoxyg(70,3); writenum(i,'w',5,0);
ch:=klic end;
if ch in['r','e','t','p'] then begin
fbc(15,0); cleardevice; goto 2 end;
rgb('DIAMO.PAL'); fbc(15,0); cleardevice; graffont(24);
writegn('The following demonstration will use this palette');
writeg('Press Enter to continue'); swy(5);
setrst($AA55);
{setrst($FFFF);}
for i:=0 to 15 do begin
backcolor(i);
for j:=0 to 15 do begin
setcolor(j);
fillrectangle(i*40,80+j*25,(i+1)*40,80+(j+1)*25) end end;
setcolor(0);
for i:=0 to 15 do
for j:=0 to 15 do
rectangle(i*40,80+j*25,(i+1)*40,80+(j+1)*25);
ch:=klic;
fbc(15,0); cleardevice; ch:='e';
3: i:=0; setcolor(15); graffont(24);
swn(14); fbc(15,0); writegn('Figure filling demonstration');
writeg('Use "e","r" or "t" key to change figure, or press Enter to exit');
graffont(14);
repeat
c:=random(15); x:=random(63); y:=random(63);
inc(i); setcolor(15); gotoxyg(70,3); writenum(i,'w',5,0);
setcolor(c); backcolor(y div 4);
case ch of
'e': fillellipse(80+x*7+c*5,100+c*10+y*5,x*3,y*2);
'r': fillrectangle(100+c*13+x*7,100+x*2+y*6,100+y*4+x,100+c*7+y);
't': filltriangle(60+x*7,70+c*13,200+y*5,400+c*5,100+y*9,150+x*3);
'p': begin p[1].x:=100-c*5+x*4; p[1].y:=200+c*13-y*2;
p[2].x:=200+x*3; p[2].y:=400+x*3-y*2;
p[3].x:=450-y*4+x*2; p[3].y:=450-y*3+c*5;
p[4].x:=550+x*2-y*3; p[4].y:=100+c*11+x*2;
p[5].x:=p[1].x; p[5].y:=p[1].y;
fillpolygon(5,p) end;
end;
until keypressed;
ch:=klic;
if ch=#13 then begin graffont(24); swy(5); ch:=klic end;
if ch in['e','r','t','p'] then begin
backcolor(0); cleardevice; goto 3 end;
fbc(15,0); cleardevice; ch:='e';
4: i:=0; setcolor(15); graffont(24);
swn(14); fbc(15,0); writegn('Figure drawing and filling demonstration');
writeg('Use "e","r" or "t" key to change figure, or press Enter to continue');
graffont(14);
repeat
c:=random(15);
x:=random(63);
y:=random(63);
inc(i); setcolor(15); gotoxyg(70,3); writenum(i,'w',5,0);
case ch of
'e': begin
setcolor(c); backcolor(y div 4);
fillellipse(80+x*7+c*5,100+c*10+y*5,x*3,y*2);
setcolor(0);
ellipse(80+x*7+c*5,100+c*10+y*5,x*3,y*2) end;
'r': begin
setcolor(c); backcolor(y div 4);
fillrectangle(100+c*13+x*7,100+x*2+y*6,100+y*4+x,100+c*7+y);
setcolor(0);
rectangle(100+c*13+x*7,100+x*2+y*6,100+y*4+x,100+c*7+y) end;
't': begin
setcolor(c); backcolor(x div 4);
filltriangle(60+x*7,70+c*13,200+y*5,400+c*5,100+y*9,150+x*3);
setcolor(0);
triangle(60+x*7,70+c*13,200+y*5,400+c*5,100+y*9,150+x*3) end;
'p': begin
setcolor(c); backcolor(x div 4);
p[1].x:=60+x*7; p[1].y:=70+c*13;
p[2].x:=200+y*5; p[2].y:=400+c*5;
p[3].x:=100+y*9; p[3].y:=150+x*3;
p[4].x:=p[1].x; p[4].y:=p[1].y;
fillpolygon(4,p);
setcolor(0); triangle(p[1].x,p[1].y,p[2].x,p[2].y,p[3].x,p[3].y) end;
end;
until keypressed;
ch:=klic;
if ch=#13 then begin graffont(24); swy(5); ch:=klic end;
if ch in['e','r','t','p'] then begin
backcolor(0); cleardevice; goto 4 end;
graffont(24); fbc(15,0); cleardevice; pe; swy(5); fbc(15,0);
writegn('Comparison of drawing (filling) speed with');
writegn('Turbo Pascal 6.0 (DOS real mode) and');
writegn('Borland Pascal 7.0 (DOS protected mode)');
writegn('^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^');
graffont(16); fbc(7,0);
writegn('');
writegn('');
writegn(' ┌───────────────┬────────┬────────┬────────┐');
writegn(' │ Drawing │ PGRAPH │ TP6 │ BP7 │');
writegn(' ├───────────────┼────────┼────────┼────────┤');
writegn(' │Ellipses/sec │ 535 │ ! 355 │ ! 220 │');
writegn(' │Rectangles/sec │ 1060 │ ! 960 │ ! 370 │');
writegn(' │Triangles/sec │ 835 │ ! 735 │ ! 330 │');
writegn(' └───────────────┴────────┴────────┴────────┘');
writegn(' ┌───────────────┬────────┬────────┬────────┐');
writegn(' │Filling+drawing│ PGRAPH │ TP6 │ BP7 │');
writegn(' ├───────────────┼────────┼────────┼────────┤');
writegn(' │Ellipses/sec │ 325 │ ! 140 │ ! 120 │');
writegn(' │Bars/sec * │ 535 │ ! 465 │ ! 260 │');
writegn(' │Triangles/sec │ 260 │ ! 130 │ ! 110 │');
writegn(' └───────────────┴────────┴────────┴────────┘');
writegn('');
writegn('Notes: ! ... PGRAPH is faster');
writegn(' * ... only filling');
writegn(''); fbc(15,0);
writegn(' Test was performed with CPU 486-DX4, 100 MHz');
writegn(' and graphics adapter CL-GD6440, 1MB VideoRAM');
ch:=klic; graffont(16);
6:
setrgbpalette(1,0,5,10);
backcolor(1); cleardevice; setrst($FFFF);
randomize;
xx:=random(200); yy:=random(420);
for i:=1 to 3 do begin
c:=random(5)+3; b:=random(3)+6;
for j:=1 to 7 do begin
x:=xx+random(55*b); y:=yy+random(19*c);
l:=random(33)+4; k:=random(29)+5;
for m:=1 to 44*(random(17)+2) do begin
putpixel(x+round(random(l*3)*cos(m/13)),
y+round(random(k)*sin(m/13+7*b)),13-i);
x:=x+random((m div (33*c*b))*round(cos(m/17+c))) div 2 ;
y:=y-round(sin(random(m))) end end end;
for i:=1 to 144 do begin
x:=random(639); y:=random(479); l:=random(19); c:=random(7)+6;
for m:=1 to l*l do
putpixel(x+(m div {43}(4*c))*round(random(m)/27*cos(m)),
y+(m div {43}(4*c))*round(random(m)/27*sin(m)),c) end;
for i:=1 to 2 do begin
c:=random(5)+3; b:=random(4)+7;
dx:=random(4)+6;
case i of 1: d:=(60-25*b)/180; 2: d:=(-60+25*c)/180 end;
l:=random(17)+9; k:=random(6)+5;
x:=random(500)+50; y:=random(230)+(i-1)*230;
for m:=1 to 222 do
putpixel(x+round(random(k+6)*cos(m/23)),y+round(random(k+6)*sin(m/23)),b);
for j:=1 to 44*dx do begin
x:=x+round(j/(k)*cos(j/33)); y:=y+round(j/(l)*sin(j/33+d));
putpixel(x+random(j div 37),y+random(j div 37),b);
x:=x-round(j/(k)*cos(j/33)); y:=y-round(j/(l)*sin(j/33+d));
putpixel(x+random(j div 37),y+random(j div 37),b) end;
for j:=1 to 44*dx do begin
x:=x+round(j/(k)*cos(j/33+pi)); y:=y+round(j/(l)*sin(j/33+d+pi));
putpixel(x+random(j div 37),y+random(j div 37),b);
x:=x-round(j/(k)*cos(j/33+pi)); y:=y-round(j/(l)*sin(j/33+d+pi));
putpixel(x+random(j div 37),y+random(j div 37),b) end end;
setcolor(15); swn(14); fbc(12,0);
writegn('PutArea - GetArea demo (0...9 - change speed, r - redraw, Enter - exit)');
l:=areasize(0,0,80,60); getmem(po,l); setcolor(15); setliwi(3);
x:=320; y:=240; getarea(x-40,y-30,x+40,y+30,po^);
j:=0; k:=random(133); c:=20;
repeat
putarea(x-40,y-30,po^); inc(j);
x:=x+round(j/7*cos(j/10)); y:=y+round(j/10*sin(j/13));
if j>k then begin k:=random(181); j:=0 end;
if x<40 then x:=40; if x>599 then x:=599;
if y<30 then y:=30; if y>449 then y:=449;
dx:=39-round(39*j/182); dy:=27-round(27*j/182);
getarea(x-40,y-30,x+40,y+30,po^);
filltriangle(x,y,x,y-dy,x-dx,y);
filltriangle(x,y,x,y+dy,x+dx,y);
line(x,y+dy,x-dx,y);
line(x+dx,y,x,y-dy);
for m:=1 to 24000*c do ;
if keypressed then begin
ch:=klic;
if ch in ['0'..'9'] then c:=(ord(ch)-48); c:=c*c;
if ch in [#13,#27] then goto 5 end;
if ch in ['r','z'] then begin ch:='4'; goto 6 end;
until keypressed;
5: freemem(po,l);
restorecrtmode;
end.