xref: /csrg-svn/lib/libplot/t300s/line.c (revision 61403)
148522Sbostic /*-
2*61403Sbostic  * Copyright (c) 1983, 1993
3*61403Sbostic  *	The Regents of the University of California.  All rights reserved.
448522Sbostic  *
548522Sbostic  * %sccs.include.proprietary.c%
648522Sbostic  */
748522Sbostic 
813333Ssam #ifndef lint
9*61403Sbostic static char sccsid[] = "@(#)line.c	8.1 (Berkeley) 06/04/93";
1048522Sbostic #endif /* not lint */
1113333Ssam 
1213333Ssam #include "con.h"
line(x0,y0,x1,y1)1313333Ssam line(x0,y0,x1,y1){
1413333Ssam 	iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
1513333Ssam 	return;
1613333Ssam }
cont(x0,y0)1713333Ssam cont(x0,y0){
1813333Ssam 	iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
1913333Ssam 	return;
2013333Ssam }
iline(cx0,cy0,cx1,cy1)2113333Ssam iline(cx0,cy0,cx1,cy1){
2213333Ssam 	int maxp,tt,j,np;
2313333Ssam 	char chx,chy,command;
2413333Ssam 	    float xd,yd;
2557886Storek 	double dist2(),sqrt();
2613333Ssam 	movep(cx0,cy0);
2713333Ssam 	maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
2813333Ssam 	xd = cx1-cx0;
2913333Ssam 	yd = cy1-cy0;
3013333Ssam 	command = COM|((xd<0)<<1)|(yd<0);
3113333Ssam 	if(maxp == 0){
3213333Ssam 		xd=0;
3313333Ssam 		yd=0;
3413333Ssam 	}
3513333Ssam 	else {
3613333Ssam 		xd /= maxp;
3713333Ssam 		yd /= maxp;
3813333Ssam 	}
3913333Ssam 	inplot();
4013333Ssam 	spew(command);
4113333Ssam 	for (tt=0; tt<=maxp; tt++){
4213333Ssam 		chx= cx0+xd*tt-xnow;
4313333Ssam 		xnow += chx;
4413333Ssam 		chx = abval(chx);
4513333Ssam 		chy = cy0+yd*tt-ynow;
4613333Ssam 		ynow += chy;
4713333Ssam 		chy = abval(chy);
4813333Ssam 		spew(ADDR|chx<<3|chy);
4913333Ssam 	}
5013333Ssam 	outplot();
5113333Ssam 	return;
5213333Ssam }
53