The PLOTTER.I include file resides on the Kyan Pascal 2.x Advanced Graphics Toolkit Disk.
- PROCEDURE clip(xf,yf,xt,yt: Real);
- PROCEDURE set_plotter_port(hl,hm,vl,vm: Real);
- PROCEDURE set_plotter_window(xl,xh,yl,yh: Real);
- PROCEDURE init_plotter;
- PROCEDURE frame;
- PROCEDURE advance;
- PROCEDURE plotter_color(c:integer);
Source Code
PROCEDURE clip(xf,yf,xt,yt: Real);
VAR
r1,r2,l1,l2,b1,b2,t1,t2: Boolean;
PROCEDURE reclip(VAR x3,y3,x4,y4: Real; l,r,b,t: Boolean);
BEGIN
IF l OR r OR b OR t THEN BEGIN
IF l THEN BEGIN
y3:=y3+(y4-y3)*
(hlow-x3)/(x4-x3);
x3:=hlow;
END;(*IF*)
IF r THEN BEGIN
y3:=y3+(y4-y3)*(hmax-
x3)/(x4-x3);
x3:=hmax;
END;(*IF r*)
IF (y3<vlow) OR (y3>vmax) THEN BEGIN
IF b THEN BEGIN
x3:=x3+(x4-x3)*
(vmax-y3)/(y4-y3);
y3:=vmax;
END;(*IF b*)
IF t THEN BEGIN
x3:=x3+(x4-x3)*
(vlow-y3)/(y4-y3);
y3:=vlow;
END;(*IF t*)
END;(*IF y bounded*)
END;(*off screen*)
END;
PROCEDURE test;
BEGIN
l1:=(xf<hlow);
r1:=(xf>hmax);
b1:=(yf>vmax);
t1:=(yf<vlow);
l2:=(xt<hlow);
r2:=(xt>hmax);
b2:=(yt>vmax);
t2:=(yt<vlow);
END;(*test*)
BEGIN
test;
IF NOT ((l1 and l2) OR
(r1 and r2) OR
(t1 and t2) OR
(b1 and b2)) THEN BEGIN
reclip(xf,yf,xt,yt,l1,r1,b1,t1);
reclip(xt,yt,xf,yf,l2,r2,b2,t2);
test;
IF NOT (l1 OR r2 OR t1 OR
b1 OR l2 OR r2 OR
t2 OR b2) THEN
writeln(toplotter,'*M',
trunc(xf),',',
trunc(yf),'*D',
trunc(xt),',',
trunc(yt));
END;(*IF bounded*)
END;(*clip*)
PROCEDURE set_plotter_port(hl,hm,vl,vm: Real);
BEGIN
hlow:=hl;
hmax:=hm;
vlow:=vl;
vmax:=vm;
END;
PROCEDURE set_plotter_window(xl,xh,yl,yh: Real);
BEGIN
psx:=(hmax-hlow)/(xh-xl);
psy:=(vmax-vlow)/(yh-yl);
pyl:=yl;
pxl:=xl;
END;
PROCEDURE init_plotter;
BEGIN
rewrite(toplotter,'P:');
writeln(toplotter,chr(27),chr(7));
writeln(toplotter,'M0,0*I');
END;
PROCEDURE frame;
BEGIN
writeln(toplotter,'*M',
trunc(hlow),',',
trunc(vmax),'*D',
trunc(hmax),',',
trunc(vmax),'*D',
trunc(hmax),',',
trunc(vlow),'*D',
trunc(hlow),',',
trunc(vlow),'*D',
trunc(hlow),',',
trunc(vmax));
END;
PROCEDURE advance;
BEGIN
writeln(toplotter,'*M0,',
-trunc(vmax-vlow+5),'*I');
END;
PROCEDURE plotter_color(c:integer);
BEGIN
writeln(toplotter,'*C',c);
END;
No comments:
Post a Comment