From 6341a1e8f282d099affed789a69bad4660fe9cdc Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 21 Apr 2016 22:14:00 +0200 Subject: [PATCH] Allow transparency in board textures Rather than coloring the square evenly OR rendering a board texture cutout we now always do both. Drawing the color will then erase anything that was on the square before, which is expected behavior, and will then remain visible where the texture is transparent. Before any transparency in the texture would leave the old square content (pieces, arrows, markers) visible. --- draw.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/draw.c b/draw.c index 874fcd8..5eb6baa 100644 --- a/draw.c +++ b/draw.c @@ -759,13 +759,7 @@ BlankSquare (cairo_surface_t *dest, int x, int y, int color, ChessSquare piece, cr = cairo_create (dest); - if ((useTexture & color+1) && CutOutSquare(x, y, &x0, &y0, color)) { - cairo_set_source_surface (cr, pngBoardBitmap[color], x*fac - x0, y*fac - y0); - cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); - cairo_rectangle (cr, x*fac, y*fac, squareSize, squareSize); - cairo_fill (cr); - cairo_destroy (cr); - } else { // evenly colored squares + { // evenly colored squares char *col = NULL; switch (color) { case 0: col = appData.darkSquareColor; break; @@ -777,8 +771,14 @@ BlankSquare (cairo_surface_t *dest, int x, int y, int color, ChessSquare piece, cairo_rectangle (cr, fac*x, fac*y, squareSize, squareSize); cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); cairo_fill (cr); - cairo_destroy (cr); } + if ((useTexture & color+1) && CutOutSquare(x, y, &x0, &y0, color)) { + cairo_set_source_surface (cr, pngBoardBitmap[color], x*fac - x0, y*fac - y0); + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_rectangle (cr, x*fac, y*fac, squareSize, squareSize); + cairo_fill (cr); + } + cairo_destroy (cr); } static void -- 1.7.0.4