Skip to content

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

License

Notifications You must be signed in to change notification settings

pelevesque-node/make-grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published