mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-12-23 04:32:05 +02:00
postscript.c: move drawing part of ps_pad_name and ps_pad to separate functions
For sharing.
This commit is contained in:
parent
57dbeb1aad
commit
238830c02d
50
postscript.c
50
postscript.c
@ -189,18 +189,26 @@ static void ps_string(FILE *file, const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----- Items ------------------------------------------------------------- */
|
static void ps_filled_box(FILE *file, struct coord a, struct coord b,
|
||||||
|
const char *pattern)
|
||||||
|
|
||||||
static void ps_pad_name(FILE *file, const struct inst *inst)
|
|
||||||
{
|
{
|
||||||
struct coord a = inst->base;
|
fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
|
||||||
struct coord b = inst->u.pad.other;
|
fprintf(file, " %d %d moveto\n", a.x, a.y);
|
||||||
const char *s;
|
fprintf(file, " %d %d lineto\n", b.x, a.y);
|
||||||
|
fprintf(file, " %d %d lineto\n", b.x, b.y);
|
||||||
|
fprintf(file, " %d %d lineto\n", a.x, b.y);
|
||||||
|
fprintf(file, " closepath gsave %s grestore stroke\n", pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ps_outlined_text_in_rect(FILE *file, const char *s,
|
||||||
|
struct coord a, struct coord b)
|
||||||
|
{
|
||||||
|
const char *t;
|
||||||
unit_type h, w;
|
unit_type h, w;
|
||||||
|
|
||||||
for (s = inst->u.pad.name; *s == ' '; s++);
|
for (t = s; *t == ' '; t++);
|
||||||
if (!*s)
|
if (!*t)
|
||||||
return;
|
return;
|
||||||
h = a.y-b.y;
|
h = a.y-b.y;
|
||||||
w = a.x-b.x;
|
w = a.x-b.x;
|
||||||
@ -210,16 +218,26 @@ static void ps_pad_name(FILE *file, const struct inst *inst)
|
|||||||
w = -w;
|
w = -w;
|
||||||
fprintf(file, "0 setgray /Helvetica-Bold findfont dup\n");
|
fprintf(file, "0 setgray /Helvetica-Bold findfont dup\n");
|
||||||
fprintf(file, " ");
|
fprintf(file, " ");
|
||||||
ps_string(file, inst->u.pad.name);
|
ps_string(file, s);
|
||||||
fprintf(file, " %d %d\n", w/2, h/2);
|
fprintf(file, " %d %d\n", w/2, h/2);
|
||||||
fprintf(file, " boxfont\n");
|
fprintf(file, " boxfont\n");
|
||||||
fprintf(file, " %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2);
|
fprintf(file, " %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2);
|
||||||
fprintf(file, " ");
|
fprintf(file, " ");
|
||||||
ps_string(file, inst->u.pad.name);
|
ps_string(file, s);
|
||||||
fprintf(file, " center %d showoutlined newpath\n", PS_FONT_OUTLINE);
|
fprintf(file, " center %d showoutlined newpath\n", PS_FONT_OUTLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- Items ------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
static void ps_pad_name(FILE *file, const struct inst *inst)
|
||||||
|
{
|
||||||
|
ps_outlined_text_in_rect(file, inst->u.pad.name,
|
||||||
|
inst->base, inst->u.pad.other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *hatch(layer_type layers)
|
static const char *hatch(layer_type layers)
|
||||||
{
|
{
|
||||||
switch (layers_to_pad_type(layers)) {
|
switch (layers_to_pad_type(layers)) {
|
||||||
@ -241,15 +259,7 @@ static const char *hatch(layer_type layers)
|
|||||||
|
|
||||||
static void ps_pad(FILE *file, const struct inst *inst, int show_name)
|
static void ps_pad(FILE *file, const struct inst *inst, int show_name)
|
||||||
{
|
{
|
||||||
struct coord a = inst->base;
|
ps_filled_box(file, inst->base, inst->u.pad.other,
|
||||||
struct coord b = inst->u.pad.other;
|
|
||||||
|
|
||||||
fprintf(file, "0 setgray %d setlinewidth\n", PS_HATCH_LINE);
|
|
||||||
fprintf(file, " %d %d moveto\n", a.x, a.y);
|
|
||||||
fprintf(file, " %d %d lineto\n", b.x, a.y);
|
|
||||||
fprintf(file, " %d %d lineto\n", b.x, b.y);
|
|
||||||
fprintf(file, " %d %d lineto\n", a.x, b.y);
|
|
||||||
fprintf(file, " closepath gsave %s grestore stroke\n",
|
|
||||||
hatch(inst->u.pad.layers));
|
hatch(inst->u.pad.layers));
|
||||||
|
|
||||||
if (show_name && !inst->u.pad.hole)
|
if (show_name && !inst->u.pad.hole)
|
||||||
|
Loading…
Reference in New Issue
Block a user