Created
September 16, 2010 13:25
-
-
Save otar/582414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array_nbr(row_idx, column_idx, rows, columns, level) | |
{ | |
level = level || 1; | |
var nbr = []; | |
for (var y = Math.max(0, row_idx - level); y <= Math.min(row_idx + level, rows); y++) | |
{ | |
for (var x = Math.max(0, column_idx - level); x <= Math.min(column_idx + level, columns); x++) | |
{ | |
nbr.push([x, y]); | |
} | |
} | |
return nbr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment