mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Introduce some infrastructure to permit games' print functions to
draw dotted lines. No puzzle yet uses this, but one's about to. [originally from svn r8453]
This commit is contained in:
16
devel.but
16
devel.but
@ -2143,6 +2143,22 @@ however, that it is a hint only: the central printing system may
|
|||||||
choose to vary line thicknesses at user request or due to printer
|
choose to vary line thicknesses at user request or due to printer
|
||||||
capabilities.
|
capabilities.
|
||||||
|
|
||||||
|
\S{print-line-width} \cw{print_line_dotted()}
|
||||||
|
|
||||||
|
\c void print_line_dotted(drawing *dr, int dotted);
|
||||||
|
|
||||||
|
This function is called to toggle the drawing of dotted lines during
|
||||||
|
printing. It is not supported during drawing.
|
||||||
|
|
||||||
|
The parameter \cq{dotted} is a boolean; \cw{TRUE} means that future
|
||||||
|
lines drawn by \cw{draw_line()}, \cw{draw_circle} and
|
||||||
|
\cw{draw_polygon()} will be dotted, and \cw{FALSE} means that they
|
||||||
|
will be solid.
|
||||||
|
|
||||||
|
Some front ends may impose restrictions on the width of dotted
|
||||||
|
lines. Asking for a dotted line via this front end will override any
|
||||||
|
line width request if the front end requires it.
|
||||||
|
|
||||||
\H{drawing-frontend} The drawing API as implemented by the front end
|
\H{drawing-frontend} The drawing API as implemented by the front end
|
||||||
|
|
||||||
This section describes the drawing API in the function-pointer form
|
This section describes the drawing API in the function-pointer form
|
||||||
|
@ -283,3 +283,8 @@ void print_line_width(drawing *dr, int width)
|
|||||||
*/
|
*/
|
||||||
dr->api->line_width(dr->handle, (float)sqrt(dr->scale) * width);
|
dr->api->line_width(dr->handle, (float)sqrt(dr->scale) * width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_line_dotted(drawing *dr, int dotted)
|
||||||
|
{
|
||||||
|
dr->api->line_dotted(dr->handle, dotted);
|
||||||
|
}
|
||||||
|
@ -184,7 +184,7 @@ const struct drawing_api nestedvm_drawing = {
|
|||||||
nestedvm_blitter_save,
|
nestedvm_blitter_save,
|
||||||
nestedvm_blitter_load,
|
nestedvm_blitter_load,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, /* {begin,end}_{doc,page,puzzle} */
|
NULL, NULL, NULL, NULL, NULL, NULL, /* {begin,end}_{doc,page,puzzle} */
|
||||||
NULL, /* line_width */
|
NULL, NULL, /* line_width, line_dotted */
|
||||||
};
|
};
|
||||||
|
|
||||||
int jcallback_key_event(int x, int y, int keyval)
|
int jcallback_key_event(int x, int y, int keyval)
|
||||||
|
1
nullfe.c
1
nullfe.c
@ -36,6 +36,7 @@ int print_rgb_grey_colour(drawing *dr, float r, float g, float b, float grey)
|
|||||||
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b, int hatch)
|
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b, int hatch)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
void print_line_width(drawing *dr, int width) {}
|
void print_line_width(drawing *dr, int width) {}
|
||||||
|
void print_line_dotted(drawing *dr, int dotted) {}
|
||||||
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc) {}
|
void midend_supersede_game_desc(midend *me, char *desc, char *privdesc) {}
|
||||||
void status_bar(drawing *dr, char *text) {}
|
void status_bar(drawing *dr, char *text) {}
|
||||||
|
|
||||||
|
12
ps.c
12
ps.c
@ -231,6 +231,17 @@ static void ps_line_width(void *handle, float width)
|
|||||||
ps_printf(ps, "%g setlinewidth\n", width);
|
ps_printf(ps, "%g setlinewidth\n", width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ps_line_dotted(void *handle, int dotted)
|
||||||
|
{
|
||||||
|
psdata *ps = (psdata *)handle;
|
||||||
|
|
||||||
|
if (dotted) {
|
||||||
|
ps_printf(ps, "[ currentlinewidth 3 mul ] 0 setdash\n");
|
||||||
|
} else {
|
||||||
|
ps_printf(ps, "[ ] 0 setdash\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ps_begin_doc(void *handle, int pages)
|
static void ps_begin_doc(void *handle, int pages)
|
||||||
{
|
{
|
||||||
psdata *ps = (psdata *)handle;
|
psdata *ps = (psdata *)handle;
|
||||||
@ -321,6 +332,7 @@ static const struct drawing_api ps_drawing = {
|
|||||||
ps_end_page,
|
ps_end_page,
|
||||||
ps_end_doc,
|
ps_end_doc,
|
||||||
ps_line_width,
|
ps_line_width,
|
||||||
|
ps_line_dotted,
|
||||||
};
|
};
|
||||||
|
|
||||||
psdata *ps_init(FILE *outfile, int colour)
|
psdata *ps_init(FILE *outfile, int colour)
|
||||||
|
@ -217,6 +217,7 @@ int print_rgb_grey_colour(drawing *dr, float r, float g, float b, float grey);
|
|||||||
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b,
|
int print_rgb_hatched_colour(drawing *dr, float r, float g, float b,
|
||||||
int hatch);
|
int hatch);
|
||||||
void print_line_width(drawing *dr, int width);
|
void print_line_width(drawing *dr, int width);
|
||||||
|
void print_line_dotted(drawing *dr, int dotted);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* midend.c
|
* midend.c
|
||||||
@ -505,6 +506,7 @@ struct drawing_api {
|
|||||||
void (*end_page)(void *handle, int number);
|
void (*end_page)(void *handle, int number);
|
||||||
void (*end_doc)(void *handle);
|
void (*end_doc)(void *handle);
|
||||||
void (*line_width)(void *handle, float width);
|
void (*line_width)(void *handle, float width);
|
||||||
|
void (*line_dotted)(void *handle, int dotted);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
21
windows.c
21
windows.c
@ -225,7 +225,7 @@ struct frontend {
|
|||||||
int printoffsetx, printoffsety;
|
int printoffsetx, printoffsety;
|
||||||
float printpixelscale;
|
float printpixelscale;
|
||||||
int fontstart;
|
int fontstart;
|
||||||
int linewidth;
|
int linewidth, linedotted;
|
||||||
drawing *dr;
|
drawing *dr;
|
||||||
int xmin, ymin;
|
int xmin, ymin;
|
||||||
float puzz_scale;
|
float puzz_scale;
|
||||||
@ -493,12 +493,16 @@ static void win_set_pen(frontend *fe, int colour, int thin)
|
|||||||
float r, g, b;
|
float r, g, b;
|
||||||
int width = thin ? 0 : fe->linewidth;
|
int width = thin ? 0 : fe->linewidth;
|
||||||
|
|
||||||
|
if (fe->linedotted)
|
||||||
|
width = 0;
|
||||||
|
|
||||||
print_get_colour(fe->dr, colour, fe->printcolour, &hatch, &r, &g, &b);
|
print_get_colour(fe->dr, colour, fe->printcolour, &hatch, &r, &g, &b);
|
||||||
/*
|
/*
|
||||||
* Stroking in hatched colours is not permitted.
|
* Stroking in hatched colours is not permitted.
|
||||||
*/
|
*/
|
||||||
assert(hatch < 0);
|
assert(hatch < 0);
|
||||||
pen = CreatePen(PS_SOLID, width, RGB(r * 255, g * 255, b * 255));
|
pen = CreatePen(fe->linedotted ? PS_DOT : PS_SOLID,
|
||||||
|
width, RGB(r * 255, g * 255, b * 255));
|
||||||
} else {
|
} else {
|
||||||
pen = fe->pens[colour];
|
pen = fe->pens[colour];
|
||||||
}
|
}
|
||||||
@ -792,6 +796,17 @@ static void win_line_width(void *handle, float width)
|
|||||||
fe->linewidth = (int)(width * fe->printpixelscale);
|
fe->linewidth = (int)(width * fe->printpixelscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void win_line_dotted(void *handle, int dotted)
|
||||||
|
{
|
||||||
|
frontend *fe = (frontend *)handle;
|
||||||
|
|
||||||
|
assert(fe->drawstatus != DRAWING);
|
||||||
|
if (fe->drawstatus == NOTHING)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fe->linedotted = dotted;
|
||||||
|
}
|
||||||
|
|
||||||
static void win_begin_doc(void *handle, int pages)
|
static void win_begin_doc(void *handle, int pages)
|
||||||
{
|
{
|
||||||
frontend *fe = (frontend *)handle;
|
frontend *fe = (frontend *)handle;
|
||||||
@ -882,6 +897,7 @@ static void win_begin_puzzle(void *handle, float xm, float xc,
|
|||||||
fe->printpixelscale = scale;
|
fe->printpixelscale = scale;
|
||||||
|
|
||||||
fe->linewidth = 1;
|
fe->linewidth = 1;
|
||||||
|
fe->linedotted = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void win_end_puzzle(void *handle)
|
static void win_end_puzzle(void *handle)
|
||||||
@ -963,6 +979,7 @@ const struct drawing_api win_drawing = {
|
|||||||
win_end_page,
|
win_end_page,
|
||||||
win_end_doc,
|
win_end_doc,
|
||||||
win_line_width,
|
win_line_width,
|
||||||
|
win_line_dotted,
|
||||||
};
|
};
|
||||||
|
|
||||||
void print(frontend *fe)
|
void print(frontend *fe)
|
||||||
|
Reference in New Issue
Block a user