Another wording tweak from Helge Kreutzmann.
[sgt/puzzles] / ps.c
diff --git a/ps.c b/ps.c
index a2fd619..f6a71bb 100644 (file)
--- a/ps.c
+++ b/ps.c
@@ -35,12 +35,13 @@ static void ps_fill(psdata *ps, int colour)
     int hatch;
     float r, g, b;
 
-    print_get_colour(ps->drawing, colour, &hatch, &r, &g, &b);
+    print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b);
 
-    if (ps->colour) {
-       ps_printf(ps, "%g %g %g setrgbcolor fill\n", r, g, b);
-    } else if (hatch == HATCH_SOLID || hatch == HATCH_CLEAR) {
-       ps_printf(ps, "%d setgray fill\n", hatch == HATCH_CLEAR);
+    if (hatch < 0) {
+       if (ps->colour)
+           ps_printf(ps, "%g %g %g setrgbcolor fill\n", r, g, b);
+       else
+           ps_printf(ps, "%g setgray fill\n", r);
     } else {
        /* Clip to the region. */
        ps_printf(ps, "gsave clip\n");
@@ -77,20 +78,17 @@ static void ps_setcolour_internal(psdata *ps, int colour, char *suffix)
     int hatch;
     float r, g, b;
 
-    print_get_colour(ps->drawing, colour, &hatch, &r, &g, &b);
+    print_get_colour(ps->drawing, colour, ps->colour, &hatch, &r, &g, &b);
 
-    if (ps->colour) {
-       if (r != g || r != b)
-           ps_printf(ps, "%g %g %g setrgbcolor%s\n", r, g, b, suffix);
-       else
-           ps_printf(ps, "%g setgray%s\n", r, suffix);
-    } else {
-       /*
-        * Stroking in hatched colours is not permitted.
-        */
-       assert(hatch == HATCH_SOLID || hatch == HATCH_CLEAR);
-       ps_printf(ps, "%d setgray%s\n", hatch == HATCH_CLEAR, suffix);
-    }
+    /*
+     * Stroking in hatched colours is not permitted.
+     */
+    assert(hatch < 0);
+    
+    if (ps->colour)
+       ps_printf(ps, "%g %g %g setrgbcolor%s\n", r, g, b, suffix);
+    else
+       ps_printf(ps, "%g setgray%s\n", r, suffix);
 }
 
 static void ps_setcolour(psdata *ps, int colour)
@@ -112,7 +110,7 @@ static void ps_draw_text(void *handle, int x, int y, int fonttype,
     ps_setcolour(ps, colour);
     ps_printf(ps, "/%s findfont %d scalefont setfont\n",
              fonttype == FONT_FIXED ? "Courier" : "Helvetica",
-             fontsize, x, y);
+             fontsize);
     if (align & ALIGN_VCENTRE) {
        ps_printf(ps, "newpath 0 0 moveto (X) true charpath flattenpath"
                  " pathbbox\n"
@@ -233,6 +231,17 @@ static void ps_line_width(void *handle, float 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)
 {
     psdata *ps = (psdata *)handle;
@@ -323,6 +332,7 @@ static const struct drawing_api ps_drawing = {
     ps_end_page,
     ps_end_doc,
     ps_line_width,
+    ps_line_dotted,
 };
 
 psdata *ps_init(FILE *outfile, int colour)
@@ -334,7 +344,7 @@ psdata *ps_init(FILE *outfile, int colour)
     ps->ytop = 0;
     ps->clipped = FALSE;
     ps->hatchthick = ps->hatchspace = ps->gamewidth = ps->gameheight = 0;
-    ps->drawing = drawing_init(&ps_drawing, ps);
+    ps->drawing = drawing_new(&ps_drawing, NULL, ps);
 
     return ps;
 }