From 879a23f81af31eef72215ebf8498b4ed1c537ac5 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Wed, 4 Aug 2021 07:20:30 +1000 Subject: [PATCH] Fix resize size for hex grids --- src/components/konva/Transformer.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/konva/Transformer.tsx b/src/components/konva/Transformer.tsx index 9b12da2..a61f113 100644 --- a/src/components/konva/Transformer.tsx +++ b/src/components/konva/Transformer.tsx @@ -39,10 +39,14 @@ function Transformer({ return { x: 0, y: 0 }; } + // Use min side for hex grids + const minSize = Vector2.componentMin(gridCellPixelSize); + const size = new Vector2(minSize, minSize); + // Get grid cell size in screen coordinates const mapTransform = mapImage.getAbsoluteTransform(); const gridCellAbsoluteSize = Vector2.subtract( - mapTransform.point(gridCellPixelSize), + mapTransform.point(size), mapTransform.point({ x: 0, y: 0 }) ); return gridCellAbsoluteSize;