Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript
Branch: master

0.0.2

latest commit 1c4d6b972a
@hughsk authored
Failed to load latest commit information.
LICENSE.md first commit
README.md first commit
index.js first commit
package.json 0.0.2
test.js first commit

README.md

moore

A little module for generating Moore neighborhoods (i.e. the surrounding cells of a single cell in a grid) of arbitrary range and dimensions. Or, the blue squares for a red square:

moore

Installation

npm install moore

Usage

require('moore')(range, dimensions)

Takes two arguments, returning an array of relative coordinates.

  • range determines how large the neighborhood extends, and defaults to 1.
  • dimensions determines how many dimensions the Moore neighborhood covers - i.e. 2 will return the results for a 2D grid, and 3 will return the results for a 3D grid. May be any value above zero.
var moore = require('moore')

// 2D, 1 range:
moore(1, 2) === [
  [-1,-1], [ 0,-1], [ 1,-1],
  [-1, 0],          [ 1, 0],
  [-1, 1], [ 0, 1], [ 1, 1],
]
Something went wrong with that request. Please try again.