Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/moore
https://github.com/hughsk/moore
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hughsk/moore
- Owner: hughsk
- License: other
- Created: 2013-06-19T04:14:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-06-21T02:07:43.000Z (over 7 years ago)
- Last Synced: 2024-10-17T16:41:16.414Z (22 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](http://i.imgur.com/BEA7pxu.jpg)](http://www.dis.anl.gov/news/HydrogenTransitionModeling.html)
## Installation ##
``` bash
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.``` javascript
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],
]
```