Created
June 19, 2022 14:05
-
-
Save computercam/75401a526bd369e9697ac3966077ac26 to your computer and use it in GitHub Desktop.
Revisions
-
computercam created this gist
Jun 19, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ export function getGrid (size) { const length = Math.pow(size, 2) const offset = (size / 2) * -1 const grid = Array.from({ length }).map((_, index, array) => { const row = Math.floor(index / size) const column = index % size const x = row + offset + 0.5 const y = column + offset + 0.5 const i = index + 1 const r = array.length - index return { x, y, i, r, row, column } }) return grid }