xref: /original-bsd/lib/libplot/t450/line.c (revision 208c32f3)
10884162dSbostic /*-
2*208c32f3Sbostic  * Copyright (c) 1983, 1993
3*208c32f3Sbostic  *	The Regents of the University of California.  All rights reserved.
40884162dSbostic  *
50884162dSbostic  * %sccs.include.proprietary.c%
60884162dSbostic  */
70884162dSbostic 
85a465ee5Ssam #ifndef lint
9*208c32f3Sbostic static char sccsid[] = "@(#)line.c	8.1 (Berkeley) 06/04/93";
100884162dSbostic #endif /* not lint */
115a465ee5Ssam 
125a465ee5Ssam #include "con.h"
line(x0,y0,x1,y1)135a465ee5Ssam line(x0,y0,x1,y1){
145a465ee5Ssam 	iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
155a465ee5Ssam 		return;
165a465ee5Ssam }
cont(x0,y0)175a465ee5Ssam cont(x0,y0){
185a465ee5Ssam 	iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
195a465ee5Ssam 	return;
205a465ee5Ssam }
iline(cx0,cy0,cx1,cy1)215a465ee5Ssam iline(cx0,cy0,cx1,cy1){
225a465ee5Ssam 	int maxp,tt,j,np;
235a465ee5Ssam 	char chx,chy;
245a465ee5Ssam 	float xd,yd;
25650594d8Storek 	double dist2(),sqrt();
265a465ee5Ssam 		movep(cx0,cy0);
275a465ee5Ssam 		maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
285a465ee5Ssam 		xd = cx1-cx0;
295a465ee5Ssam 		yd = cy1-cy0;
305a465ee5Ssam 		if(xd >= 0)chx = RIGHT;
315a465ee5Ssam 		else chx = LEFT;
325a465ee5Ssam 		if(yd >= 0)chy = UP;
335a465ee5Ssam 		else chy = DOWN;
345a465ee5Ssam 		if(maxp == 0){
355a465ee5Ssam 			xd=0;
365a465ee5Ssam 			yd=0;
375a465ee5Ssam 		}
385a465ee5Ssam 		else{
395a465ee5Ssam 			xd /= maxp;
405a465ee5Ssam 			yd /= maxp;
415a465ee5Ssam 		}
425a465ee5Ssam 		inplot();
435a465ee5Ssam 		for (tt=0; tt<=maxp; tt++){
445a465ee5Ssam 			j= cx0+xd*tt-xnow;
455a465ee5Ssam 			xnow += j;
465a465ee5Ssam 			j = abval(j);
475a465ee5Ssam 			while(j-- > 0)spew(chx);
485a465ee5Ssam 			j = cy0+yd*tt-ynow;
495a465ee5Ssam 			ynow += j;
505a465ee5Ssam 			j = abval(j);
515a465ee5Ssam 			while(j-- > 0)spew(chy);
525a465ee5Ssam 			spew ('.');
535a465ee5Ssam 		}
545a465ee5Ssam 		outplot();
555a465ee5Ssam 		return;
565a465ee5Ssam }
57