Fix 1-pixel offset of grid lines on some cairo implementations
authorH.G. Muller <h.g.muller@hccnet.nl>
Thu, 11 Oct 2012 17:08:49 +0000 (19:08 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sun, 21 Oct 2012 09:28:22 +0000 (11:28 +0200)
draw.c
xoptions.c

diff --git a/draw.c b/draw.c
index f811dbe..8a39aeb 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -502,6 +502,7 @@ DrawGrid()
 {
   /* draws a grid starting around Nx, Ny squares starting at x,y */
   int i;
+  float odd = (lineGap & 1)/2.;
   cairo_t *cr;
 
   /* get a cairo_t */
@@ -513,8 +514,8 @@ DrawGrid()
   /* lines in X */
   for (i = 0; i < BOARD_WIDTH + BOARD_HEIGHT + 2; i++)
     {
-      cairo_move_to (cr, gridSegments[i].x1, gridSegments[i].y1);
-      cairo_line_to (cr, gridSegments[i].x2, gridSegments[i].y2);
+      cairo_move_to (cr, gridSegments[i].x1 + odd, gridSegments[i].y1 + odd);
+      cairo_line_to (cr, gridSegments[i].x2 + odd, gridSegments[i].y2 + odd);
       cairo_stroke (cr);
     }
 
@@ -541,7 +542,7 @@ DrawBorder (int x, int y, int type, int odd)
     SetPen(cr, lineGap, col, 0);
     cairo_stroke(cr);
     cairo_destroy(cr);
-    GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+lineGap+odd, squareSize+lineGap+odd);
+    GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+2*lineGap+odd, squareSize+2*lineGap+odd);
 }
 
 static int
index 2446fb0..979399a 100644 (file)
@@ -569,6 +569,7 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event)
            }
            cr = cairo_create((cairo_surface_t *) graph->textValue);
            cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0);
+           cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
            cairo_rectangle(cr, ((XExposeEvent*)event)->x, ((XExposeEvent*)event)->y, ((XExposeEvent*)event)->width, ((XExposeEvent*)event)->height);
            cairo_fill(cr);
            cairo_destroy(cr);