chiark / gitweb /
RFH: tracks: Grid line width problems
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Sep 2017 23:24:33 +0000 (00:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Sep 2017 13:27:22 +0000 (14:27 +0100)
The #define BORDER_WIDTH is not used.  It seems to have been intended
for the grid width (since there's BORDER for the actual border).

In this commit I have tried to introduce use of BORDER_WIDTH to the
four places where the grid is drawn, changing draw_line to
draw_thick_line.

I have also increased the BORDER_WIDTH value dramatically to show the
effect.  (IMO a sensible value would be TILE_SIZE/16, like
LINE_THICK, but:)

Unfortunately, the has some drawing artefacts at the corners.  And,
empirically, the grid line width which appears is about half that
which has been specified in the #define.  I guess the drawing code in
tracks contains a number of hardcoded "1" values that relate to the
grid line thickness, although of course these are hard to search for.

I find the game which results from the current setting to be somewhat
more playable than the unpatched version, and the artefacts are
cosmetic, but this change is clearly not correct (or, at least,
unfinished) and should not be applied as-is.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
tracks.c

index 4d5e7caa53daada2dfcafb9907a4d1666b7f1731..d9c50d8029cd7d1dc093cde34f5ac64a4af14c7d 100644 (file)
--- a/tracks.c
+++ b/tracks.c
@@ -1718,7 +1718,7 @@ static void game_changed_state(game_ui *ui, const game_state *oldstate,
 #define TILE_SIZE (ds->sz6*6)
 
 #define BORDER (TILE_SIZE/8)
-#define BORDER_WIDTH (max(TILE_SIZE / 32, 1))
+#define BORDER_WIDTH (TILE_SIZE/8)
 #define LINE_THICK (TILE_SIZE/16)
 
 #define COORD(x) ( (x+1) * TILE_SIZE + BORDER )
@@ -2353,8 +2353,8 @@ static void draw_square(drawing *dr, game_drawstate *ds,
     draw_rect(dr, ox, oy, TILE_SIZE, TILE_SIZE, bg);
 
     /* Draw outline of grid square */
-    draw_line(dr, ox, oy, COORD(x+1), oy, COL_GRID);
-    draw_line(dr, ox, oy, ox, COORD(y+1), COL_GRID);
+    draw_thick_line(dr, BORDER_WIDTH, ox, oy, COORD(x+1), oy, COL_GRID);
+    draw_thick_line(dr, BORDER_WIDTH, ox, oy, ox, COORD(y+1), COL_GRID);
 
     /* More outlines for clue squares. */
     if (flags & DS_CURSOR) {
@@ -2499,8 +2499,8 @@ static void game_redraw(drawing *dr, game_drawstate *ds, const game_state *oldst
 
         draw_loop_ends(dr, ds, state, COL_CLUE);
 
-        draw_line(dr, COORD(ds->w), COORD(0), COORD(ds->w), COORD(ds->h), COL_GRID);
-        draw_line(dr, COORD(0), COORD(ds->h), COORD(ds->w), COORD(ds->h), COL_GRID);
+        draw_thick_line(dr, BORDER_WIDTH, COORD(ds->w), COORD(0), COORD(ds->w), COORD(ds->h), COL_GRID);
+        draw_thick_line(dr, BORDER_WIDTH, COORD(0), COORD(ds->h), COORD(ds->w), COORD(ds->h), COL_GRID);
 
         draw_update(dr, 0, 0, (w+2)*TILE_SIZE + 2*BORDER, (h+2)*TILE_SIZE + 2*BORDER);