Annotation of researchv9/jerq/src/lib/j/disc.c, revision 1.1

1.1     ! root        1: #ifndef        MUX
        !             2: #define        Jcursinhibit()  cursinhibit()
        !             3: #define        Jcursallow()    cursallow()
        !             4: #define        lrectf(l, r, f) rectf(l, r, f)
        !             5: #endif
        !             6: 
        !             7: #include <jerq.h>
        !             8: #define        DB              ((Word *)0x700000)
        !             9: #define        ONSCREEN(b)     (b->base>=DB && b->base<DB+XMAX/WORDSIZE*YMAX)
        !            10: /*     Fill a disc of radius r centered at x1,y1
        !            11:  *     The boundary is a sequence of vertically, horizontally,
        !            12:  *     or diagonally adjacent points that minimize 
        !            13:  *     abs(x^2+y^2-r^2).
        !            14:  *
        !            15:  *     The circle is guaranteed to be symmetric about
        !            16:  *     the horizontal, vertical, and diagonal axes
        !            17:  */
        !            18: disc(b, p, r, f)
        !            19:        Bitmap *b;
        !            20:        Point p;
        !            21: {
        !            22:        register x1=p.x, y1=p.y;
        !            23:        register eps = 0;       /* x^2 + y^2 - r^2 */
        !            24:        int dxsq = 1;           /* (x+dx)^2-x^2*/
        !            25:        int dysq = 1 - 2*r;
        !            26:        int exy;
        !            27:        short inhibited;
        !            28:        register x0 = x1;
        !            29:        register y0 = y1 - r;
        !            30:        x1++;           /* to offset jerq's half-open lines*/
        !            31:        y1 += r;
        !            32:        inhibited=0;
        !            33:        if(f!=F_XOR && ONSCREEN(b)){
        !            34:                Jcursinhibit();
        !            35:                inhibited=1;
        !            36:        }
        !            37:        while(y1 > y0) {
        !            38:                exy = eps + dxsq + dysq;
        !            39:                if(-exy <= eps+dxsq) {
        !            40:                        lrectf(b, Rect(x0, y0, x1, y0+1), f);
        !            41:                        lrectf(b, Rect(x0, y1, x1, y1+1), f);
        !            42:                        y1--;
        !            43:                        y0++;
        !            44:                        eps += dysq;
        !            45:                        dysq += 2;
        !            46:                }
        !            47:                if(exy <= -eps) {
        !            48:                        x1++;
        !            49:                        x0--;
        !            50:                        eps += dxsq;
        !            51:                        dxsq += 2;
        !            52:                }
        !            53:        }
        !            54:        lrectf(b, Rect(x0, y0, x1, y0+1), f);
        !            55:        if(inhibited)
        !            56:                Jcursallow();
        !            57: }

unix.superglobalmegacorp.com

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