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
|
||||
|
||||
// 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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue