7 * elarc(dst,c,a,b,t,src,sp,alpha,phi)
8 * draws the part of an ellipse between rays at angles alpha and alpha+phi
9 * measured counterclockwise from the positive x axis. other
10 * arguments are as for ellipse(dst,c,a,b,t,src,sp)
15 R, T, L, B /* right, top, left, bottom */
30 * make a "wedge" mask covering the desired angle and contained in
31 * a surrounding square; draw a full ellipse; intersect that with the
32 * wedge to make a mask through which to copy src to dst.
35 memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int alpha, int phi, int op)
37 int i, w, beta, tmp, c1, c2, m, m1;
40 Memimage *wedge, *figure, *mask;
49 alpha = -alpha; /* compensate for upside-down coords */
59 memellipse(dst, c, a, b, t, src, sp, op);
66 c1 = alpha/90 & 3; /* number of nearest corner */
69 * icossin returns point at radius ICOSSCALE.
70 * multiplying by m1 moves it outside the ellipse
72 rect = Rect(-a-w, -b-w, a+w+1, b+w+1);
73 m = rect.max.x; /* inradius of bounding square */
76 m1 = (m+ICOSSCALE-1) >> 10;
77 m = m1 << 10; /* assure m1*cossin is inside */
80 icossin(alpha, &p.x, &p.y);
81 bnd[i++] = mulpt(p, m1);
83 bnd[i++] = mulpt(corners[c1], m);
89 icossin(beta, &p.x, &p.y);
90 bnd[i++] = mulpt(p, m1);
94 wedge = allocmemimage(rect, GREY1);
97 memfillcolor(wedge, DTransparent);
98 memfillpoly(wedge, bnd, i, ~0, memopaque, p00, S);
99 figure = allocmemimage(rect, GREY1);
102 memfillcolor(figure, DTransparent);
103 memellipse(figure, p00, a, b, t, memopaque, p00, S);
104 mask = allocmemimage(rect, GREY1);
107 memfillcolor(mask, DTransparent);
108 memimagedraw(mask, rect, figure, rect.min, wedge, rect.min, S);
109 c = subpt(c, dst->r.min);
110 memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(p00, c), op);
114 freememimage(figure);