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 61f5c35c 2004-05-15 devnull 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 61f5c35c 2004-05-15 devnull
111 61f5c35c 2004-05-15 devnull endstring();
112 61f5c35c 2004-05-15 devnull if (pageon())
113 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d Dl\n", hpos, vpos, hpos+x1, vpos+y1);
114 61f5c35c 2004-05-15 devnull hpos += x1;
115 61f5c35c 2004-05-15 devnull vpos += y1;
116 61f5c35c 2004-05-15 devnull break;
117 61f5c35c 2004-05-15 devnull case 'c':
118 61f5c35c 2004-05-15 devnull if (Bgetfield(Bp, 'd', &d1, 0)<=0)
119 61f5c35c 2004-05-15 devnull error(FATAL, "draw circle function, diameter coordinates not found.\n");
120 61f5c35c 2004-05-15 devnull
121 61f5c35c 2004-05-15 devnull endstring();
122 61f5c35c 2004-05-15 devnull if (pageon())
123 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d De\n", hpos, vpos, d1, d1);
124 61f5c35c 2004-05-15 devnull hpos += d1;
125 61f5c35c 2004-05-15 devnull break;
126 61f5c35c 2004-05-15 devnull case 'e':
127 61f5c35c 2004-05-15 devnull if (Bgetfield(Bp, 'd', &d1, 0)<=0 || Bgetfield(Bp, 'd', &d2, 0)<=0)
128 61f5c35c 2004-05-15 devnull error(FATAL, "draw ellipse function, diameter coordinates not found.\n");
129 61f5c35c 2004-05-15 devnull
130 61f5c35c 2004-05-15 devnull endstring();
131 61f5c35c 2004-05-15 devnull if (pageon())
132 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d De\n", hpos, vpos, d1, d2);
133 61f5c35c 2004-05-15 devnull hpos += d1;
134 61f5c35c 2004-05-15 devnull break;
135 61f5c35c 2004-05-15 devnull case 'a':
136 61f5c35c 2004-05-15 devnull 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)
137 61f5c35c 2004-05-15 devnull error(FATAL, "draw arc function, coordinates not found.\n");
138 61f5c35c 2004-05-15 devnull
139 61f5c35c 2004-05-15 devnull endstring();
140 61f5c35c 2004-05-15 devnull if (pageon())
141 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d %d %d %d %d Da\n", hpos, vpos, x1, y1, x2, y2);
142 61f5c35c 2004-05-15 devnull hpos += x1 + x2;
143 61f5c35c 2004-05-15 devnull vpos += y1 + y2;
144 61f5c35c 2004-05-15 devnull break;
145 61f5c35c 2004-05-15 devnull case 'q':
146 61f5c35c 2004-05-15 devnull drawspline(Bp, 1);
147 61f5c35c 2004-05-15 devnull break;
148 61f5c35c 2004-05-15 devnull case '~':
149 61f5c35c 2004-05-15 devnull drawspline(Bp, 2);
150 61f5c35c 2004-05-15 devnull break;
151 61f5c35c 2004-05-15 devnull default:
152 61f5c35c 2004-05-15 devnull error(FATAL, "unknown draw function <%c>\n", r);
153 61f5c35c 2004-05-15 devnull break;
154 61f5c35c 2004-05-15 devnull }
155 61f5c35c 2004-05-15 devnull }
156 61f5c35c 2004-05-15 devnull
157 61f5c35c 2004-05-15 devnull void
158 61f5c35c 2004-05-15 devnull beginpath(char *buf, int copy) {
159 61f5c35c 2004-05-15 devnull
160 61f5c35c 2004-05-15 devnull /*
161 61f5c35c 2004-05-15 devnull * Called from devcntrl() whenever an "x X BeginPath" command is read. It's used
162 61f5c35c 2004-05-15 devnull * to mark the start of a sequence of drawing commands that should be grouped
163 61f5c35c 2004-05-15 devnull * together and treated as a single path. By default the drawing procedures in
164 61f5c35c 2004-05-15 devnull * *drawfile treat each drawing command as a separate object, and usually start
165 61f5c35c 2004-05-15 devnull * with a newpath (just as a precaution) and end with a stroke. The newpath and
166 61f5c35c 2004-05-15 devnull * stroke isolate individual drawing commands and make it impossible to deal with
167 61f5c35c 2004-05-15 devnull * composite objects. "x X BeginPath" can be used to mark the start of drawing
168 61f5c35c 2004-05-15 devnull * commands that should be grouped together and treated as a single object, and
169 61f5c35c 2004-05-15 devnull * part of what's done here ensures that the PostScript drawing commands defined
170 61f5c35c 2004-05-15 devnull * in *drawfile skip the newpath and stroke, until after the next "x X DrawPath"
171 61f5c35c 2004-05-15 devnull * command. At that point the path that's been built up can be manipulated in
172 61f5c35c 2004-05-15 devnull * various ways (eg. filled and/or stroked with a different line width).
173 61f5c35c 2004-05-15 devnull *
174 61f5c35c 2004-05-15 devnull * Color selection is one of the options that's available in parsebuf(),
175 61f5c35c 2004-05-15 devnull * so if we get here we add *colorfile to the output file before doing
176 61f5c35c 2004-05-15 devnull * anything important.
177 61f5c35c 2004-05-15 devnull *
178 61f5c35c 2004-05-15 devnull */
179 61f5c35c 2004-05-15 devnull if (inpath == FALSE) {
180 61f5c35c 2004-05-15 devnull endstring();
181 61f5c35c 2004-05-15 devnull /* getdraw(); */
182 61f5c35c 2004-05-15 devnull /* getcolor(); */
183 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "gsave\n");
184 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "newpath\n");
185 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%d %d m\n", hpos, vpos);
186 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/inpath true def\n");
187 61f5c35c 2004-05-15 devnull if ( copy == TRUE )
188 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", buf);
189 61f5c35c 2004-05-15 devnull inpath = TRUE;
190 61f5c35c 2004-05-15 devnull }
191 61f5c35c 2004-05-15 devnull }
192 61f5c35c 2004-05-15 devnull
193 61f5c35c 2004-05-15 devnull static void parsebuf(char*);
194 61f5c35c 2004-05-15 devnull
195 61f5c35c 2004-05-15 devnull void
196 61f5c35c 2004-05-15 devnull drawpath(char *buf, int copy) {
197 61f5c35c 2004-05-15 devnull
198 61f5c35c 2004-05-15 devnull /*
199 61f5c35c 2004-05-15 devnull *
200 61f5c35c 2004-05-15 devnull * Called from devcntrl() whenever an "x X DrawPath" command is read. It marks the
201 61f5c35c 2004-05-15 devnull * end of the path started by the last "x X BeginPath" command and uses whatever
202 61f5c35c 2004-05-15 devnull * has been passed along in *buf to manipulate the path (eg. fill and/or stroke
203 61f5c35c 2004-05-15 devnull * the path). Once that's been done the drawing procedures are restored to their
204 61f5c35c 2004-05-15 devnull * default behavior in which each drawing command is treated as an isolated path.
205 61f5c35c 2004-05-15 devnull * The new version (called after "x X DrawPath") has copy set to FALSE, and calls
206 61f5c35c 2004-05-15 devnull * parsebuf() to figure out what goes in the output file. It's a feeble attempt
207 61f5c35c 2004-05-15 devnull * to free users and preprocessors (like pic) from having to know PostScript. The
208 61f5c35c 2004-05-15 devnull * comments in parsebuf() describe what's handled.
209 61f5c35c 2004-05-15 devnull *
210 61f5c35c 2004-05-15 devnull * In the early version a path was started with "x X BeginObject" and ended with
211 61f5c35c 2004-05-15 devnull * "x X EndObject". In both cases *buf was just copied to the output file, and
212 61f5c35c 2004-05-15 devnull * was expected to be legitimate PostScript that manipulated the current path.
213 61f5c35c 2004-05-15 devnull * The old escape sequence will be supported for a while (for Ravi), and always
214 61f5c35c 2004-05-15 devnull * call this routine with copy set to TRUE.
215 61f5c35c 2004-05-15 devnull *
216 61f5c35c 2004-05-15 devnull *
217 61f5c35c 2004-05-15 devnull */
218 61f5c35c 2004-05-15 devnull
219 61f5c35c 2004-05-15 devnull if ( inpath == TRUE ) {
220 61f5c35c 2004-05-15 devnull if ( copy == TRUE )
221 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", buf);
222 61f5c35c 2004-05-15 devnull else
223 61f5c35c 2004-05-15 devnull parsebuf(buf);
224 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
225 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/inpath false def\n");
226 61f5c35c 2004-05-15 devnull /* reset(); */
227 61f5c35c 2004-05-15 devnull inpath = FALSE;
228 61f5c35c 2004-05-15 devnull }
229 61f5c35c 2004-05-15 devnull }
230 61f5c35c 2004-05-15 devnull
231 61f5c35c 2004-05-15 devnull
232 61f5c35c 2004-05-15 devnull /*****************************************************************************/
233 61f5c35c 2004-05-15 devnull
234 61f5c35c 2004-05-15 devnull static void
235 61f5c35c 2004-05-15 devnull parsebuf(char *buf)
236 61f5c35c 2004-05-15 devnull {
237 e8fb1d3e 2004-05-17 devnull char *p = (char*)0; /* usually the next token */
238 61f5c35c 2004-05-15 devnull char *q;
239 61f5c35c 2004-05-15 devnull int gsavelevel = 0; /* non-zero if we've done a gsave */
240 61f5c35c 2004-05-15 devnull
241 61f5c35c 2004-05-15 devnull /*
242 61f5c35c 2004-05-15 devnull *
243 61f5c35c 2004-05-15 devnull * Simple minded attempt at parsing the string that followed an "x X DrawPath"
244 61f5c35c 2004-05-15 devnull * command. Everything not recognized here is simply ignored - there's absolutely
245 61f5c35c 2004-05-15 devnull * no error checking and what was originally in buf is clobbered by strtok().
246 61f5c35c 2004-05-15 devnull * A typical *buf might look like,
247 61f5c35c 2004-05-15 devnull *
248 61f5c35c 2004-05-15 devnull * gray .9 fill stroke
249 61f5c35c 2004-05-15 devnull *
250 61f5c35c 2004-05-15 devnull * to fill the current path with a gray level of .9 and follow that by stroking the
251 61f5c35c 2004-05-15 devnull * outline of the path. Since unrecognized tokens are ignored the last example
252 61f5c35c 2004-05-15 devnull * could also be written as,
253 61f5c35c 2004-05-15 devnull *
254 61f5c35c 2004-05-15 devnull * with gray .9 fill then stroke
255 61f5c35c 2004-05-15 devnull *
256 61f5c35c 2004-05-15 devnull * The "with" and "then" strings aren't recognized tokens and are simply discarded.
257 61f5c35c 2004-05-15 devnull * The "stroke", "fill", and "wfill" force out appropriate PostScript code and are
258 61f5c35c 2004-05-15 devnull * followed by a grestore. In otherwords changes to the grahics state (eg. a gray
259 61f5c35c 2004-05-15 devnull * level or color) are reset to default values immediately after the stroke, fill,
260 61f5c35c 2004-05-15 devnull * or wfill tokens. For now "fill" gets invokes PostScript's eofill operator and
261 61f5c35c 2004-05-15 devnull * "wfill" calls fill (ie. the operator that uses the non-zero winding rule).
262 61f5c35c 2004-05-15 devnull *
263 61f5c35c 2004-05-15 devnull * The tokens that cause temporary changes to the graphics state are "gray" (for
264 61f5c35c 2004-05-15 devnull * setting the gray level), "color" (for selecting a known color from the colordict
265 61f5c35c 2004-05-15 devnull * dictionary defined in *colorfile), and "line" (for setting the line width). All
266 61f5c35c 2004-05-15 devnull * three tokens can be extended since strncmp() makes the comparison. For example
267 61f5c35c 2004-05-15 devnull * the strings "line" and "linewidth" accomplish the same thing. Colors are named
268 61f5c35c 2004-05-15 devnull * (eg. "red"), but must be appropriately defined in *colorfile. For now all three
269 61f5c35c 2004-05-15 devnull * tokens must be followed immediately by their single argument. The gray level
270 61f5c35c 2004-05-15 devnull * (ie. the argument that follows "gray") should be a number between 0 and 1, with
271 61f5c35c 2004-05-15 devnull * 0 for black and 1 for white.
272 61f5c35c 2004-05-15 devnull *
273 61f5c35c 2004-05-15 devnull * To pass straight PostScript through enclose the appropriate commands in double
274 61f5c35c 2004-05-15 devnull * quotes. Straight PostScript is only bracketed by the outermost gsave/grestore
275 61f5c35c 2004-05-15 devnull * pair (ie. the one from the initial "x X BeginPath") although that's probably
276 61f5c35c 2004-05-15 devnull * a mistake. Suspect I may have to change the double quote delimiters.
277 61f5c35c 2004-05-15 devnull *
278 61f5c35c 2004-05-15 devnull */
279 61f5c35c 2004-05-15 devnull
280 61f5c35c 2004-05-15 devnull for( ; p != nil ; p = q ) {
281 61f5c35c 2004-05-15 devnull if( q = strchr(p, ' ') ) {
282 61f5c35c 2004-05-15 devnull *q++ = '\0';
283 61f5c35c 2004-05-15 devnull }
284 61f5c35c 2004-05-15 devnull
285 61f5c35c 2004-05-15 devnull if ( gsavelevel == 0 ) {
286 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "gsave\n");
287 61f5c35c 2004-05-15 devnull gsavelevel++;
288 61f5c35c 2004-05-15 devnull }
289 61f5c35c 2004-05-15 devnull if ( strcmp(p, "stroke") == 0 ) {
290 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "closepath stroke\ngrestore\n");
291 61f5c35c 2004-05-15 devnull gsavelevel--;
292 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "openstroke") == 0 ) {
293 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "stroke\ngrestore\n");
294 61f5c35c 2004-05-15 devnull gsavelevel--;
295 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "fill") == 0 ) {
296 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "eofill\ngrestore\n");
297 61f5c35c 2004-05-15 devnull gsavelevel--;
298 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "wfill") == 0 ) {
299 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "fill\ngrestore\n");
300 61f5c35c 2004-05-15 devnull gsavelevel--;
301 61f5c35c 2004-05-15 devnull } else if ( strcmp(p, "sfill") == 0 ) {
302 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "eofill\ngrestore\ngsave\nstroke\ngrestore\n");
303 61f5c35c 2004-05-15 devnull gsavelevel--;
304 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "gray", strlen("gray")) == 0 ) {
305 61f5c35c 2004-05-15 devnull if( q ) {
306 61f5c35c 2004-05-15 devnull p = q;
307 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
308 61f5c35c 2004-05-15 devnull *q++ = '\0';
309 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s setgray\n", p);
310 61f5c35c 2004-05-15 devnull }
311 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "color", strlen("color")) == 0 ) {
312 61f5c35c 2004-05-15 devnull if( q ) {
313 61f5c35c 2004-05-15 devnull p = q;
314 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
315 61f5c35c 2004-05-15 devnull *q++ = '\0';
316 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "/%s setcolor\n", p);
317 61f5c35c 2004-05-15 devnull }
318 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "line", strlen("line")) == 0 ) {
319 61f5c35c 2004-05-15 devnull if( q ) {
320 61f5c35c 2004-05-15 devnull p = q;
321 61f5c35c 2004-05-15 devnull if ( q = strchr(p, ' ') )
322 61f5c35c 2004-05-15 devnull *q++ = '\0';
323 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s resolution mul 2 div setlinewidth\n", p);
324 61f5c35c 2004-05-15 devnull }
325 61f5c35c 2004-05-15 devnull } else if ( strncmp(p, "reverse", strlen("reverse")) == 0 )
326 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "reversepath\n");
327 61f5c35c 2004-05-15 devnull else if ( *p == '"' ) {
328 61f5c35c 2004-05-15 devnull for ( ; gsavelevel > 0; gsavelevel-- )
329 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
330 61f5c35c 2004-05-15 devnull if ( q != nil )
331 61f5c35c 2004-05-15 devnull *--q = ' ';
332 61f5c35c 2004-05-15 devnull if ( (q = strchr(p, '"')) != nil ) {
333 61f5c35c 2004-05-15 devnull *q++ = '\0';
334 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "%s\n", p);
335 61f5c35c 2004-05-15 devnull }
336 61f5c35c 2004-05-15 devnull }
337 61f5c35c 2004-05-15 devnull }
338 61f5c35c 2004-05-15 devnull
339 61f5c35c 2004-05-15 devnull for ( ; gsavelevel > 0; gsavelevel-- )
340 61f5c35c 2004-05-15 devnull Bprint(Bstdout, "grestore\n");
341 61f5c35c 2004-05-15 devnull
342 61f5c35c 2004-05-15 devnull }