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