| @@ -24,9 +24,6 @@ Point corners[] = { · 23 unmodified lines |
| 24 | 24 | {1,-1} |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | | −static |
| 28 | | −Point p00; |
| 29 | | − |
| 30 | 27 | /* |
| 31 | 28 | * make a "wedge" mask covering the desired angle and contained in |
| 32 | 29 | * a surrounding square; draw a full ellipse; intersect that with the |
| @@ -40,13 +37,13 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int · 7 unmodified lines |
| 40 | 37 | Point p, bnd[8]; |
| 41 | 38 | Memimage *wedge, *figure, *mask; |
| 42 | 39 | |
| 43 | | − if(a < 0) |
| 44 | | − a = -a; |
| 45 | | − if(b < 0) |
| 46 | | − b = -b; |
| 47 | | − w = t; |
| 48 | | − if(w < 0) |
| 49 | | − w = 0; |
| 40 | + if(phi == 0) |
| 41 | + return; |
| 42 | + if(phi <= -360 || phi >= 360){ |
| 43 | + memellipse(dst, c, a, b, t, src, sp, op); |
| 44 | + return; |
| 45 | + } |
| 46 | + alpha %= 360; |
| 50 | 47 | alpha = -alpha; /* compensate for upside-down coords */ |
| 51 | 48 | phi = -phi; |
| 52 | 49 | beta = alpha + phi; |
| @@ -56,10 +53,6 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int · 3 unmodified lines |
| 56 | 53 | beta = tmp; |
| 57 | 54 | phi = -phi; |
| 58 | 55 | } |
| 59 | | − if(phi >= 360){ |
| 60 | | − memellipse(dst, c, a, b, t, src, sp, op); |
| 61 | | − return; |
| 62 | | − } |
| 63 | 56 | while(alpha < 0) |
| 64 | 57 | alpha += 360; |
| 65 | 58 | while(beta < 0) |
| @@ -70,6 +63,15 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int · 4 unmodified lines |
| 70 | 63 | * icossin returns point at radius ICOSSCALE. |
| 71 | 64 | * multiplying by m1 moves it outside the ellipse |
| 72 | 65 | */ |
| 66 | + |
| 67 | + if(a < 0) |
| 68 | + a = -a; |
| 69 | + if(b < 0) |
| 70 | + b = -b; |
| 71 | + w = t; |
| 72 | + if(w < 0) |
| 73 | + w = 0; |
| 74 | + |
| 73 | 75 | rect = Rect(-a-w, -b-w, a+w+1, b+w+1); |
| 74 | 76 | m = rect.max.x; /* inradius of bounding square */ |
| 75 | 77 | if(m < rect.max.y) |
| @@ -96,19 +98,19 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int · 20 unmodified lines |
| 96 | 98 | if(wedge == nil) |
| 97 | 99 | goto Return; |
| 98 | 100 | memfillcolor(wedge, DTransparent); |
| 99 | | − memfillpoly(wedge, bnd, i, ~0, memopaque, p00, S); |
| 101 | + memfillpoly(wedge, bnd, i, ~0, memopaque, ZP, S); |
| 100 | 102 | figure = allocmemimage(rect, GREY1); |
| 101 | 103 | if(figure == nil) |
| 102 | 104 | goto Return; |
| 103 | 105 | memfillcolor(figure, DTransparent); |
| 104 | | − memellipse(figure, p00, a, b, t, memopaque, p00, S); |
| 106 | + memellipse(figure, ZP, a, b, t, memopaque, ZP, S); |
| 105 | 107 | mask = allocmemimage(rect, GREY1); |
| 106 | 108 | if(mask == nil) |
| 107 | 109 | goto Return; |
| 108 | 110 | memfillcolor(mask, DTransparent); |
| 109 | 111 | memimagedraw(mask, rect, figure, rect.min, wedge, rect.min, S); |
| 110 | 112 | c = subpt(c, dst->r.min); |
| 111 | | − memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(p00, c), op); |
| 113 | + memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(ZP, c), op); |
| 112 | 114 | |
| 113 | 115 | Return: |
| 114 | 116 | freememimage(wedge); |