148525Sbostic /*- 248525Sbostic * Copyright (c) 1983 The Regents of the University of California. 348525Sbostic * All rights reserved. 448525Sbostic * 548525Sbostic * %sccs.include.proprietary.c% 648525Sbostic */ 748525Sbostic 813368Ssam #ifndef lint 9*57887Storek static char sccsid[] = "@(#)line.c 4.3 (Berkeley) 02/10/93"; 1048525Sbostic #endif /* not lint */ 1113368Ssam 1213368Ssam #include "con.h" 1313368Ssam line(x0,y0,x1,y1){ 1413368Ssam iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1))); 1513368Ssam return; 1613368Ssam } 1713368Ssam cont(x0,y0){ 1813368Ssam iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0))); 1913368Ssam return; 2013368Ssam } 2113368Ssam iline(cx0,cy0,cx1,cy1){ 2213368Ssam int maxp,tt,j,np; 2313368Ssam char chx,chy; 2413368Ssam float xd,yd; 25*57887Storek double dist2(),sqrt(); 2613368Ssam movep(cx0,cy0); 2713368Ssam maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.; 2813368Ssam xd = cx1-cx0; 2913368Ssam yd = cy1-cy0; 3013368Ssam if(xd >= 0)chx = RIGHT; 3113368Ssam else chx = LEFT; 3213368Ssam if(yd >= 0)chy = UP; 3313368Ssam else chy = DOWN; 3413368Ssam if(maxp == 0){ 3513368Ssam xd=0; 3613368Ssam yd=0; 3713368Ssam } 3813368Ssam else{ 3913368Ssam xd /= maxp; 4013368Ssam yd /= maxp; 4113368Ssam } 4213368Ssam inplot(); 4313368Ssam for (tt=0; tt<=maxp; tt++){ 4413368Ssam j= cx0+xd*tt-xnow; 4513368Ssam xnow += j; 4613368Ssam j = abval(j); 4713368Ssam while(j-- > 0)spew(chx); 4813368Ssam j = cy0+yd*tt-ynow; 4913368Ssam ynow += j; 5013368Ssam j = abval(j); 5113368Ssam while(j-- > 0)spew(chy); 5213368Ssam spew ('.'); 5313368Ssam } 5413368Ssam outplot(); 5513368Ssam return; 5613368Ssam } 57