Prevent odd-width line shift in length direction
authorH.G. Muller <h.g.muller@hccnet.nl>
Sun, 21 Oct 2012 07:58:23 +0000 (09:58 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sun, 21 Oct 2012 09:46:35 +0000 (11:46 +0200)
draw.c

diff --git a/draw.c b/draw.c
index 7ec60ae..82c5582 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -518,8 +518,9 @@ DrawGrid()
   /* lines in X */
   for (i = 0; i < BOARD_WIDTH + BOARD_HEIGHT + 2; i++)
     {
-      cairo_move_to (cr, gridSegments[i].x1 + odd, gridSegments[i].y1 + odd);
-      cairo_line_to (cr, gridSegments[i].x2 + odd, gridSegments[i].y2 + odd);
+      int h = (gridSegments[i].y1 == gridSegments[i].y2); // horizontal
+      cairo_move_to (cr, gridSegments[i].x1 + !h*odd, gridSegments[i].y1 + h*odd);
+      cairo_line_to (cr, gridSegments[i].x2 + !h*odd, gridSegments[i].y2 + h*odd);
       cairo_stroke (cr);
     }