chiark / gitweb /
draw_polygon() and draw_circle() have always had a portability
authorSimon Tatham <anakin@pobox.com>
Sun, 3 Jul 2005 09:35:29 +0000 (09:35 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 3 Jul 2005 09:35:29 +0000 (09:35 +0000)
constraint: because some front ends interpret `draw filled shape' to
mean `including its boundary' while others interpret it to mean `not
including its boundary' (and X seems to vacillate between the two
opinions as it moves around the shape!), you MUST NOT draw a filled
shape only. You can fill in one colour and outline in another, you
can fill or outline in the same colour, or you can just outline, but
just filling is a no-no.

This leads to a _lot_ of double calls to these functions, so I've
changed the interface. draw_circle() and draw_polygon() now each
take two colour arguments, a fill colour (which can be -1 for none)
and an outline colour (which must be valid). This should simplify
code in the game back ends, while also reducing the possibility for
coding error.

[originally from svn r6047]

16 files changed:
cube.c
fifteen.c
flip.c
gtk.c
guess.c
mines.c
net.c
netslide.c
osx.m
pattern.c
puzzles.h
samegame.c
sixteen.c
solo.c
twiddle.c
windows.c

diff --git a/cube.c b/cube.c
index cf5e512f1df96b7a0219bd3ff002d1ae311f96c7..6a867a47c8c387971a9967f2247a40689d73011a 100644 (file)
--- a/cube.c
+++ b/cube.c
@@ -1568,9 +1568,9 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
                             + ds->oy);
         }
 
