Date: | 2012-07-19 01:24:00 (11 years 8 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 238830c02d01e0e408155ea5d89f974ed0af54f9 |
Message: | postscript.c: move drawing part of ps_pad_name and ps_pad to
separate functions For sharing. |
Files: |
postscript.c (3 diffs) |
Change Details
postscript.c | ||
---|---|---|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
192 | /* ----- Items ------------------------------------------------------------- */ | |
192 | static void ps_filled_box(FILE *file, struct coord a, struct coord b, | |
193 | const char *pattern) | |
194 | { | |
195 | fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE); | |
196 | fprintf(file, " %d %d moveto\n", a.x, a.y); | |
197 | fprintf(file, " %d %d lineto\n", b.x, a.y); | |
198 | fprintf(file, " %d %d lineto\n", b.x, b.y); | |
199 | fprintf(file, " %d %d lineto\n", a.x, b.y); | |
200 | fprintf(file, " closepath gsave %s grestore stroke\n", pattern); | |
201 | } | |
193 | 202 | |
194 | 203 | |
195 | static void ps_pad_name(FILE *file, const struct inst *inst) | |
204 | static void ps_outlined_text_in_rect(FILE *file, const char *s, | |
205 | struct coord a, struct coord b) | |
196 | 206 | { |
197 | struct coord a = inst->base; | |
198 | struct coord b = inst->u.pad.other; | |
199 | const char *s; | |
207 | const char *t; | |
200 | 208 | unit_type h, w; |
201 | 209 | |
202 | for (s = inst->u.pad.name; *s == ' '; s++); | |
203 | if (!*s) | |
210 | for (t = s; *t == ' '; t++); | |
211 | if (!*t) | |
204 | 212 | return; |
205 | 213 | h = a.y-b.y; |
206 | 214 | w = a.x-b.x; |
... | ... | |
210 | 218 | w = -w; |
211 | 219 | fprintf(file, "0 setgray /Helvetica-Bold findfont dup\n"); |
212 | 220 | fprintf(file, " "); |
213 | ps_string(file, inst->u.pad.name); | |
221 | ps_string(file, s); | |
214 | 222 | fprintf(file, " %d %d\n", w/2, h/2); |
215 | 223 | fprintf(file, " boxfont\n"); |
216 | 224 | fprintf(file, " %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2); |
217 | 225 | fprintf(file, " "); |
218 | ps_string(file, inst->u.pad.name); | |
226 | ps_string(file, s); | |
219 | 227 | fprintf(file, " center %d showoutlined newpath\n", PS_FONT_OUTLINE); |
220 | 228 | } |
221 | 229 | |
222 | 230 | |
231 | /* ----- Items ------------------------------------------------------------- */ | |
232 | ||
233 | ||
234 | static void ps_pad_name(FILE *file, const struct inst *inst) | |
235 | { | |
236 | ps_outlined_text_in_rect(file, inst->u.pad.name, | |
237 | inst->base, inst->u.pad.other); | |
238 | } | |
239 | ||
240 | ||
223 | 241 | static const char *hatch(layer_type layers) |
224 | 242 | { |
225 | 243 | switch (layers_to_pad_type(layers)) { |
... | ... | |
241 | 259 | |
242 | 260 | static void ps_pad(FILE *file, const struct inst *inst, int show_name) |
243 | 261 | { |
244 | struct coord a = inst->base; | |
245 | struct coord b = inst->u.pad.other; | |
246 | ||
247 | fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE); | |
248 | fprintf(file, " %d %d moveto\n", a.x, a.y); | |
249 | fprintf(file, " %d %d lineto\n", b.x, a.y); | |
250 | fprintf(file, " %d %d lineto\n", b.x, b.y); | |
251 | fprintf(file, " %d %d lineto\n", a.x, b.y); | |
252 | fprintf(file, " closepath gsave %s grestore stroke\n", | |
262 | ps_filled_box(file, inst->base, inst->u.pad.other, | |
253 | 263 | hatch(inst->u.pad.layers)); |
254 | 264 | |
255 | 265 | if (show_name && !inst->u.pad.hole) |
Branches:
master