ea-cellmap
Contact
- mail - earendel@wolke7.net
- chat - http://bit.ly/irc-javascript
Install
npm install ea-cellmap --save
Usage
//require modulevar CellMap = ; //init 10x10 cellsvar cell = CellMap; //set some property on any cell within rangealive = true; //get neighboured cells cellsall //get neighboured cell to the rightcellsright;
Source Code
/* git@github.com:hagb4rd/ea-cellmap.git */ var util = ; { thiscols = cols; thisrows = rows; thisitems = rows * cols;}; CellMapprototype { var self = this; i = i || 0; var cell = x: i + selfcols % selfcols y: Math index: i ; cellcells = { return -1 -10 -11 -1-1 01 0-1 10 11 1 } { return thisall0 } { return thisall1 } { return thisall2 } { return thisall3 } { return thisall4 } { return thisall5 } { return thisall6 } { return thisall7 } ; return cell;}; CellMapprototype { if !argumentslength return thisitems; x = Math; y = Math; if x < 0 || x >= thiscolt return null; if y < 0 || y >= thisrows return null; return thisitemsy * thiscols + x}; CellMap { var cellMap = cols rows; var f = cellMapfield; fcellMap = cellMap; f { return JSON }; f util; return f;}; CellMaphelp = " https://github.com/hagb4rd/ea-cellmap "; moduleexports = CellMap;