Skip pattern generation when canvas is very narrow
This commit is contained in:
parent
caa21e1825
commit
4c84b63ce3
1 changed files with 4 additions and 4 deletions
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue