@pelevesque/make-grid

0.0.9 • Public • Published

Build Status Coverage Status JavaScript Style Guide

make-grid

Creates a two dimensional array arranged as a grid with x, y, w, h values on each item.

Node Repository

https://www.npmjs.com/package/@pelevesque/make-grid

Installation

npm install @pelevesque/make-grid

Tests

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

Usage

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 }
  ]
]

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i @pelevesque/make-grid

    Weekly Downloads

    0

    Version

    0.0.9

    License

    MIT

    Unpacked Size

    6.37 kB

    Total Files

    6

    Last publish

    Collaborators

    • pelevesque