The type of the properties of the grid cells.
Initializes a new instance of the grid.
The size of the grid along the x-axis.
Optional
ySize: numberThe size of the grid along the y-axis. Defaults to xSize
.
Optional
starterProps: PropertiesType | ((grid: GridCell<PropertiesType>) => PropertiesType)The properties to initialize with.
Gets an array containing all cells in the grid.
Use getAll instead.
Gets an array containing all cells that have the same x coordinate.
The x coordinate to check.
Use getAllX instead.
Gets an array containing all cells that have the same y coordinate.
The y coordinate to check.
Use getAllY instead.
Represents the cells of the grid.
Gets a cell.
The x coordinate to check.
The y coordinate to check.
Whether to allow overflow. Defaults to true
.
Use getCell instead.
Sets the value of a cell in the grid.
The x-coordinate of the cell.
The y-coordinate of the cell.
The value to set for the cell.
Use setCell instead.
The size of the grid along the x-axis.
The size of the grid along the x-axis.
Gets an array containing all cells orthogonally adjacent to a specific cell.
The x coordinate to check.
The y coordinate to check.
The distance to check. Defaults to 1
.
Whether to fill the adjacent cells. Defaults to false
.
Whether to allow overflow. Defaults to true
.
Gets an array containing all cells in the grid.
Gets an array containing all cells that have the same x coordinate.
The x coordinate to check.
Gets an array containing all cells that have the same y coordinate.
The y coordinate to check.
Gets a cell.
The x coordinate to check.
The y coordinate to check.
Whether to allow overflow. Defaults to true
.
Gets an array containing all cells diagonally adjacent from a specific cell.
The x coordinate to check.
The y coordinate to check.
The distance to check. Defaults to 1
.
Whether to fill the diagonal. Defaults to false
.
Whether to allow overflow. Defaults to true
.
Gets an array containing all cells that surround a cell.
The x coordinate to check.
The y coordinate to check.
The distance to check. Defaults to 1
.
Whether to fill the surrounding cells. Defaults to false
.
Whether to allow overflow. Defaults to true
.
Resizes the grid. Merges the cells if the new grid is bigger and truncates the cells if the new grid is smaller.
The new size of the grid along the x-axis.
Optional
ySize: numberThe new size of the grid along the y-axis. Defaults to xSize
.
Sets the value of a cell in the grid.
The x-coordinate of the cell.
The y-coordinate of the cell.
The value to set for the cell.
Static
getCalculates the distance between two points on the grid.
The x-coordinate of the first point.
The y-coordinate of the first point.
The x-coordinate of the second point.
The y-coordinate of the second point.
The distance between the two points.
Static
get
Represents a grid with cells.