• Enumerate all cell coordinates in an efficient manner. Runs left-to-right, top-to-bottom.

    If end of grid is reached, behaviour depends on wrap:

    • true (default): iterator will wrap to ensure all are visited.
    • false: iterator stops at end of grid
    import { Grids } from 'ixfx/geometry.js';

    // Enumerate each cell position, left-to-right, top-to-bottom
    for (const cell of Grids.By.cells(grid)) {
    // cell will be { x, y }
    }

    See also:

    Parameters

    • grid: Grid

      Grid to iterate over

    • Optionalstart: GridCell

      Starting cell position (default: {x:0,y:0})

    • wrap: boolean = true

      If true (default), iteration will wrap around through (0,0) when end of grid is reached.

    Returns Generator<{
        x: number;
        y: number;
    }, void, unknown>