File: mi_zerarc.h

package info (click to toggle)
plotutils 2.4.1-15
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 11,072 kB
  • ctags: 6,952
  • sloc: ansic: 76,305; cpp: 12,402; sh: 8,475; yacc: 2,604; makefile: 894; lex: 144
file content (101 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* This header file is included by mi_zerarc.c, which draws a single-pixel
   (i.e. Bresenham) poly-arc using a fast integer algorithm.  It defines
   structures and macros used in the algorithm. */

typedef struct 
{
  int x;
  int y;
  unsigned int mask;
} miZeroArcPt;

typedef struct 
{
  int x, y, k1, k3, a, b, d, dx, dy;
  int alpha, beta;
  int xorg, yorg;		/* upper left corner */
  int xorgo, yorgo;
  unsigned int w, h;
  unsigned int initialMask;
  miZeroArcPt start, altstart, end, altend;
  int firstx, firsty;
  int startAngle, endAngle;	/* in 1/64 degrees */
} miZeroArc;

/* miZeroPolyArc() draws an arc only if it satisfies the following size
   constraint.  If it doesn't, miZeroPolyArc() hands it off to miPolyArc(),
   which uses a floating point algorithm. */
#define MI_CAN_ZERO_ARC(arc) (((arc)->width == (arc)->height) || \
			     (((arc)->width <= 800) && ((arc)->height <= 800)))

/* used for setup only */
#define MIARCSETUP(info, x, y, k1, k3, a, b, d, dx, dy) \
x = info.x; \
y = info.y; \
k1 = info.k1; \
k3 = info.k3; \
a = info.a; \
b = info.b; \
d = info.d; \
dx = info.dx; \
dy = info.dy

#define MIARCOCTANTSHIFT(info, x, y, dx, dy, a, b, d, k1, k3, clause) \
if (a < 0) \
{ \
    if (y == (int)info.h) \
      { \
	d = -1; \
	a = b = k1 = 0; \
      } \
  else \
    { \
      dx = (k1 << 1) - k3; \
      k1 = dx - k1; \
      k3 = -k3; \
      b = b + a - (k1 >> 1); \
      d = b + ((-a) >> 1) - d + (k3 >> 3); \
      if (dx < 0) \
	  a = -((-dx) >> 1) - a; \
      else \
	  a = (dx >> 1) - a; \
      dx = 0; \
      dy = 1; \
      clause \
    } \
}

#define MIARCSTEP(x, y, dx, dy, a, b, d, k1, k3, move1, move2) \
b -= k1; \
if (d < 0) \
{ \
    x += dx; \
    y += dy; \
    a += k1; \
    d += b; \
    move1 \
} \
else \
{ \
    x++; \
    y++; \
    a += k3; \
    d -= a; \
    move2 \
}

#define MIARCCIRCLESTEP(x, y, a, b, d, k1, k3, clause) \
b -= k1; \
x++; \
if (d < 0) \
{ \
  a += k1; \
  d += b; \
} \
else \
{ \
  y++; \
  a += k3; \
  d -= a; \
  clause \
}