-        draw_polygon(fe, coords, state->squares[i].npoints, TRUE,
-                     state->squares[i].blue ? COL_BLUE : COL_BACKGROUND);
-        draw_polygon(fe, coords, state->squares[i].npoints, FALSE, COL_BORDER);
+        draw_polygon(fe, coords, state->squares[i].npoints,
+                     state->squares[i].blue ? COL_BLUE : COL_BACKGROUND,
+                    COL_BORDER);
     }
 
     /*
@@ -1650,9 +1650,9 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
                 continue;
         }
 
-        draw_polygon(fe, coords, poly->order, TRUE,
-                     state->facecolours[i] ? COL_BLUE : COL_BACKGROUND);
-        draw_polygon(fe, coords, poly->order, FALSE, COL_BORDER);
+        draw_polygon(fe, coords, poly->order,
+                     state->facecolours[i] ? COL_BLUE : COL_BACKGROUND,
+                    COL_BORDER);
     }
     sfree(poly);
 
index bd791eae7b6d474f1fba39a745176571d2e99f4f..6f75514f069c74efc054f184ccce644c2ccba631 100644 (file)
--- a/fifteen.c
+++ b/fifteen.c
@@ -654,13 +654,11 @@ static void draw_tile(frontend *fe, game_drawstate *ds, game_state *state,
         coords[3] = y;
         coords[4] = x;
         coords[5] = y + TILE_SIZE - 1;
-        draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 3, COL_LOWLIGHT, COL_LOWLIGHT);
 
         coords[0] = x;
         coords[1] = y;
-        draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
                   TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -709,13 +707,11 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
         coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
         coords[6] = coords[8] + TILE_SIZE;
         coords[7] = coords[9] - TILE_SIZE;
-        draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
         coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
-        draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
 
         ds->started = TRUE;
     }
diff --git a/flip.c b/flip.c
index 9ad3eb234c169b6f3fb31767b067be1fca1523fc..1d7c4f59553c44af02d5f5fb2335e19e13e44e49 100644 (file)
--- a/flip.c
+++ b/flip.c
@@ -1059,8 +1059,7 @@ static void draw_tile(frontend *fe, game_drawstate *ds,
        if (animtime < 0.5)
            colour = COL_WRONG + COL_RIGHT - colour;
 
-       draw_polygon(fe, coords, 4, TRUE, colour);
-       draw_polygon(fe, coords, 4, FALSE, COL_GRID);
+       draw_polygon(fe, coords, 4, colour, COL_GRID);
     }
 
     /*
diff --git a/gtk.c b/gtk.c
index ef795a4ea4bf87d966002f0633f6d2314f2f50d2..1a79f0ef3571c8dab9d6bb66240a5cbc9a18cf96 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -348,7 +348,7 @@ void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
 }
 
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour)
+                  int fillcolour, int outlinecolour)
 {
     GdkPoint *points = snewn(npoints, GdkPoint);
     int i;
@@ -358,19 +358,32 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
         points[i].y = coords[i*2+1];
     }
 
-    gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
-    gdk_draw_polygon(fe->pixmap, fe->gc, fill, points, npoints);
+    if (fillcolour >= 0) {
+       gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+       gdk_draw_polygon(fe->pixmap, fe->gc, TRUE, points, npoints);
+    }
+    assert(outlinecolour >= 0);
+    gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+    gdk_draw_polygon(fe->pixmap, fe->gc, FALSE, points, npoints);
 
     sfree(points);
 }
 
 void draw_circle(frontend *fe, int cx, int cy, int radius,
-                 int fill, int colour)
+                 int fillcolour, int outlinecolour)
 {
-    gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
-    gdk_draw_arc(fe->pixmap, fe->gc, fill,
-                 cx - radius, cy - radius,
-                 2 * radius, 2 * radius, 0, 360 * 64);
+    if (fillcolour >= 0) {
+       gdk_gc_set_foreground(fe->gc, &fe->colours[fillcolour]);
+       gdk_draw_arc(fe->pixmap, fe->gc, TRUE,
+                    cx - radius, cy - radius,
+                    2 * radius, 2 * radius, 0, 360 * 64);
+    }
+
+    assert(outlinecolour >= 0);
+    gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
+    gdk_draw_arc(fe->pixmap, fe->gc, FALSE,
+                cx - radius, cy - radius,
+                2 * radius, 2 * radius, 0, 360 * 64);
 }
 
 struct blitter {
diff --git a/guess.c b/guess.c
index 12d8b1b3ad6be70483dccd87381946b20e9706f6..9b94123bbbe59eb82bf14979c21b537a81bd8b9d 100644 (file)
--- a/guess.c
+++ b/guess.c
@@ -1021,8 +1021,8 @@ static void draw_peg(frontend *fe, game_drawstate *ds, int cx, int cy,
         draw_rect(fe, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2,
                   COL_BACKGROUND);
     if (PEGRAD > 0) {
-        draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD, 1, COL_EMPTY + col);
-        draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD, 0, COL_EMPTY + col);
+        draw_circle(fe, cx+PEGRAD, cy+PEGRAD, PEGRAD,
+                   COL_EMPTY + col, COL_EMPTY + col);
     } else
         draw_rect(fe, cx, cy, PEGSZ, PEGSZ, COL_EMPTY + col);
     draw_update(fe, cx-CGAP, cy-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
@@ -1030,7 +1030,7 @@ static void draw_peg(frontend *fe, game_drawstate *ds, int cx, int cy,
 
 static void draw_cursor(frontend *fe, game_drawstate *ds, int x, int y)
 {
-    draw_circle(fe, x+PEGRAD, y+PEGRAD, PEGRAD+CGAP, 0, COL_CURSOR);
+    draw_circle(fe, x+PEGRAD, y+PEGRAD, PEGRAD+CGAP, -1, COL_CURSOR);
 
     draw_update(fe, x-CGAP, y-CGAP, PEGSZ+CGAP*2, PEGSZ+CGAP*2);
 }
@@ -1129,8 +1129,7 @@ static void hint_redraw(frontend *fe, game_drawstate *ds, int guess,
                 rowy += HINTOFF;
             }
             if (HINTRAD > 0) {
-                draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, 1, col);
-                draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, 0, col);
+                draw_circle(fe, rowx+HINTRAD, rowy+HINTRAD, HINTRAD, col, col);
             } else {
                 draw_rect(fe, rowx, rowy, HINTSZ, HINTSZ, col);
             }
diff --git a/mines.c b/mines.c
index 6cfb634bd5dbc83b02c7552a0678748a56f833bf..7597d072c194287d32f90fb02dbda85071ae8fea 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -2751,13 +2751,12 @@ static void draw_tile(frontend *fe, game_drawstate *ds,
            coords[3] = y;
            coords[4] = x;
            coords[5] = y + TILE_SIZE - 1;
-           draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT ^ hl);
-           draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT ^ hl);
+           draw_polygon(fe, coords, 3, COL_LOWLIGHT ^ hl, COL_LOWLIGHT ^ hl);
 
            coords[0] = x;
            coords[1] = y;
-           draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT ^ hl);
-           draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT ^ hl);
+           draw_polygon(fe, coords, 3, COL_HIGHLIGHT ^ hl,
+                        COL_HIGHLIGHT ^ hl);
 
            draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
                      TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -2778,14 +2777,12 @@ static void draw_tile(frontend *fe, game_drawstate *ds,
            SETCOORD(3, 0.25, 0.8);
            SETCOORD(4, 0.55, 0.7);
            SETCOORD(5, 0.55, 0.35);
-           draw_polygon(fe, coords, 6, TRUE, COL_FLAGBASE);
-           draw_polygon(fe, coords, 6, FALSE, COL_FLAGBASE);
+           draw_polygon(fe, coords, 6, COL_FLAGBASE, COL_FLAGBASE);
 
            SETCOORD(0, 0.6, 0.2);
            SETCOORD(1, 0.6, 0.5);
            SETCOORD(2, 0.2, 0.35);
-           draw_polygon(fe, coords, 3, TRUE, COL_FLAG);
-           draw_polygon(fe, coords, 3, FALSE, COL_FLAG);
+           draw_polygon(fe, coords, 3, COL_FLAG, COL_FLAG);
 #undef SETCOORD
 
        } else if (v == -3) {
@@ -2863,8 +2860,7 @@ static void draw_tile(frontend *fe, game_drawstate *ds,
                    xdy = -tdy;
                }
 
-               draw_polygon(fe, coords, 5*4, TRUE, COL_MINE);
-               draw_polygon(fe, coords, 5*4, FALSE, COL_MINE);
+               draw_polygon(fe, coords, 5*4, COL_MINE, COL_MINE);
 
                draw_rect(fe, cx-r/3, cy-r/3, r/3, r/4, COL_HIGHLIGHT);
            }
@@ -2929,13 +2925,11 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
         coords[9] = COORD(state->h) + OUTER_HIGHLIGHT_WIDTH - 1;
         coords[6] = coords[8] + TILE_SIZE;
         coords[7] = coords[9] - TILE_SIZE;
-        draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         coords[1] = COORD(0) - OUTER_HIGHLIGHT_WIDTH;
         coords[0] = COORD(0) - OUTER_HIGHLIGHT_WIDTH;
-        draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
 
         ds->started = TRUE;
     }
@@ -3091,7 +3085,7 @@ void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
 void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour) {}
+                  int fillcolour, int outlinecolour) {}
 void clip(frontend *fe, int x, int y, int w, int h) {}
 void unclip(frontend *fe) {}
 void start_draw(frontend *fe) {}
diff --git a/net.c b/net.c
index 767ef31d3402ab3b37195f2511335ad43ba387b9..2e867007f9c3ecc6e4d426ba4ca1f90a9c289d77 100644 (file)
--- a/net.c
+++ b/net.c
@@ -2405,8 +2405,7 @@ static void draw_tile(frontend *fe, game_state *state, game_drawstate *ds,
             points[i+1] = by+(int)(cy+ty);
         }
 
-        draw_polygon(fe, points, 4, TRUE, col);
-        draw_polygon(fe, points, 4, FALSE, COL_WIRE);
+        draw_polygon(fe, points, 4, col, COL_WIRE);
     }
 
     /*
index 236491a005de1eb4523259a2665eb53ab9acfc55..fe77794d4e23638a00cf184585bfd54a63e11544 100644 (file)
@@ -1436,8 +1436,7 @@ static void draw_tile(frontend *fe, game_drawstate *ds, game_state *state,
             points[i+1] = by+(int)(cy+ey);
         }
 
-        draw_polygon(fe, points, 4, TRUE, col);
-        draw_polygon(fe, points, 4, FALSE, COL_WIRE);
+        draw_polygon(fe, points, 4, col, COL_WIRE);
     }
 
     /*
@@ -1533,8 +1532,7 @@ static void draw_arrow(frontend *fe, game_drawstate *ds,
     POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2);   /* left concave */
     POINT(6,     TILE_SIZE / 4, TILE_SIZE / 2);   /* left corner */
 
