148521Sbostic /*- 248521Sbostic * Copyright (c) 1983 The Regents of the University of California. 348521Sbostic * All rights reserved. 448521Sbostic * 548521Sbostic * %sccs.include.proprietary.c% 648521Sbostic */ 748521Sbostic 813316Ssam #ifndef lint 9*57885Storek static char sccsid[] = "@(#)line.c 4.3 (Berkeley) 02/10/93"; 1048521Sbostic #endif /* not lint */ 1113316Ssam 1213316Ssam #include "con.h" 1313316Ssam line(x0,y0,x1,y1){ 1413316Ssam iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1))); 1513316Ssam return; 1613316Ssam } 1713316Ssam cont(x0,y0){ 1813316Ssam iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0))); 1913316Ssam return; 2013316Ssam } 2113316Ssam iline(cx0,cy0,cx1,cy1){ 2213316Ssam int maxp,tt,j,np; 2313316Ssam char chx,chy; 2413316Ssam float xd,yd; 25*57885Storek double dist2(),sqrt(); 2613316Ssam movep(cx0,cy0); 2713316Ssam maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.; 2813316Ssam xd = cx1-cx0; 2913316Ssam yd = cy1-cy0; 3013316Ssam if(xd >= 0)chx = RIGHT; 3113316Ssam else chx = LEFT; 3213316Ssam if(yd >= 0)chy = UP; 3313316Ssam else chy = DOWN; 3413316Ssam if(maxp==0){ 3513316Ssam xd=0; 3613316Ssam yd=0; 3713316Ssam } 3813316Ssam else{ 3913316Ssam xd /= maxp; 4013316Ssam yd /= maxp; 4113316Ssam } 4213316Ssam inplot(); 4313316Ssam for (tt=0; tt<=maxp; tt++){ 4413316Ssam j= cx0+xd*tt-xnow; 4513316Ssam xnow += j; 4613316Ssam j = abval(j); 4713316Ssam while(j-- > 0)spew(chx); 4813316Ssam j = cy0+yd*tt-ynow; 4913316Ssam ynow += j; 5013316Ssam j = abval(j); 5113316Ssam while(j-- > 0)spew(chy); 5213316Ssam spew ('.'); 5313316Ssam } 5413316Ssam outplot(); 5513316Ssam return; 5613316Ssam } 57