From 18f63518ed5d7c91bcaf737924e6ccf31ad3e0d4 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Thu, 11 Oct 2012 09:51:07 +0200 Subject: [PATCH] Solve odd lineGap problem Not all cairo versions seem to round the same when an odd-width line is to be drawn at integer coordinates. So now we explicitly ask it to be drawn centered on half-odd-integer coordinates. --- board.c | 2 +- board.h | 2 +- draw.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/board.c b/board.c index b8be924..96cbd7b 100644 --- a/board.c +++ b/board.c @@ -140,7 +140,7 @@ drawHighlight (int file, int rank, int type) (squareSize + lineGap); } - DrawBorder(x,y, type); + DrawBorder(x,y, type, lineGap & 1); // pass whether lineGap is odd } int hi1X = -1, hi1Y = -1, hi2X = -1, hi2Y = -1; diff --git a/board.h b/board.h index 400fb98..5db1893 100644 --- a/board.h +++ b/board.h @@ -90,7 +90,7 @@ void DrawBlank P((AnimNr anr, int x, int y, int startColor)); void CopyRectangle P((AnimNr anr, int srcBuf, int destBuf, int srcX, int srcY, int width, int height, int destX, int destY)); void SetDragPiece P((AnimNr anr, ChessSquare piece)); void DragPieceMove P((int x, int y)); -void DrawBorder P((int x, int y, int type)); +void DrawBorder P((int x, int y, int type, int odd)); void FlashDelay P((int flash_delay)); void SwitchWindow P((void)); diff --git a/draw.c b/draw.c index ab9b693..f811dbe 100644 --- a/draw.c +++ b/draw.c @@ -525,7 +525,7 @@ DrawGrid() } void -DrawBorder (int x, int y, int type) +DrawBorder (int x, int y, int type, int odd) { cairo_t *cr; char *col; @@ -537,11 +537,11 @@ DrawBorder (int x, int y, int type) } cr = cairo_create(csBoardWindow); cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); - cairo_rectangle(cr, x, y, squareSize+lineGap, squareSize+lineGap); + cairo_rectangle(cr, x+odd/2., y+odd/2., squareSize+lineGap, squareSize+lineGap); SetPen(cr, lineGap, col, 0); cairo_stroke(cr); cairo_destroy(cr); - GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+2*lineGap, squareSize+2*lineGap); + GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+lineGap+odd, squareSize+lineGap+odd); } static int -- 1.7.0.4