-    draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
-    draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
+    draw_polygon(fe, coords, 7, COL_LOWLIGHT, COL_TEXT);
 }
 
 static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
diff --git a/osx.m b/osx.m
index b009cd7ab0abcff21454cfe61463b40bd3bf3ad1..c3f6d1bf1e0c57fbeac48d58911d19cb3f3866bb 100644 (file)
--- a/osx.m
+++ b/osx.m
@@ -1216,16 +1216,13 @@ struct frontend {
  * Drawing routines called by the midend.
  */
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour)
+                  int fillcolour, int outlinecolour)
 {
     NSBezierPath *path = [NSBezierPath bezierPath];
     int i;
 
     [[NSGraphicsContext currentContext] setShouldAntialias:YES];
 
-    assert(colour >= 0 && colour < fe->ncolours);
-    [fe->colours[colour] set];
-
     for (i = 0; i < npoints; i++) {
        NSPoint p = { coords[i*2] + 0.5, coords[i*2+1] + 0.5 };
        if (i == 0)
@@ -1236,30 +1233,37 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
 
     [path closePath];
 
-    if (fill)
+    if (fillcolour >= 0) {
+       assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+       [fe->colours[fillcolour] set];
        [path fill];
-    else
-       [path stroke];
+    }
+
+    assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+    [fe->colours[outlinecolour] set];
+    [path stroke];
 }
 void draw_circle(frontend *fe, int cx, int cy, int radius,
-                 int fill, int colour)
+                 int fillcolour, int outlinecolour)
 {
     NSBezierPath *path = [NSBezierPath bezierPath];
 
     [[NSGraphicsContext currentContext] setShouldAntialias:YES];
 
-    assert(colour >= 0 && colour < fe->ncolours);
-    [fe->colours[colour] set];
-
     [path appendBezierPathWithArcWithCenter:NSMakePoint(cx + 0.5, cy + 0.5)
         radius:radius startAngle:0.0 endAngle:360.0];
 
     [path closePath];
 
-    if (fill)
+    if (fillcolour >= 0) {
+       assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+       [fe->colours[fillcolour] set];
        [path fill];
-    else
-       [path stroke];
+    }
+
+    assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+    [fe->colours[outlinecolour] set];
+    [path stroke];
 }
 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
 {
index b7c5334fc36028aa985570dc67545ff0f08d2c11..7713ffd2062f427e606d7aec22b7979f262b26fe 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1215,8 +1215,6 @@ void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
                int align, int colour, char *text) {}
 void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
