Calculates a legal position for a cell based on
grid size and bounds wrapping logic.
Returns a legal position for a cell based on grid size and bounds wrapping logic.
Generator that returns rectangles for each cell in a grid
Returns the cell at a specified visual coordinate or undefined if the position is outside of the grid.
Returns true if two cells equal. Returns false if either cell are undefined
Returns the grid cell that corresponds to a given index in a JaggedGrid. Assumes rows are stored end-to-end.
Returns a key string for a cell instance A key string allows comparison of instances by value rather than reference
Returns the visual midpoint of a cell (eg. pixel coordinate)
Returns the first cell of a grid.
Returns the cells on the line of start and end, inclusive
Returns an { x, y } signed vector corresponding to the provided cardinal direction.
Returns a string representation of the grid, handy for debugging.
Returns the index for a given cell in a UniformGrid. This is useful if a grid is stored in an array.
Returns an index for a given cell in a JaggedGrid. This is useful if a grid is stored in an array. Assumes rows are stored end-to-end.
Returns true if cell coordinates are above zero and within bounds of grid.
Returns true if cell parameter is a cell with x,y fields.
Does not check validity of fields.
Returns true if grids a and b are equal in value.
Returns false if either parameter is undefined.
Returns true if cell is a placeholder cell, i.e. has x and y as NaN.
Returns the last cell of a grid, column-wise
Returns the last cell of a grid, row-wise
Gets a list of neighbours for cell (using neighbours), filtering
results to only those that are valid neighbours (using isNeighbour)
Returns neighbours for a cell. If no directions are provided, it defaults to allDirections.
Returns a coordinate offset from start by vector amount.
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.
Returns a visual rectangle of the cell, positioned from the top-left corner
Returns a list of cells from start to end.
Tests a cell.
If grid is provided, cell will be checked that it's inside the bounds of the grid.
Throws an exception if any of the grid's parameters are invalid.
Converts an 1D or 2D array of cell coordinates into values
Returns a list of all cardinal directions: n, ne, nw, e, s, se, sw, w
Returns a list of + shaped directions: n, e, s, w
Iterates over slices of the grid (eg a whole row, a whole column)