UNPKG

@thi.ng/grid-iterators

Version:

2D grid and shape iterators w/ multiple orderings

13 lines (12 loc) 242 B
const isOnDiagonal = ([x, y], n) => { const d = (x + y) / n | 0; return y === d * n - x; }; const isOnDiagonalAlt = ([x, y], N) => { const d = (x - y) / N | 0; return -y === d * N - x; }; export { isOnDiagonal, isOnDiagonalAlt };