Share your code.
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:
npm install moore
Takes two arguments, returning an array of relative coordinates.
rangedetermines how large the neighborhood extends, and defaults to 1.
dimensionsdetermines 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 =// 2D, 1 range:===-1-1 0-1 1-1-1 0 1 0-1 1 0 1 1 1