Skip pattern generation when canvas is very narrow

This commit is contained in:
arne 2024-07-20 22:45:24 +02:00
commit 4c84b63ce3

View file

@ -99,14 +99,14 @@ const scene = sync({
const [width, height] = size const [width, height] = size
// calculate available drawing area // 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 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 yPadding = (height - (yCells * cellSize)) / 2
const xLines = [...map(l => scale(l, cellSize), generateLines(yCells, xCells, cycle(ySeeds), xLineGen))] const xLines = xCells && yCells ? [...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 yLines = xCells && yCells ? [...map(l => scale(l, cellSize), generateLines(xCells, yCells, cycle(xSeeds), yLineGen))] : []
return translate( return translate(
group( group(