1 /* $Header: /home/yav/xpx/RCS/circle.c,v 1.5 1995/11/23 16:28:39 yav Exp $
2 * circle
3 * written by yav (UHD98984@pcvan.or.jp)
4 * Reference:
5 * Algorithm dictionary by Haruhiko Okumura (PAF01002@niftyserve.or.jp)
6 */
7
8 char rcsid_cirle[] = "$Id: circle.c,v 1.5 1995/11/23 16:28:39 yav Exp $";
9
10 #define DOT(x,y) (*pp++ = (x), *pp++ = (y))
11
circle(pp,xc,yc,r)12 int circle(pp, xc, yc, r)
13 int *pp;
14 int xc;
15 int yc;
16 int r;
17 {
18 int x, y, pts;
19
20 x = r;
21 pts = y = 0;
22 while (x >= y) {
23 DOT(xc + x -1, yc + y -1);
24 DOT(xc + x -1, yc - y);
25 DOT(xc - x, yc + y -1);
26 DOT(xc - x, yc - y);
27 DOT(xc + y -1, yc + x -1);
28 DOT(xc + y -1, yc - x);
29 DOT(xc - y, yc + x -1);
30 DOT(xc - y, yc - x);
31 pts += 8;
32 if ((r -= (y++ << 1) - 1) < 0)
33 r += (x-- - 1) << 1;
34 }
35 return pts;
36 }
37
38 /* End of file */
39