chiark / gitweb /
grid.c: fix size miscalculation in Floret tiling.
authorSimon Tatham <anakin@pobox.com>
Sun, 12 Apr 2020 13:37:47 +0000 (14:37 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 12 Apr 2020 13:37:47 +0000 (14:37 +0100)
A Floret grid of height h usually alternates columns of h hexagonal
florets with columns of h-1. An exception is when h=1, in which case
alternating columns of 1 and 0 florets would leave the grid
disconnected. So in that situation all columns have 1 floret in them,
and the starting y-coordinate oscillates to make the grid tile
sensibly.

However, that special case wasn't taken account of when calculating
the grid height. As a result the anomalous extra florets in the
height-1 tiling fell off the bottom of the puzzle window.

grid.c

diff --git a/grid.c b/grid.c
index 89bde187bee57f415570b947c8d696e80e4ae637..5ea37439d4f1f6cb9c894968fb68f6be659c24f9 100644 (file)
--- a/grid.c
+++ b/grid.c
@@ -2378,6 +2378,8 @@ static void grid_size_floret(int width, int height,
     *tilesize = FLORET_TILESIZE;
     *xextent = (6*px+3*qx)/2 * (width-1) + 4*qx + 2*px;
     *yextent = (5*qy-4*py) * (height-1) + 4*qy + 2*ry;
+    if (height == 1)
+        *yextent += (5*qy-4*py)/2;
 }
 
 static grid *grid_new_floret(int width, int height, const char *desc)