pub struct SquareGrid {
pub size: Size,
pub layout: SquareLayout,
pub wrap_flags: WrapFlags,
}Fields§
§size: Size§layout: SquareLayout§wrap_flags: WrapFlagsImplementations§
Source§impl SquareGrid
impl SquareGrid
Sourcepub const fn new(
size: Size,
layout: SquareLayout,
wrap_flags: WrapFlags,
) -> Self
pub const fn new( size: Size, layout: SquareLayout, wrap_flags: WrapFlags, ) -> Self
Creates a new SquareGrid with the specified size, layout, and wrap flags.
Sourcepub const fn with_resized_layout(&self, layout_size: [f32; 2]) -> Self
pub const fn with_resized_layout(&self, layout_size: [f32; 2]) -> Self
Returns a new SquareGrid with the specified layout size, keeping other properties unchanged.
Trait Implementations§
Source§impl Clone for SquareGrid
impl Clone for SquareGrid
Source§fn clone(&self) -> SquareGrid
fn clone(&self) -> SquareGrid
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SquareGrid
Source§impl Grid for SquareGrid
impl Grid for SquareGrid
Source§type GridCoordinateType = Square
type GridCoordinateType = Square
Internal coordinate type used by the grid. Read more
Source§fn with_dimensions(&self, width: u32, height: u32) -> Self
fn with_dimensions(&self, width: u32, height: u32) -> Self
Returns a new
Grid with the specified width and height, preserving all other fields from the current instance.Source§fn edge_direction_array(&self) -> Self::DirectionArrayType
fn edge_direction_array(&self) -> Self::DirectionArrayType
Returns the array of edge directions for the grid. Read more
Source§fn corner_direction_array(&self) -> Self::DirectionArrayType
fn corner_direction_array(&self) -> Self::DirectionArrayType
Returns the array of corner directions for the grid. Read more
Source§fn wrap_flags(&self) -> WrapFlags
fn wrap_flags(&self) -> WrapFlags
Returns the flags that indicate how a grid/map wraps at its borders. Read more
Source§fn left_bottom(&self) -> [f32; 2]
fn left_bottom(&self) -> [f32; 2]
Get the left-bottom position of the grid in pixel coordinates. Read more
Source§fn right_top(&self) -> [f32; 2]
fn right_top(&self) -> [f32; 2]
Get the right-top position of the grid in pixel coordinates. Read more
Source§fn offset_to_pixel(&self, offset_coordinate: OffsetCoordinate) -> [f32; 2]
fn offset_to_pixel(&self, offset_coordinate: OffsetCoordinate) -> [f32; 2]
Returns the pixel coordinates of the center of the given
OffsetCoordinate. Read moreSource§fn pixel_to_offset(&self, pixel: [f32; 2]) -> OffsetCoordinate
fn pixel_to_offset(&self, pixel: [f32; 2]) -> OffsetCoordinate
Returns the
OffsetCoordinate which contains the given pixel coordinates. Read moreSource§fn grid_coordinate_to_cell(
&self,
grid_coordinate: Self::GridCoordinateType,
) -> Option<Cell>
fn grid_coordinate_to_cell( &self, grid_coordinate: Self::GridCoordinateType, ) -> Option<Cell>
Source§fn neighbor(self, center: Cell, direction: Direction) -> Option<Cell>
fn neighbor(self, center: Cell, direction: Direction) -> Option<Cell>
Returns the neighbor of
center in the given direction.Source§fn cells_within_distance(
self,
center: Cell,
distance: u32,
) -> impl Iterator<Item = Cell>
fn cells_within_distance( self, center: Cell, distance: u32, ) -> impl Iterator<Item = Cell>
Returns an iterator over all grid cells that are within a distance of
distance from center.
This includes the center cell itself. Read moreSource§fn wrap_x(&self) -> bool
fn wrap_x(&self) -> bool
Returns if the grid is wrapped in the X direction (horizontal wrapping). Read more
Source§fn wrap_y(&self) -> bool
fn wrap_y(&self) -> bool
Returns if the grid is wrapped in the Y direction (vertical wrapping). Read more
Source§fn cell_to_offset(&self, cell: Cell) -> OffsetCoordinate
fn cell_to_offset(&self, cell: Cell) -> OffsetCoordinate
Source§fn offset_to_cell(
&self,
offset_coordinate: OffsetCoordinate,
) -> Result<Cell, String>
fn offset_to_cell( &self, offset_coordinate: OffsetCoordinate, ) -> Result<Cell, String>
Converts an
OffsetCoordinate to a Cell. If the coordinate is out of bounds, an error is returned. Read moreSource§fn normalize_offset(
&self,
offset_coordinate: OffsetCoordinate,
) -> Result<OffsetCoordinate, String>
fn normalize_offset( &self, offset_coordinate: OffsetCoordinate, ) -> Result<OffsetCoordinate, String>
Normalizes an offset coordinate to fit within the grid’s bounds. If the coordinate is out of bounds, an error is returned. Read more
Source§fn within_grid_bounds(&self, offset_coordinate: OffsetCoordinate) -> bool
fn within_grid_bounds(&self, offset_coordinate: OffsetCoordinate) -> bool
Checks if the given
OffsetCoordinate is within the grid bounds. Read moreSource§impl GridSize for SquareGrid
impl GridSize for SquareGrid
Source§fn default_size(world_size_type: WorldSizeType) -> Size
fn default_size(world_size_type: WorldSizeType) -> Size
Get the default size of the grid based on its world size type.
This is used to initialize the grid with a default size.
Source§fn world_size_type(&self) -> WorldSizeType
fn world_size_type(&self) -> WorldSizeType
Get world size type of the grid based on its size.
Auto Trait Implementations§
impl Freeze for SquareGrid
impl RefUnwindSafe for SquareGrid
impl Send for SquareGrid
impl Sync for SquareGrid
impl Unpin for SquareGrid
impl UnsafeUnpin for SquareGrid
impl UnwindSafe for SquareGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more