URI:
       tvec.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tvec.c (916B)
       ---
            1 #include "mplot.h"
            2 #define        code(x, y)        ((x<clipminx?1:x>clipmaxx?2:0)|(y<clipminy?4:y>clipmaxy?8:0))
            3 void vec(double xx, double yy){
            4         int x0, y0, x1, y1, c0, c1, c, tx, ty;
            5         double t;
            6         t=SCX(e1->copyx); if(fabs(t)>BIGINT) return; x0=t;
            7         t=SCY(e1->copyy); if(fabs(t)>BIGINT) return; y0=t;
            8         t=SCX(xx); if(fabs(t)>BIGINT) return; x1=t;
            9         t=SCY(yy); if(fabs(t)>BIGINT) return; y1=t;
           10         e1->copyx=xx;
           11         e1->copyy=yy;
           12         /* clipping -- what a concept */
           13         c0=code(x0, y0);
           14         c1=code(x1, y1);
           15         while(c0|c1){
           16                 if(c0&c1) return;
           17                 c=c0?c0:c1;
           18                 if(c&1)      ty=y0+(y1-y0)*(clipminx-x0)/(x1-x0), tx=clipminx;
           19                 else if(c&2) ty=y0+(y1-y0)*(clipmaxx-x0)/(x1-x0), tx=clipmaxx;
           20                 else if(c&4) tx=x0+(x1-x0)*(clipminy-y0)/(y1-y0), ty=clipminy;
           21                 else         tx=x0+(x1-x0)*(clipmaxy-y0)/(y1-y0), ty=clipmaxy;
           22                 if(c==c0) x0=tx, y0=ty, c0=code(x0, y0);
           23                 else      x1=tx, y1=ty, c1=code(x1, y1);
           24         }
           25         m_vector(x0, y0, x1, y1, e1->foregr);
           26 }