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(