From 3aace970046b4fcc8ba128f73c70692e7cd39315 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 16 Jul 2021 10:06:35 +1000 Subject: [PATCH] Fix grid pattern offset for Konva v8 --- src/components/Grid.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Grid.js b/src/components/Grid.js index 8896cbb..8dc3018 100644 --- a/src/components/Grid.js +++ b/src/components/Grid.js @@ -51,19 +51,19 @@ function Grid({ stroke }) { const scale = gridCellPixelSize.width / 300; patternProps.fillPatternScaleX = scale; patternProps.fillPatternScaleY = scale; - patternProps.fillPatternOffsetX = gridCellPixelSize.width / 2; - patternProps.fillPatternOffsetY = gridCellPixelSize.height / 2; + patternProps.fillPatternOffsetX = gridCellPixelSize.width / scale / 2; + patternProps.fillPatternOffsetY = gridCellPixelSize.height / scale / 2; } else if (grid.type === "hexVertical") { // Hex tile pattern is 153 DPI to better fit hex tiles const scale = gridCellPixelSize.width / 153; patternProps.fillPatternScaleX = scale; patternProps.fillPatternScaleY = scale; - patternProps.fillPatternOffsetY = gridCellPixelSize.radius / 2; + patternProps.fillPatternOffsetY = gridCellPixelSize.radius / scale / 2; } else if (grid.type === "hexHorizontal") { const scale = gridCellPixelSize.height / 153; patternProps.fillPatternScaleX = scale; patternProps.fillPatternScaleY = scale; - patternProps.fillPatternOffsetY = -gridCellPixelSize.radius / 2; + patternProps.fillPatternOffsetY = -gridCellPixelSize.radius / scale / 2; patternProps.fillPatternRotation = 90; }