grid-cells

stable

Computes grid cells coordinates

Usage

NPM

grid(width, height, numCellsX, numCellsY, margin)

Returns: List of numCellsX * numCellsY rectangles. [[x, y, w, h], ...]

Example

To get a grid like in the screenshot above

var grid = require('grid-cells');

var cells = grid(1024, 512, 4, 2, 10);
console.log(cells[0]); //-> [ 10, 10, 243, 241 ]

License

MIT, see LICENSE.md for details.