Creates a two dimensional array arranged as a grid with x
, y
, w
, h
values on each item.
https://www.npmjs.com/package/@pelevesque/make-grid
npm install @pelevesque/make-grid
Command | Description |
---|---|
npm test or npm run test |
All Tests Below |
npm run cover |
Standard Style |
npm run standard |
Coverage |
npm run unit |
Unit Tests |
const makeGrid = require('@pelevesque/make-grid')
const numRows = 3
const numCols = 5
const cellWidth = 2
const cellHeight = 3
const grid = makeGrid(numRows, numCols, cellWidth, cellHeight)
// result
grid = [
[ { x: 0, y: 0, w: 2, h: 3 },
{ x: 2, y: 0, w: 2, h: 3 },
{ x: 4, y: 0, w: 2, h: 3 },
{ x: 6, y: 0, w: 2, h: 3 },
{ x: 8, y: 0, w: 2, h: 3 }
], [
{ x: 0, y: 3, w: 2, h: 3 },
{ x: 2, y: 3, w: 2, h: 3 },
{ x: 4, y: 3, w: 2, h: 3 },
{ x: 6, y: 3, w: 2, h: 3 },
{ x: 8, y: 3, w: 2, h: 3 }
], [
{ x: 0, y: 6, w: 2, h: 3 },
{ x: 2, y: 6, w: 2, h: 3 },
{ x: 4, y: 6, w: 2, h: 3 },
{ x: 6, y: 6, w: 2, h: 3 },
{ x: 8, y: 6, w: 2, h: 3 }
]
]