ixfx
    Preparing search index...

    Function indexFromCell

    • Returns the index for a given cell. This is useful if a grid is stored in an array.

      const data = [
      1, 2,
      3, 4,
      5, 6 ];
      const cols = 2; // Grid of 2 columns wide
      const index = indexFromCell(cols, {x: 1, y: 1});
      // Yields an index of 3
      console.log(data[index]); // Yields 4

      Bounds logic is applied to cell.x/y separately. Wrapping only ever happens in same col/row.

      Parameters

      Returns undefined | number

      cellFromIndex