xref: /original-bsd/lib/libplot/t300s/line.c (revision c3e32dec)
1 /*-
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)line.c	8.1 (Berkeley) 06/04/93";
10 #endif /* not lint */
11 
12 #include "con.h"
13 line(x0,y0,x1,y1){
14 	iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
15 	return;
16 }
17 cont(x0,y0){
18 	iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
19 	return;
20 }
21 iline(cx0,cy0,cx1,cy1){
22 	int maxp,tt,j,np;
23 	char chx,chy,command;
24 	    float xd,yd;
25 	double dist2(),sqrt();
26 	movep(cx0,cy0);
27 	maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
28 	xd = cx1-cx0;
29 	yd = cy1-cy0;
30 	command = COM|((xd<0)<<1)|(yd<0);
31 	if(maxp == 0){
32 		xd=0;
33 		yd=0;
34 	}
35 	else {
36 		xd /= maxp;
37 		yd /= maxp;
38 	}
39 	inplot();
40 	spew(command);
41 	for (tt=0; tt<=maxp; tt++){
42 		chx= cx0+xd*tt-xnow;
43 		xnow += chx;
44 		chx = abval(chx);
45 		chy = cy0+yd*tt-ynow;
46 		ynow += chy;
47 		chy = abval(chy);
48 		spew(ADDR|chx<<3|chy);
49 	}
50 	outplot();
51 	return;
52 }
53