|
|
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: #define lpoint(l, p, f) point(l, p, f) ! 6: #endif ! 7: ! 8: #include <jerq.h> ! 9: #define DB ((Word *)0x700000) ! 10: #define ONSCREEN(b) (b->base>=DB && b->base<DB+XMAX/WORDSIZE*YMAX) ! 11: /* Form a circle of radius r centered at x1,y1 ! 12: * The boundary is a sequence of vertically, horizontally, ! 13: * or diagonally adjacent points that minimize ! 14: * abs(x^2+y^2-r^2). ! 15: * ! 16: * The circle is guaranteed to be symmetric about ! 17: * the horizontal, vertical, and diagonal axes ! 18: */ ! 19: circle(b,p,r,f) ! 20: Bitmap *b; ! 21: Point p; ! 22: { ! 23: short inhibited; ! 24: int x1=p.x; ! 25: register y1=p.y; ! 26: register eps = 0; /* x^2 + y^2 - r^2 */ ! 27: register dxsq = 1; /* (x+dx)^2-x^2*/ ! 28: register dysq = 1 - 2*r; ! 29: register exy; ! 30: int x0 = x1; ! 31: register y0 = y1 - r; ! 32: y1 += r; ! 33: if (f == F_XOR) { /* endpoints coincide */ ! 34: point(b,Pt(x0,y0),f); ! 35: point(b,Pt(x0,y1),f); ! 36: inhibited=0; ! 37: }else if(ONSCREEN(b)){ ! 38: Jcursinhibit(); ! 39: inhibited=1; ! 40: } ! 41: while(y1 > y0) { ! 42: lpoint(b,Pt(x0,y0),f); ! 43: lpoint(b,Pt(x0,y1),f); ! 44: lpoint(b,Pt(x1,y0),f); ! 45: lpoint(b,Pt(x1,y1),f); ! 46: exy = eps + dxsq + dysq; ! 47: if(-exy <= eps+dxsq) { ! 48: y1--; ! 49: y0++; ! 50: eps += dysq; ! 51: dysq += 2; ! 52: } ! 53: if(exy <= -eps) { ! 54: x1++; ! 55: x0--; ! 56: eps += dxsq; ! 57: dxsq += 2; ! 58: } ! 59: } ! 60: lpoint(b,Pt(x0,y0),f); ! 61: lpoint(b,Pt(x1,y0),f); ! 62: if(inhibited) ! 63: Jcursallow(); ! 64: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.