ixfx
    Preparing search index...

    Function indexFromCell

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

    const data = [
    1, 2,
    3, 4,
    5, 6
    ];

    // Get index for cell {x: 1, y: 1} (ie. second column, second row)
    const index = indexFromCell({ rows: 2, cols: 2}, {x: 1, y: 1}); // Yields 3
    console.log(data[index]); // Yields 4

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

    cellFromIndex

    Grid

    Cell to get index for

    Logic for if we hit bounds of grid