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 */
28 * make a "wedge" mask covering the desired angle and contained in
29 * a surrounding square; draw a full ellipse; intersect that with the
30 * wedge to make a mask through which to copy src to dst.
33 memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int alpha, int phi, int op)
35 int i, w, beta, tmp, c1, c2, m, m1;
38 Memimage *wedge, *figure, *mask;
42 if(phi <= -360 || phi >= 360){
43 memellipse(dst, c, a, b, t, src, sp, op);
47 alpha = -alpha; /* compensate for upside-down coords */
60 c1 = alpha/90 & 3; /* number of nearest corner */
63 * icossin returns point at radius ICOSSCALE.
64 * multiplying by m1 moves it outside the ellipse
75 rect = Rect(-a-w, -b-w, a+w+1, b+w+1);
76 m = rect.max.x; /* inradius of bounding square */
79 m1 = (m+ICOSSCALE-1) >> 10;
80 m = m1 << 10; /* assure m1*cossin is inside */
83 icossin(alpha, &p.x, &p.y);
84 bnd[i++] = mulpt(p, m1);
86 bnd[i++] = mulpt(corners[c1], m);
92 icossin(beta, &p.x, &p.y);
93 bnd[i++] = mulpt(p, m1);
97 wedge = allocmemimage(rect, GREY1);
100 memfillcolor(wedge, DTransparent);
101 memfillpoly(wedge, bnd, i, ~0, memopaque, ZP, S);
102 figure = allocmemimage(rect, GREY1);
105 memfillcolor(figure, DTransparent);
106 memellipse(figure, ZP, a, b, t, memopaque, ZP, S);
107 mask = allocmemimage(rect, GREY1);
110 memfillcolor(mask, DTransparent);
111 memimagedraw(mask, rect, figure, rect.min, wedge, rect.min, S);
112 c = subpt(c, dst->r.min);
113 memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(ZP, c), op);
117 freememimage(figure);