-void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour) {}
 void clip(frontend *fe, int x, int y, int w, int h) {}
 void unclip(frontend *fe) {}
 void start_draw(frontend *fe) {}
index 2bb90c108266f4e2af1992f0cafc2554736cb8a7..57445ab4b02d3044a101aae55521dc2ffbe639f5 100644 (file)
--- a/puzzles.h
+++ b/puzzles.h
@@ -136,9 +136,9 @@ void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
 void draw_rect(frontend *fe, int x, int y, int w, int h, int colour);
 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour);
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour);
+                  int fillcolour, int outlinecolour);
 void draw_circle(frontend *fe, int cx, int cy, int radius,
-                 int fill, int colour);
+                 int fillcolour, int outlinecolour);
 void clip(frontend *fe, int x, int y, int w, int h);
 void unclip(frontend *fe);
 void start_draw(frontend *fe);
index ed516e2cbd173236895f0aab95294fa126b15a1b..a384c0b54e1b40254b9b5ad33520f5c2e00e6bad 100644 (file)
@@ -883,13 +883,11 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
        coords[9] = COORD(state->params.h) + HIGHLIGHT_WIDTH - 1 - TILE_GAP;
        coords[6] = coords[8] + TILE_SIZE;
        coords[7] = coords[9] - TILE_SIZE;
-       draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
-       draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+       draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
        coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
        coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
-       draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
-       draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+       draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
 
        ds->started = 1;
     }
index 1b6107c2324567b5c64ee8ff95cb766fe5b6aea5..72585c17fe99f89c213bead00e625ec7df924126 100644 (file)
--- a/sixteen.c
+++ b/sixteen.c
@@ -778,13 +778,11 @@ static void draw_tile(frontend *fe, game_drawstate *ds,
         coords[3] = y;
         coords[4] = x;
         coords[5] = y + TILE_SIZE - 1;
-        draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 3, COL_LOWLIGHT, COL_LOWLIGHT);
 
         coords[0] = x;
         coords[1] = y;
