Annotation of 43BSDTahoe/usr.lib/libplot/t450/line.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)line.c     4.1 (Berkeley) 6/27/83";
                      3: #endif
                      4: 
                      5: #include "con.h"
                      6: line(x0,y0,x1,y1){
                      7:        iline(xconv(xsc(x0)),yconv(ysc(y0)),xconv(xsc(x1)),yconv(ysc(y1)));
                      8:                return;
                      9: }
                     10: cont(x0,y0){
                     11:        iline(xnow,ynow,xconv(xsc(x0)),yconv(ysc(y0)));
                     12:        return;
                     13: }
                     14: iline(cx0,cy0,cx1,cy1){
                     15:        int maxp,tt,j,np;
                     16:        char chx,chy;
                     17:        float xd,yd;
                     18:        float dist2(),sqrt();
                     19:                movep(cx0,cy0);
                     20:                maxp = sqrt(dist2(cx0,cy0,cx1,cy1))/2.;
                     21:                xd = cx1-cx0;
                     22:                yd = cy1-cy0;
                     23:                if(xd >= 0)chx = RIGHT;
                     24:                else chx = LEFT;
                     25:                if(yd >= 0)chy = UP;
                     26:                else chy = DOWN;
                     27:                if(maxp == 0){
                     28:                        xd=0;
                     29:                        yd=0;
                     30:                }
                     31:                else{
                     32:                        xd /= maxp;
                     33:                        yd /= maxp;
                     34:                }
                     35:                inplot();
                     36:                for (tt=0; tt<=maxp; tt++){
                     37:                        j= cx0+xd*tt-xnow;
                     38:                        xnow += j;
                     39:                        j = abval(j);
                     40:                        while(j-- > 0)spew(chx);
                     41:                        j = cy0+yd*tt-ynow;
                     42:                        ynow += j;
                     43:                        j = abval(j);
                     44:                        while(j-- > 0)spew(chy);
                     45:                        spew ('.');
                     46:                }
                     47:                outplot();
                     48:                return;
                     49: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.