From 4c84b63ce3280cd0ddc9376715ef89fdf2c09b03 Mon Sep 17 00:00:00 2001 From: arne Date: Sat, 20 Jul 2024 22:45:24 +0200 Subject: [PATCH] Skip pattern generation when canvas is very narrow --- src/main.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 36c603c..810cb4b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -99,14 +99,14 @@ const scene = sync({ const [width, height] = size // calculate available drawing area - const xCells = Math.floor((width - 2 * padding * cellSize) / cellSize) + const xCells = Math.max(0, Math.floor((width - 2 * padding * cellSize) / cellSize)) const xPadding = (width - (xCells * cellSize)) / 2 - const yCells = Math.floor((height - 2 * padding * cellSize) / cellSize) + const yCells = Math.max(0, Math.floor((height - 2 * padding * cellSize) / cellSize)) const yPadding = (height - (yCells * cellSize)) / 2 - const xLines = [...map(l => scale(l, cellSize), generateLines(yCells, xCells, cycle(ySeeds), xLineGen))] - const yLines = [...map(l => scale(l, cellSize), generateLines(xCells, yCells, cycle(xSeeds), yLineGen))] + const xLines = xCells && yCells ? [...map(l => scale(l, cellSize), generateLines(yCells, xCells, cycle(ySeeds), xLineGen))] : [] + const yLines = xCells && yCells ? [...map(l => scale(l, cellSize), generateLines(xCells, yCells, cycle(xSeeds), yLineGen))] : [] return translate( group(