8 * elarc(dst,c,a,b,t,src,sp,alpha,phi)
9 * draws the part of an ellipse between rays at angles alpha and alpha+phi
10 * measured counterclockwise from the positive x axis. other
11 * arguments are as for ellipse(dst,c,a,b,t,src,sp)
16 R, T, L, B /* right, top, left, bottom */
31 * make a "wedge" mask covering the desired angle and contained in
32 * a surrounding square; draw a full ellipse; intersect that with the
33 * wedge to make a mask through which to copy src to dst.
36 memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int alpha, int phi, int op)
38 int i, w, beta, tmp, c1, c2, m, m1;
41 Memimage *wedge, *figure, *mask;
50 alpha = -alpha; /* compensate for upside-down coords */
60 memellipse(dst, c, a, b, t, src, sp, op);
67 c1 = alpha/90 & 3; /* number of nearest corner */
70 * icossin returns point at radius ICOSSCALE.
71 * multiplying by m1 moves it outside the ellipse
73 rect = Rect(-a-w, -b-w, a+w+1, b+w+1);
74 m = rect.max.x; /* inradius of bounding square */
77 m1 = (m+ICOSSCALE-1) >> 10;
78 m = m1 << 10; /* assure m1*cossin is inside */
81 icossin(alpha, &p.x, &p.y);
82 bnd[i++] = mulpt(p, m1);
84 bnd[i++] = mulpt(corners[c1], m);
90 icossin(beta, &p.x, &p.y);
91 bnd[i++] = mulpt(p, m1);
95 wedge = allocmemimage(rect, GREY1);
98 memfillcolor(wedge, DTransparent);
99 memfillpoly(wedge, bnd, i, ~0, memopaque, p00, S);
100 figure = allocmemimage(rect, GREY1);
103 memfillcolor(figure, DTransparent);
104 memellipse(figure, p00, a, b, t, memopaque, p00, S);
105 mask = allocmemimage(rect, GREY1);
108 memfillcolor(mask, DTransparent);
109 memimagedraw(mask, rect, figure, rect.min, wedge, rect.min, S);
110 c = subpt(c, dst->r.min);
111 memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(p00, c), op);
115 freememimage(figure);