14be2d126Sbostic /*-
2*13b2c6e0Sbostic * Copyright (c) 1983, 1993
3*13b2c6e0Sbostic * The Regents of the University of California. All rights reserved.
44be2d126Sbostic *
54be2d126Sbostic * %sccs.include.proprietary.c%
64be2d126Sbostic */
74be2d126Sbostic
82626ae60Ssam #ifndef lint
9*13b2c6e0Sbostic static char sccsid[] = "@(#)line.c 8.1 (Berkeley) 06/04/93";
104be2d126Sbostic #endif /* not lint */
112626ae60Ssam
122626ae60Ssam #include "con.h"
line(x0,y0,x1,y1)132626ae60Ssam line(x0,y0,x1,y1){
142626ae60Ssam iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
152626ae60Ssam return;
162626ae60Ssam }
cont(x0,y0)172626ae60Ssam cont(x0,y0){
182626ae60Ssam iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
192626ae60Ssam return;
202626ae60Ssam }
iline(cx0,cy0,cx1,cy1)212626ae60Ssam iline(cx0,cy0,cx1,cy1){
222626ae60Ssam int maxp,tt,j,np;
232626ae60Ssam char chx,chy;
242626ae60Ssam float xd,yd;
256339f93fStorek double dist2(),sqrt();
262626ae60Ssam movep(cx0,cy0);
272626ae60Ssam maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
282626ae60Ssam xd = cx1-cx0;
292626ae60Ssam yd = cy1-cy0;
302626ae60Ssam if(xd >= 0)chx = RIGHT;
312626ae60Ssam else chx = LEFT;
322626ae60Ssam if(yd >= 0)chy = UP;
332626ae60Ssam else chy = DOWN;
342626ae60Ssam if(maxp==0){
352626ae60Ssam xd=0;
362626ae60Ssam yd=0;
372626ae60Ssam }
382626ae60Ssam else{
392626ae60Ssam xd /= maxp;
402626ae60Ssam yd /= maxp;
412626ae60Ssam }
422626ae60Ssam inplot();
432626ae60Ssam for (tt=0; tt<=maxp; tt++){
442626ae60Ssam j= cx0+xd*tt-xnow;
452626ae60Ssam xnow += j;
462626ae60Ssam j = abval(j);
472626ae60Ssam while(j-- > 0)spew(chx);
482626ae60Ssam j = cy0+yd*tt-ynow;
492626ae60Ssam ynow += j;
502626ae60Ssam j = abval(j);
512626ae60Ssam while(j-- > 0)spew(chy);
522626ae60Ssam spew ('.');
532626ae60Ssam }
542626ae60Ssam outplot();
552626ae60Ssam return;
562626ae60Ssam }
57