7 void dotline(double, double, double, double, int, double);
8 void dotbox(double, double, double, double, int, double);
9 void ellipse(double, double, double, double);
10 void circle(double, double, double);
11 void arc(double, double, double, double, double, double);
12 void arrow(double, double, double, double, double, double, double, int);
13 void line(double, double, double, double);
14 void box(double, double, double, double);
15 void spline(double x
, double y
, double n
, ofloat
*p
, int dashed
, double ddval
);
16 void move(double, double);
19 void fillstart(double), fillend(int vis
, int noedge
);
26 double x0
, y0
, x1
, y1
, ox
, oy
, dx
, dy
, ndx
, ndy
;
28 for (i
= 0; i
< nobj
; i
++) {
37 fill
= p
->o_attr
& FILLBIT
;
38 invis
= p
->o_attr
& INVIS
;
42 troff(text
[p
->o_nt1
].t_val
);
52 fillstart(p
->o_fillval
);
54 if (p
->o_type
== BLOCK
)
55 ; /* nothing at all */
56 else if (invis
&& !fill
)
57 ; /* nothing at all */
58 else if (p
->o_attr
& (DOTBIT
|DASHBIT
))
59 dotbox(x0
, y0
, x1
, y1
, p
->o_attr
, p
->o_ddval
);
65 dotext(p
); /* if there are any text strings */
67 move(isright(m
) ? x1
: x0
, oy
); /* right side */
69 move(ox
, isdown(m
) ? y0
: y1
); /* bottom */
75 fillstart(p
->o_fillval
);
83 move(ox
+ isright(m
) ? x1
: -x1
, oy
);
85 move(ox
, oy
+ isup(m
) ? x1
: -x1
);
89 fillstart(p
->o_fillval
);
91 ellipse(ox
, oy
, x1
, y1
);
97 move(ox
+ isright(m
) ? x1
: -x1
, oy
);
99 move(ox
, oy
- isdown(m
) ? y1
: -y1
);
104 fillstart(p
->o_fillval
);
106 if (p
->o_attr
& HEAD1
)
107 arrow(x1
- (y1
- oy
), y1
+ (x1
- ox
),
108 x1
, y1
, p
->o_val
[4], p
->o_val
[5], p
->o_val
[5]/p
->o_val
[6]/2, p
->o_nhead
);
110 /* probably wrong when it's cw */
113 arc(ox
, oy
, x1
, y1
, p
->o_val
[2], p
->o_val
[3]);
114 if (p
->o_attr
& HEAD2
)
115 arrow(p
->o_val
[2] + p
->o_val
[3] - oy
, p
->o_val
[3] - (p
->o_val
[2] - ox
),
116 p
->o_val
[2], p
->o_val
[3], p
->o_val
[4], p
->o_val
[5], -p
->o_val
[5]/p
->o_val
[6]/2, p
->o_nhead
);
119 if (p
->o_attr
& CW_ARC
)
120 move(x1
, y1
); /* because drawn backwards */
129 fillstart(p
->o_fillval
);
131 if (vis
&& p
->o_attr
& HEAD1
)
132 arrow(ox
+ p
->o_val
[5], oy
+ p
->o_val
[6], ox
, oy
, p
->o_val
[2], p
->o_val
[3], 0.0, p
->o_nhead
);
135 else if (p
->o_type
== SPLINE
)
136 spline(ox
, oy
, p
->o_val
[4], &p
->o_val
[5], p
->o_attr
& (DOTBIT
|DASHBIT
), p
->o_ddval
);
140 for (k
=0, j
=5; k
< p
->o_val
[4]; k
++, j
+= 2) {
141 ndx
= dx
+ p
->o_val
[j
];
142 ndy
= dy
+ p
->o_val
[j
+1];
143 if (p
->o_attr
& (DOTBIT
|DASHBIT
))
144 dotline(dx
, dy
, ndx
, ndy
, p
->o_attr
, p
->o_ddval
);
146 line(dx
, dy
, ndx
, ndy
);
151 if (vis
&& p
->o_attr
& HEAD2
) {
154 for (k
= 0, j
= 5; k
< p
->o_val
[4] - 1; k
++, j
+= 2) {
158 arrow(dx
, dy
, x1
, y1
, p
->o_val
[2], p
->o_val
[3], 0.0, p
->o_nhead
);
162 move((ox
+ x1
)/2, (oy
+ y1
)/2); /* center */
177 void dotline(double x0
, double y0
, double x1
, double y1
, int ddtype
, double ddval
) /* dotted line */
179 static double prevval
= 0.05; /* 20 per inch by default */
186 /* don't save dot/dash value */
189 if (ddtype
& DOTBIT
) {
190 numdots
= sqrt(dx
*dx
+ dy
*dy
) / prevval
+ 0.5;
192 for (i
= 0; i
<= numdots
; i
++) {
193 a
= (double) i
/ (double) numdots
;
194 move(x0
+ (a
* dx
), y0
+ (a
* dy
));
197 } else if (ddtype
& DASHBIT
) {
198 double d
, dashsize
, spacesize
;
199 d
= sqrt(dx
*dx
+ dy
*dy
);
200 if (d
<= 2 * prevval
) {
201 line(x0
, y0
, x1
, y1
);
204 numdots
= d
/ (2 * prevval
) + 1; /* ceiling */
206 spacesize
= (d
- numdots
* dashsize
) / (numdots
- 1);
207 for (i
= 0; i
< numdots
-1; i
++) {
208 a
= i
* (dashsize
+ spacesize
) / d
;
209 b
= a
+ dashsize
/ d
;
210 line(x0
+ (a
*dx
), y0
+ (a
*dy
), x0
+ (b
*dx
), y0
+ (b
*dy
));
212 b
= a
+ spacesize
/ d
;
213 move(x0
+ (a
*dx
), y0
+ (a
*dy
));
215 line(x0
+ (b
* dx
), y0
+ (b
* dy
), x1
, y1
);
220 void dotbox(double x0
, double y0
, double x1
, double y1
, int ddtype
, double ddval
) /* dotted or dashed box */
222 dotline(x0
, y0
, x1
, y0
, ddtype
, ddval
);
223 dotline(x1
, y0
, x1
, y1
, ddtype
, ddval
);
224 dotline(x1
, y1
, x0
, y1
, ddtype
, ddval
);
225 dotline(x0
, y1
, x0
, y0
, ddtype
, ddval
);
228 void dotext(obj
*p
) /* print text strings of p in proper vertical spacing */
231 void label(char *, int, int);
233 nhalf
= p
->o_nt2
- p
->o_nt1
- 1;
234 for (i
= p
->o_nt1
; i
< p
->o_nt2
; i
++) {
235 label(text
[i
].t_val
, text
[i
].t_type
, nhalf
);