Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @pelevesque/make-grid with all npm packages installed. Try it out:

var makeGrid = require("@pelevesque/make-grid")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@pelevesque/make-grid v0.0.8

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

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

Standard Style & Unit Tests

npm test

Unit Tests & Coverage

npm run cover

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 } ] ]
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free