-        draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
                   TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -816,8 +814,7 @@ static void draw_arrow(frontend *fe, game_drawstate *ds,
     POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2);   /* left concave */
     POINT(6,     TILE_SIZE / 4, TILE_SIZE / 2);   /* left corner */
 
-    draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
-    draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
+    draw_polygon(fe, coords, 7, COL_LOWLIGHT, COL_TEXT);
 }
 
 static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
@@ -855,13 +852,11 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
         coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
         coords[6] = coords[8] + TILE_SIZE;
         coords[7] = coords[9] - TILE_SIZE;
-        draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
         coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
-        draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
 
         /*
          * Arrows for making moves.
diff --git a/solo.c b/solo.c
index b9510e23a1a94d6152fb85fb3ae1f711bfcb6fed..cfbb869ac3e457dc1c6943dc9695c3126e3a05e7 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -2215,7 +2215,7 @@ static void draw_number(frontend *fe, game_drawstate *ds, game_state *state,
         coords[3] = cy;
         coords[4] = cx;
         coords[5] = cy+ch/2;
-        draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 3, COL_HIGHLIGHT, COL_HIGHLIGHT);
     }
 
     /* new number needs drawing? */
@@ -2438,7 +2438,7 @@ void draw_text(frontend *fe, int x, int y, int fonttype, int fontsize,
 void draw_rect(frontend *fe, int x, int y, int w, int h, int colour) {}
 void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour) {}
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour) {}
+                  int fillcolour, int outlinecolour) {}
 void clip(frontend *fe, int x, int y, int w, int h) {}
 void unclip(frontend *fe) {}
 void start_draw(frontend *fe) {}
