Struct sark_grids::grid::Grid [−][src]
pub struct Grid<T: Clone> { /* fields omitted */ }
Expand description
A dense sized grid that stores it’s elements in a Vec
.
This grid assumes that [0,0]
refers to the bottom-left most tile, and
[width -1, height -1]
refers to the top-right-most tile.
Implementations
Creates a new Grid
Creates a new Grid
An iterator over a single row of the grid.
Goes from left to right.
A mutable iterator over a single row of the grid.
Goes from left to right.
Insert into a row of the grid using an iterator.
Will insert up to the length of a row.
Insert into a row of the grid using an iterator.
Will insert up to the length of a row.
Insert into a column of the grid using an iterator.
Will insert up to the height of a column.
Insert into a column of the grid using an iterator.
Will insert up to the height of a column.
An iterator over a single column of the grid.
Goes from bottom to top.
A mutable iterator over a single column of the grid.
Goes from bottom to top.
Converts a 2d grid position to it’s corresponding 1D index.
Converts a 2d grid position to it’s corresponding 1D index.
Converts a 1d index to it’s corresponding grid position.
Converts a 1d index to it’s corresponding grid position.
Returns the index of the bottom row (0
).
Returns the index of the left-most column (0
).
Returns the index of the right-most column.
Get the position of a tile on the grid at the given pivot.
Note that for even-sized grids the “center” will be rounded down.
For example, for a a 4x4 grid calling pivot_position(Pivot::Center)
will return (1,1)
.
An iterator over a rectangular portion of the grid defined by the given range.
Yields (IVec2, &T)
, where IVec2
is the corresponding position of the value in the grid.
Returns an iterator which enumerates the 2d position of every value in the grid.
Yields (IVec2, &T)
, where IVec2
is the corresponding position of the value in the grid.
Returns a mutable iterator which enumerates the 2d position of every value in the grid.
Yields (IVec2, &mut T)
, where IVec2
is the corresponding position of the value in the grid.
Creates a crate::world_grid::WorldGrid from this grid with the given pivot. This can be used to translate between grid points and world space.
Creates a crate::world_grid::WorldGrid from this grid with the default bottom left pivot. This can be used to translate between grid points and world space.