Blame


1 61f5c35c 2004-05-15 devnull #include <u.h>
2 61f5c35c 2004-05-15 devnull #include <libc.h>
3 61f5c35c 2004-05-15 devnull #include <bio.h>
4 61f5c35c 2004-05-15 devnull #include <ctype.h>
5 61f5c35c 2004-05-15 devnull #include "../common/common.h"
6 61f5c35c 2004-05-15 devnull #include "tr2post.h"
7 61f5c35c 2004-05-15 devnull
8 61f5c35c 2004-05-15 devnull BOOLEAN drawflag = FALSE;
9 61f5c35c 2004-05-15 devnull BOOLEAN inpath = FALSE; /* TRUE if we're putting pieces together */
10 61f5c35c 2004-05-15 devnull
11 61f5c35c 2004-05-15 devnull void
12 61f5c35c 2004-05-15 devnull cover(double x, double y) {
13 61f5c35c 2004-05-15 devnull }
14 61f5c35c 2004-05-15 devnull
15 61f5c35c 2004-05-15 devnull void
16 e8fb1d3e 2004-05-17 devnull drawspline(Biobuf *Bp, int flag) { /* flag!=1 connect end points */
17 61f5c35c 2004-05-15 devnull int x[100], y[100];
18 61f5c35c 2004-05-15 devnull int i, N;
19 61f5c35c 2004-05-15 devnull /*
20 61f5c35c 2004-05-15 devnull *
21 61f5c35c 2004-05-15 devnull * Spline drawing routine for Postscript printers. The complicated stuff is
22 61f5c35c 2004-05-15 devnull * handled by procedure Ds, which should be defined in the library file. I've
23 61f5c35c 2004-05-15 devnull * seen wrong implementations of troff's spline drawing, so fo the record I'll
24 61f5c35c 2004-05-15 devnull * write down the parametric equations and the necessary conversions to Bezier
25 61f5c35c 2004-05-15 devnull * cubic splines (as used in Postscript).
26 61f5c35c 2004-05-15 devnull *
27 61f5c35c 2004-05-15 devnull *
28 61f5c35c 2004-05-15 devnull * Parametric equation (x coordinate only):
29 61f5c35c 2004-05-15 devnull *
30 61f5c35c 2004-05-15 devnull *
31 61f5c35c 2004-05-15 devnull * (x2 - 2 * x1 + x0) 2 (x0 + x1)
32 61f5c35c 2004-05-15 devnull * x = ------------------ * t + (x1 - x0) * t + ---------
33 61f5c35c 2004-05-15 devnull * 2 2
34 61f5c35c 2004-05-15 devnull *
35 61f5c35c 2004-05-15 devnull *
36 61f5c35c 2004-05-15 devnull * The coefficients in the Bezier cubic are,
37 61f5c35c 2004-05-15 devnull *
38 61f5c35c 2004-05-15 devnull *
39 61f5c35c 2004-05-15 devnull * A = 0
40 61f5c35c 2004-05-15 devnull * B = (x2 - 2 * x1 + x0) / 2
41 61f5c35c 2004-05-15 devnull * C = x1 - x0
42 61f5c35c 2004-05-15 devnull *
43 61f5c35c 2004-05-15 devnull *
44 61f5c35c 2004-05-15 devnull * while the current point is,
45 61f5c35c 2004-05-15 devnull *
46 61f5c35c 2004-05-15 devnull * current-point = (x0 + x1) / 2
47 61f5c35c 2004-05-15 devnull *
48 61f5c35c 2004-05-15 devnull * Using the relationships given in the Postscript manual (page 121) it's easy to
49 61f5c35c 2004-05-15 devnull * see that the control points are given by,
50 61f5c35c 2004-05-15 devnull *
51 61f5c35c 2004-05-15 devnull *
52 61f5c35c 2004-05-15 devnull * x0' = (x0 + 5 * x1) / 6
53 61f5c35c 2004-05-15 devnull * x1' = (x2 + 5 * x1) / 6
54 61f5c35c 2004-05-15 devnull * x2' = (x1 + x2) / 2
55 61f5c35c 2004-05-15 devnull *
56 61f5c35c 2004-05-15 devnull *
57 61f5c35c 2004-05-15 devnull * where the primed variables are the ones used by curveto. The calculations
58 61f5c35c 2004-05-15 devnull * shown above are done in procedure Ds using the coordinates set up in both
59 61f5c35c 2004-05-15 devnull * the x[] and y[] arrays.
60 61f5c35c 2004-05-15 devnull *
61 61f5c35c 2004-05-15 devnull * A simple test of whether your spline drawing is correct would be to use cip
62 61f5c35c 2004-05-15 devnull * to draw a spline and some tangent lines at appropriate points and then print
63 61f5c35c 2004-05-15 devnull * the file.
64 61f5c35c 2004-05-15 devnull *
65 61f5c35c 2004-05-15 devnull */
66 61f5c35c 2004-05-15 devnull
67 61f5c35c 2004-05-15 devnull for (N=2; N<sizeof(x)/sizeof(x[0]); N++)
68 61f5c35c 2004-05-15 devnull if (Bgetfield(Bp, 'd', &x[N], 0)<=0 || Bgetfield(Bp, 'd', &y[N], 0)<=0)
69 61f5c35c 2004-05-15 devnull break;
70 61f5c35c 2004-05-15 devnull
71 61f5c35c 2004-05-15 devnull x[0] = x[1] = hpos;
72 61f5c35c 2004-05-15 devnull y[0] = y[1] = vpos;
73 61f5c35c 2004-05-15 devnull
74 61f5c35c 2004-05-15 devnull for (i = 1; i < N; i++) {
75 61f5c35c 2004-05-15 devnull x[i+1] += x[i];
76 61f5c35c 2004-05-15 devnull y[i+1] += y[i];
77 61f5c35c 2004-05-15 devnull }
78 61f5c35c 2004-05-15 devnull
79 61f5c35c 2004-05-15 devnull x[N] = x[N-1];
80 61f5c35c 2004-05-15 devnull y[N] = y[N-1];
81 61f5c35c 2004-05-15 devnull
82 61f5c35c 2004-05-15 devnull for (i = ((flag!=1)?0:1); i < ((flag!=1)?N-1:N-2); i++) {
83 61f5c35c 2004-05-15 devnull endstring();
84 61f5c35c 2004-05-15 devnull if (pageon())
85 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d %d %d Ds\n", x[i], y[i], x[i+1], y[i+1], x[i+2], y[i+2]);
86 61f5c35c 2004-05-15 devnull /* if (dobbox == TRUE) { /* could be better */
87 61f5c35c 2004-05-15 devnull /* cover((double)(x[i] + x[i+1])/2,(double)-(y[i] + y[i+1])/2);
88 61f5c35c 2004-05-15 devnull /* cover((double)x[i+1], (double)-y[i+1]);
89 61f5c35c 2004-05-15 devnull /* cover((double)(x[i+1] + x[i+2])/2, (double)-(y[i+1] + y[i+2])/2);
90 61f5c35c 2004-05-15 devnull /* }
91 61f5c35c 2004-05-15 devnull */
92 61f5c35c 2004-05-15 devnull }
93 61f5c35c 2004-05-15 devnull
94 61f5c35c 2004-05-15 devnull hpos = x[N]; /* where troff expects to be */
95 61f5c35c 2004-05-15 devnull vpos = y[N];
96 61f5c35c 2004-05-15 devnull }
97 61f5c35c 2004-05-15 devnull
98 61f5c35c 2004-05-15 devnull void
99 e8fb1d3e 2004-05-17 devnull draw(Biobuf *Bp) {
100 61f5c35c 2004-05-15 devnull
101 61f5c35c 2004-05-15 devnull int r, x1, y1, x2, y2, i;
102 61f5c35c 2004-05-15 devnull int d1, d2;
103 61f5c35c 2004-05-15 devnull
104 61f5c35c 2004-05-15 devnull drawflag = TRUE;
105 61f5c35c 2004-05-15 devnull r = Bgetrune(Bp);
106 61f5c35c 2004-05-15 devnull switch(r) {
107 61f5c35c 2004-05-15 devnull case 'l':
108 0cfb3760 2012-10-21 rsc if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'r', &i, 0)<=0) {
109 61f5c35c 2004-05-15 devnull error(FATAL, "draw line function, destination coordinates not found.\n");
110 0cfb3760 2012-10-21 rsc return;
111 0cfb3760 2012-10-21 rsc }
112 61f5c35c 2004-05-15 devnull
113 61f5c35c 2004-05-15 devnull endstring();
114 61f5c35c 2004-05-15 devnull if (pageon())
115 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d Dl\n", hpos, vpos, hpos+x1, vpos+y1);
116 61f5c35c 2004-05-15 devnull hpos += x1;
117 61f5c35c 2004-05-15 devnull vpos += y1;
118 61f5c35c 2004-05-15 devnull break;
119 61f5c35c 2004-05-15 devnull case 'c':
120 0cfb3760 2012-10-21 rsc if (Bgetfield(Bp, 'd', &d1, 0)<=0) {
121 61f5c35c 2004-05-15 devnull error(FATAL, "draw circle function, diameter coordinates not found.\n");
122 0cfb3760 2012-10-21 rsc return;
123 0cfb3760 2012-10-21 rsc }
124 61f5c35c 2004-05-15 devnull
125 61f5c35c 2004-05-15 devnull endstring();
126 61f5c35c 2004-05-15 devnull if (pageon())
127 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d De\n", hpos, vpos, d1, d1);
128 61f5c35c 2004-05-15 devnull hpos += d1;
129 61f5c35c 2004-05-15 devnull break;
130 61f5c35c 2004-05-15 devnull case 'e':
131 0cfb3760 2012-10-21 rsc if (Bgetfield(Bp, 'd', &d1, 0)<=0 || Bgetfield(Bp, 'd', &d2, 0)<=0) {
132 61f5c35c 2004-05-15 devnull error(FATAL, "draw ellipse function, diameter coordinates not found.\n");
133 0cfb3760 2012-10-21 rsc return;
134 0cfb3760 2012-10-21 rsc }
135 61f5c35c 2004-05-15 devnull
136 61f5c35c 2004-05-15 devnull endstring();
137 61f5c35c 2004-05-15 devnull if (pageon())
138 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d De\n", hpos, vpos, d1, d2);
139 61f5c35c 2004-05-15 devnull hpos += d1;
140 61f5c35c 2004-05-15 devnull break;
141 61f5c35c 2004-05-15 devnull case 'a':
142 0cfb3760 2012-10-21 rsc if (Bgetfield(Bp, 'd', &x1, 0)<=0 || Bgetfield(Bp, 'd', &y1, 0)<=0 || Bgetfield(Bp, 'd', &x2, 0)<=0 || Bgetfield(Bp, 'd', &y2, 0)<=0) {
143 61f5c35c 2004-05-15 devnull error(FATAL, "draw arc function, coordinates not found.\n");
144 0cfb3760 2012-10-21 rsc return;
145 0cfb3760 2012-10-21 rsc }
146 61f5c35c 2004-05-15 devnull
147 61f5c35c 2004-05-15 devnull endstring();
148 61f5c35c 2004-05-15 devnull if (pageon())
149 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d %d %d Da\n", hpos, vpos, x1, y1, x2, y2);
150 61f5c35c 2004-05-15 devnull hpos += x1 + x2;
151 61f5c35c 2004-05-15 devnull vpos += y1 + y2;
152 61f5c35c 2004-05-15 devnull break;
153 61f5c35c 2004-05-15 devnull case 'q':
154 61f5c35c 2004-05-15 devnull drawspline(Bp, 1);
155 61f5c35c 2004-05-15 devnull break;
156 61f5c35c 2004-05-15 devnull case '~':
157 61f5c35c 2004-05-15 devnull drawspline(Bp, 2);
158 61f5c35c 2004-05-15 devnull break;
159 61f5c35c 2004-05-15 devnull default:
160 61f5c35c 2004-05-15 devnull error(FATAL, "unknown draw function <%c>\n", r);
161 0cfb3760 2012-10-21 rsc return;
162 61f5c35c 2004-05-15 devnull }
163 61f5c35c 2004-05-15 devnull }
164 61f5c35c 2004-05-15 devnull
165 61f5c35c 2004-05-15 devnull void
166 61f5c35c 2004-05-15 devnull beginpath(char *buf, int copy) {
167 61f5c35c 2004-05-15 devnull
168 61f5c35c 2004-05-15 devnull /*
169 61f5c35c 2004-05-15 devnull * Called from devcntrl() whenever an "x X BeginPath" command is read. It's used
170 61f5c35c 2004-05-15 devnull * to mark the start of a sequence of drawing commands that should be grouped
171 61f5c35c 2004-05-15 devnull * together and treated as a single path. By default the drawing procedures in
172 61f5c35c 2004-05-15 devnull * *drawfile treat each drawing command as a separate object, and usually start
173 61f5c35c 2004-05-15 devnull * with a newpath (just as a precaution) and end with a stroke. The newpath and
174 61f5c35c 2004-05-15 devnull * stroke isolate individual drawing commands and make it impossible to deal with
175 61f5c35c 2004-05-15 devnull * composite objects. "x X BeginPath" can be used to mark the start of drawing
176 61f5c35c 2004-05-15 devnull * commands that should be grouped together and treated as a single object, and
177 61f5c35c 2004-05-15 devnull * part of what's done here ensures that the PostScript drawing commands defined
178 61f5c35c 2004-05-15 devnull * in *drawfile skip the newpath and stroke, until after the next "x X DrawPath"
179 61f5c35c 2004-05-15 devnull * command. At that point the path that's been built up can be manipulated in
180 61f5c35c 2004-05-15 devnull * various ways (eg. filled and/or stroked with a different line width).
181 61f5c35c 2004-05-15 devnull *
182 61f5c35c 2004-05-15 devnull * Color selection is one of the options that's available in parsebuf(),
183 61f5c35c 2004-05-15 devnull * so if we get here we add *colorfile to the output file before doing
184 61f5c35c 2004-05-15 devnull * anything important.
185 61f5c35c 2004-05-15 devnull *
186 61f5c35c 2004-05-15 devnull */
187 61f5c35c 2004-05-15 devnull if (inpath == FALSE) {
188 61f5c35c 2004-05-15 devnull endstring();
189 61f5c35c 2004-05-15 devnull /* getdraw(); */
190 61f5c35c 2004-05-15 devnull /* getcolor(); */
191 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "gsave\n");
192 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "newpath\n");
193 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d m\n", hpos, vpos);
194 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/inpath true def\n");
195 61f5c35c 2004-05-15 devnull if ( copy == TRUE )
196 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", buf);
197 61f5c35c 2004-05-15 devnull inpath = TRUE;
198 61f5c35c 2004-05-15 devnull }
199 61f5c35c 2004-05-15 devnull }
200 61f5c35c 2004-05-15 devnull
201 61f5c35c 2004-05-15 devnull static void parsebuf(char*);
202 61f5c35c 2004-05-15 devnull
203 61f5c35c 2004-05-15 devnull void
204 61f5c35c 2004-05-15 devnull drawpath(char *buf, int copy) {
205 61f5c35c 2004-05-15 devnull
206 61f5c35c 2004-05-15 devnull /*
207 61f5c35c 2004-05-15 devnull *
208 61f5c35c 2004-05-15 devnull * Called from devcntrl() whenever an "x X DrawPath" command is read. It marks the
209 61f5c35c 2004-05-15 devnull * end of the path started by the last "x X BeginPath" command and uses whatever
210 61f5c35c 2004-05-15 devnull * has been passed along in *buf to manipulate the path (eg. fill and/or stroke
211 61f5c35c 2004-05-15 devnull * the path). Once that's been done the drawing procedures are restored to their
212 61f5c35c 2004-05-15 devnull * default behavior in which each drawing command is treated as an isolated path.
213 61f5c35c 2004-05-15 devnull * The new version (called after "x X DrawPath") has copy set to FALSE, and calls
214 61f5c35c 2004-05-15 devnull * parsebuf() to figure out what goes in the output file. It's a feeble attempt
215 61f5c35c 2004-05-15 devnull * to free users and preprocessors (like pic) from having to know PostScript. The
216 61f5c35c 2004-05-15 devnull * comments in parsebuf() describe what's handled.
217 61f5c35c 2004-05-15 devnull *
218 61f5c35c 2004-05-15 devnull * In the early version a path was started with "x X BeginObject" and ended with
219 61f5c35c 2004-05-15 devnull * "x X EndObject". In both cases *buf was just copied to the output file, and
220 61f5c35c 2004-05-15 devnull * was expected to be legitimate PostScript that manipulated the current path.
221 61f5c35c 2004-05-15 devnull * The old escape sequence will be supported for a while (for Ravi), and always
222 61f5c35c 2004-05-15 devnull * call this routine with copy set to TRUE.
223 fa325e9b 2020-01-10 cross *
224 61f5c35c 2004-05-15 devnull *
225 61f5c35c 2004-05-15 devnull */
226 61f5c35c 2004-05-15 devnull
227 61f5c35c 2004-05-15 devnull if ( inpath == TRUE ) {
228 61f5c35c 2004-05-15 devnull if ( copy == TRUE )
229 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", buf);
230 61f5c35c 2004-05-15 devnull else
231 61f5c35c 2004-05-15 devnull parsebuf(buf);
232 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
233 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/inpath false def\n");
234 61f5c35c 2004-05-15 devnull /* reset(); */
235 61f5c35c 2004-05-15 devnull inpath = FALSE;
236 61f5c35c 2004-05-15 devnull }
237 61f5c35c 2004-05-15 devnull }
238 61f5c35c 2004-05-15 devnull
239 61f5c35c 2004-05-15 devnull
240 61f5c35c 2004-05-15 devnull /*****************************************************************************/
241 61f5c35c 2004-05-15 devnull
242 61f5c35c 2004-05-15 devnull static void
243 61f5c35c 2004-05-15 devnull parsebuf(char *buf)
244 61f5c35c 2004-05-15 devnull {
245 e8fb1d3e 2004-05-17 devnull char *p = (char*)0; /* usually the next token */
246 61f5c35c 2004-05-15 devnull char *q;
247 61f5c35c 2004-05-15 devnull int gsavelevel = 0; /* non-zero if we've done a gsave */
248 61f5c35c 2004-05-15 devnull
249 61f5c35c 2004-05-15 devnull /*
250 61f5c35c 2004-05-15 devnull *
251 61f5c35c 2004-05-15 devnull * Simple minded attempt at parsing the string that followed an "x X DrawPath"
252 61f5c35c 2004-05-15 devnull * command. Everything not recognized here is simply ignored - there's absolutely
253 61f5c35c 2004-05-15 devnull * no error checking and what was originally in buf is clobbered by strtok().
254 61f5c35c 2004-05-15 devnull * A typical *buf might look like,
255 61f5c35c 2004-05-15 devnull *
256 61f5c35c 2004-05-15 devnull * gray .9 fill stroke
257 61f5c35c 2004-05-15 devnull *
258 61f5c35c 2004-05-15 devnull * to fill the current path with a gray level of .9 and follow that by stroking the
259 61f5c35c 2004-05-15 devnull * outline of the path. Since unrecognized tokens are ignored the last example
260 61f5c35c 2004-05-15 devnull * could also be written as,
261 61f5c35c 2004-05-15 devnull *
262 61f5c35c 2004-05-15 devnull * with gray .9 fill then stroke
263 61f5c35c 2004-05-15 devnull *
264 61f5c35c 2004-05-15 devnull * The "with" and "then" strings aren't recognized tokens and are simply discarded.
265 61f5c35c 2004-05-15 devnull * The "stroke", "fill", and "wfill" force out appropriate PostScript code and are
266 61f5c35c 2004-05-15 devnull * followed by a grestore. In otherwords changes to the grahics state (eg. a gray
267 61f5c35c 2004-05-15 devnull * level or color) are reset to default values immediately after the stroke, fill,
268 61f5c35c 2004-05-15 devnull * or wfill tokens. For now "fill" gets invokes PostScript's eofill operator and
269 61f5c35c 2004-05-15 devnull * "wfill" calls fill (ie. the operator that uses the non-zero winding rule).
270 61f5c35c 2004-05-15 devnull *
271 61f5c35c 2004-05-15 devnull * The tokens that cause temporary changes to the graphics state are "gray" (for
272 61f5c35c 2004-05-15 devnull * setting the gray level), "color" (for selecting a known color from the colordict
273 61f5c35c 2004-05-15 devnull * dictionary defined in *colorfile), and "line" (for setting the line width). All
274 61f5c35c 2004-05-15 devnull * three tokens can be extended since strncmp() makes the comparison. For example
275 61f5c35c 2004-05-15 devnull * the strings "line" and "linewidth" accomplish the same thing. Colors are named
276 61f5c35c 2004-05-15 devnull * (eg. "red"), but must be appropriately defined in *colorfile. For now all three
277 61f5c35c 2004-05-15 devnull * tokens must be followed immediately by their single argument. The gray level
278 61f5c35c 2004-05-15 devnull * (ie. the argument that follows "gray") should be a number between 0 and 1, with
279 61f5c35c 2004-05-15 devnull * 0 for black and 1 for white.
280 61f5c35c 2004-05-15 devnull *
281 61f5c35c 2004-05-15 devnull * To pass straight PostScript through enclose the appropriate commands in double
282 61f5c35c 2004-05-15 devnull * quotes. Straight PostScript is only bracketed by the outermost gsave/grestore
283 61f5c35c 2004-05-15 devnull * pair (ie. the one from the initial "x X BeginPath") although that's probably
284 61f5c35c 2004-05-15 devnull * a mistake. Suspect I may have to change the double quote delimiters.
285 61f5c35c 2004-05-15 devnull *
286 61f5c35c 2004-05-15 devnull */
287 61f5c35c 2004-05-15 devnull
288 61f5c35c 2004-05-15 devnull for( ; p != nil ; p = q ) {
289 61f5c35c 2004-05-15 devnull if( q = strchr(p, ' ') ) {
290 61f5c35c 2004-05-15 devnull *q++ = '\0';
291 61f5c35c 2004-05-15 devnull }
292 61f5c35c 2004-05-15 devnull
293 61f5c35c 2004-05-15 devnull if ( gsavelevel == 0 ) {
294 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "gsave\n");
295 61f5c35c 2004-05-15 devnull gsavelevel++;
296 61f5c35c 2004-05-15 devnull }
297 61f5c35c 2004-05-15 devnull if ( strcmp(p, "stroke") == 0 ) {
298 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "closepath stroke\ngrestore\n");
299 61f5c35c 2004-05-15 devnull gsavelevel--;
300 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "openstroke") == 0 ) {
301 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "stroke\ngrestore\n");
302 61f5c35c 2004-05-15 devnull gsavelevel--;
303 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "fill") == 0 ) {
304 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "eofill\ngrestore\n");
305 61f5c35c 2004-05-15 devnull gsavelevel--;
306 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "wfill") == 0 ) {
307 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "fill\ngrestore\n");
308 61f5c35c 2004-05-15 devnull gsavelevel--;
309 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "sfill") == 0 ) {
310 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "eofill\ngrestore\ngsave\nstroke\ngrestore\n");
311 61f5c35c 2004-05-15 devnull gsavelevel--;
312 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "gray", strlen("gray")) == 0 ) {
313 61f5c35c 2004-05-15 devnull if( q ) {
314 61f5c35c 2004-05-15 devnull p = q;
315 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
316 61f5c35c 2004-05-15 devnull *q++ = '\0';
317 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s setgray\n", p);
318 61f5c35c 2004-05-15 devnull }
319 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "color", strlen("color")) == 0 ) {
320 61f5c35c 2004-05-15 devnull if( q ) {
321 61f5c35c 2004-05-15 devnull p = q;
322 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
323 61f5c35c 2004-05-15 devnull *q++ = '\0';
324 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/%s setcolor\n", p);
325 61f5c35c 2004-05-15 devnull }
326 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "line", strlen("line")) == 0 ) {
327 61f5c35c 2004-05-15 devnull if( q ) {
328 61f5c35c 2004-05-15 devnull p = q;
329 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
330 61f5c35c 2004-05-15 devnull *q++ = '\0';
331 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s resolution mul 2 div setlinewidth\n", p);
332 61f5c35c 2004-05-15 devnull }
333 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "reverse", strlen("reverse")) == 0 )
334 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "reversepath\n");
335 61f5c35c 2004-05-15 devnull else if ( *p == '"' ) {
336 61f5c35c 2004-05-15 devnull for ( ; gsavelevel > 0; gsavelevel-- )
337 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
338 61f5c35c 2004-05-15 devnull if ( q != nil )
339 61f5c35c 2004-05-15 devnull *--q = ' ';
340 61f5c35c 2004-05-15 devnull if ( (q = strchr(p, '"')) != nil ) {
341 61f5c35c 2004-05-15 devnull *q++ = '\0';
342 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", p);
343 61f5c35c 2004-05-15 devnull }
344 61f5c35c 2004-05-15 devnull }
345 61f5c35c 2004-05-15 devnull }
346 61f5c35c 2004-05-15 devnull
347 61f5c35c 2004-05-15 devnull for ( ; gsavelevel > 0; gsavelevel-- )
348 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
349 61f5c35c 2004-05-15 devnull
350 61f5c35c 2004-05-15 devnull }