index fc124113d5b7b99216c91a4affb0d5ab33a9879b..92f5db3806638f9231652e069e3b3e054134e8ea 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -880,29 +880,29 @@ static void draw_tile(frontend *fe, game_drawstate *ds, game_state *state,
     coords[2] = x + TILE_SIZE - 1;
     coords[3] = y;
     rotate(coords+2, rot);
-    draw_polygon(fe, coords, 3, TRUE, rot ? rot->rc : COL_LOWLIGHT);
-    draw_polygon(fe, coords, 3, FALSE, rot ? rot->rc : COL_LOWLIGHT);
+    draw_polygon(fe, coords, 3, rot ? rot->rc : COL_LOWLIGHT,
+                rot ? rot->rc : COL_LOWLIGHT);
 
     /* Bottom side. */
     coords[2] = x;
     coords[3] = y + TILE_SIZE - 1;
     rotate(coords+2, rot);
-    draw_polygon(fe, coords, 3, TRUE, rot ? rot->bc : COL_LOWLIGHT);
-    draw_polygon(fe, coords, 3, FALSE, rot ? rot->bc : COL_LOWLIGHT);
+    draw_polygon(fe, coords, 3, rot ? rot->bc : COL_LOWLIGHT,
+                rot ? rot->bc : COL_LOWLIGHT);
 
     /* Left side. */
     coords[0] = x;
     coords[1] = y;
     rotate(coords+0, rot);
-    draw_polygon(fe, coords, 3, TRUE, rot ? rot->lc : COL_HIGHLIGHT);
-    draw_polygon(fe, coords, 3, FALSE, rot ? rot->lc : COL_HIGHLIGHT);
+    draw_polygon(fe, coords, 3, rot ? rot->lc : COL_HIGHLIGHT,
+                rot ? rot->lc : COL_HIGHLIGHT);
 
     /* Top side. */
     coords[2] = x + TILE_SIZE - 1;
     coords[3] = y;
     rotate(coords+2, rot);
-    draw_polygon(fe, coords, 3, TRUE, rot ? rot->tc : COL_HIGHLIGHT);
-    draw_polygon(fe, coords, 3, FALSE, rot ? rot->tc : COL_HIGHLIGHT);
+    draw_polygon(fe, coords, 3, rot ? rot->tc : COL_HIGHLIGHT,
+                rot ? rot->tc : COL_HIGHLIGHT);
 
     /*
      * Now the main blank area in the centre of the tile.
@@ -920,8 +920,7 @@ static void draw_tile(frontend *fe, game_drawstate *ds, game_state *state,
        coords[6] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
        coords[7] = y + HIGHLIGHT_WIDTH;
        rotate(coords+6, rot);
-       draw_polygon(fe, coords, 4, TRUE, flash_colour);
-       draw_polygon(fe, coords, 4, FALSE, flash_colour);
+       draw_polygon(fe, coords, 4, flash_colour, flash_colour);
     } else {
        draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
                  TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
@@ -967,8 +966,7 @@ static void draw_tile(frontend *fe, game_drawstate *ds, game_state *state,
        coords[4] = cx - displ * ydx;
        coords[5] = cy - displ * ydy;
        rotate(coords+4, rot);
-       draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT_GENTLE);
-       draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT_GENTLE);
+       draw_polygon(fe, coords, 3, COL_LOWLIGHT_GENTLE, COL_LOWLIGHT_GENTLE);
     }
 
     coords[0] = x + TILE_SIZE/2;
@@ -1082,13 +1080,11 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
         coords[9] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
         coords[6] = coords[8] + TILE_SIZE;
         coords[7] = coords[9] - TILE_SIZE;
-        draw_polygon(fe, coords, 5, TRUE, COL_HIGHLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_HIGHLIGHT);
+        draw_polygon(fe, coords, 5, COL_HIGHLIGHT, COL_HIGHLIGHT);
 
         coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
         coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
-        draw_polygon(fe, coords, 5, TRUE, COL_LOWLIGHT);
-        draw_polygon(fe, coords, 5, FALSE, COL_LOWLIGHT);
+        draw_polygon(fe, coords, 5, COL_LOWLIGHT, COL_LOWLIGHT);
 
         ds->started = TRUE;
     }
index df3de019fc116ff97a9324bb47994dd6aead25ca..57673e151d2e5bee4716fe7466b813424c567d18 100644 (file)
--- a/windows.c
+++ b/windows.c
@@ -333,26 +333,28 @@ void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
 }
 
 void draw_circle(frontend *fe, int cx, int cy, int radius,
-                 int fill, int colour)
+                 int fillcolour, int outlinecolour)
 {
-    if (fill) {
-       HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
-       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+    assert(outlinecolour >= 0);
+
+    if (fillcolour >= 0) {
+       HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[fillcolour]);
+       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
        Ellipse(fe->hdc_bm, cx - radius, cy - radius,
                cx + radius + 1, cy + radius + 1);
        SelectObject(fe->hdc_bm, oldbrush);
        SelectObject(fe->hdc_bm, oldpen);
     } else {
-       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
-        Arc(fe->hdc_bm, cx - radius, cy - radius,
-            cx + radius + 1, cy + radius + 1,
-            cx - radius, cy, cx - radius, cy);
+       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
+       Arc(fe->hdc_bm, cx - radius, cy - radius,
+           cx + radius + 1, cy + radius + 1,
+           cx - radius, cy, cx - radius, cy);
        SelectObject(fe->hdc_bm, oldpen);
     }
 }
 
 void draw_polygon(frontend *fe, int *coords, int npoints,
-                  int fill, int colour)
+                  int fillcolour, int outlinecolour)
 {
     POINT *pts = snewn(npoints+1, POINT);
     int i;
@@ -363,14 +365,16 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
        pts[i].y = coords[j*2+1];
     }
 
-    if (fill) {
-       HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[colour]);
-       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+    assert(outlinecolour >= 0);
+
+    if (fillcolour >= 0) {
+       HBRUSH oldbrush = SelectObject(fe->hdc_bm, fe->brushes[fillcolour]);
+       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
        Polygon(fe->hdc_bm, pts, npoints);
        SelectObject(fe->hdc_bm, oldbrush);
        SelectObject(fe->hdc_bm, oldpen);
     } else {
-       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[colour]);
+       HPEN oldpen = SelectObject(fe->hdc_bm, fe->pens[outlinecolour]);
        Polyline(fe->hdc_bm, pts, npoints+1);
        SelectObject(fe->hdc_bm, oldpen);
     }