ixfx
    Preparing search index...

    Namespace Grids

    Namespaces

    Array1d
    Array2d
    As

    Iterates over slices of the grid (eg a whole row, a whole column)

    By
    Visit

    Functions

    applyBounds

    Calculates a legal position for a cell based on grid size and bounds wrapping logic.

    asRectangles

    Generator that returns rectangles for each cell in a grid

    cellAtPoint

    Returns the cell at a specified visual coordinate or undefined if the position is outside of the grid.

    cellEquals

    Returns true if two cells equal. Returns false if either cell are undefined

    cellFromIndex

    Returns x,y from an array index.

    cellKeyString

    Returns a key string for a cell instance A key string allows comparison of instances by value rather than reference

    cellMiddle

    Returns the visual midpoint of a cell (eg. pixel coordinate)

    getLine

    Returns the cells on the line of start and end, inclusive

    getVectorFromCardinal

    Returns an { x, y } signed vector corresponding to the provided cardinal direction.

    guardGrid

    Throws an exception if any of the grid's parameters are invalid

    indexFromCell

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

    inside

    Returns true if cell coordinates are above zero and within bounds of grid

    isCell

    Returns true if cell parameter is a cell with x,y fields. Does not check validity of fields.

    isEqual

    Returns true if grids a and b are equal in value. Returns false if either parameter is undefined.

    neighbourList

    Gets a list of neighbours for cell (using neighbours), filtering results to only those that are valid neighbours (using isNeighbour)

    neighbours

    Returns neighbours for a cell. If no directions are provided, it defaults to allDirections.

    offset

    Returns a coordinate offset from start by vector amount.

    offsetCardinals

    Returns cells that correspond to the cardinal directions at a specified distance i.e. it projects a line from start cell in all cardinal directions and returns the cells at steps distance.

    randomNeighbour
    rectangleForCell

    Returns a visual rectangle of the cell, positioned from the top-left corner

    simpleLine

    Returns a list of cells from start to end.

    toArray2d
    values

    Converts an 1D or 2D array of cell coordinates into values

    Type Aliases

    Grid
    GridArray1d
    GridBoundsLogic

    Bounds logic

    • Unbounded: attempts to read beyond limits
    • Undefined: returns undefined when reading beyond limits
    • Stop: returns cell value at edge of limits
    • Wrap: Wrap-around cell positions
    GridCardinalDirection
    GridCardinalDirectionOptional
    GridCell
    GridCellAccessor

    A function that returns a value (or undefined) based on a cell

    GridCellAndValue
    GridCellSetter

    A function that sets the value of a cell.

    GridCreateVisitor
    GridIdentifyNeighbours

    Identify neighbours logic. For a given grid and origin, return a list of neighbours

    GridNeighbour
    GridNeighbourMaybe
    GridNeighbours
    GridNeighbourSelectionLogic

    Logic to select the next cell based on a list of neighbours

    GridNeighbourSelector

    Neighbour selector logic. For a given set of neighbours pick one to visit next.

    GridReadable

    Shape of a grid and a function to read values from it, based on cell location.

    GridVisitorOpts
    GridVisual
    GridWritable

    Variables

    allDirections

    Returns a list of all cardinal directions: n, ne, nw, e, s, se, sw, w

    crossDirections

    Returns a list of + shaped directions: n, e, s, w