xref: /csrg-svn/lib/libplot/t300s/line.c (revision 48522)
1*48522Sbostic /*-
2*48522Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*48522Sbostic  * All rights reserved.
4*48522Sbostic  *
5*48522Sbostic  * %sccs.include.proprietary.c%
6*48522Sbostic  */
7*48522Sbostic 
813333Ssam #ifndef lint
9*48522Sbostic static char sccsid[] = "@(#)line.c	4.2 (Berkeley) 04/22/91";
10*48522Sbostic #endif /* not lint */
1113333Ssam 
1213333Ssam #include "con.h"
1313333Ssam line(x0,y0,x1,y1){
1413333Ssam 	iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
1513333Ssam 	return;
1613333Ssam }
1713333Ssam cont(x0,y0){
1813333Ssam 	iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
1913333Ssam 	return;
2013333Ssam }
2113333Ssam iline(cx0,cy0,cx1,cy1){
2213333Ssam 	int maxp,tt,j,np;
2313333Ssam 	char chx,chy,command;
2413333Ssam 	    float xd,yd;
2513333Ssam 	float 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