Skip to main content

SquareGrid

Struct SquareGrid 

Source
pub struct SquareGrid {
    pub size: Size,
    pub layout: SquareLayout,
    pub wrap_flags: WrapFlags,
}

Fields§

§size: Size§layout: SquareLayout§wrap_flags: WrapFlags

Implementations§

Source§

impl SquareGrid

Source

pub const fn new( size: Size, layout: SquareLayout, wrap_flags: WrapFlags, ) -> Self

Creates a new SquareGrid with the specified size, layout, and wrap flags.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Copy for SquareGrid

Source§

impl Grid for SquareGrid

Source§

type GridCoordinateType = Square

Internal coordinate type used by the grid. Read more
Source§

type DirectionArrayType = [Direction; 4]

Direction array type for edges or corners. Read more
Source§

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

Returns the array of edge directions for the grid. Read more
Source§

fn corner_direction_array(&self) -> Self::DirectionArrayType

Returns the array of corner directions for the grid. Read more
Source§

fn size(&self) -> Size

Returns the grid dimensions as a Size struct.
Source§

fn wrap_flags(&self) -> WrapFlags

Returns the flags that indicate how a grid/map wraps at its borders. Read more
Source§

fn center(&self) -> [f32; 2]

Get the center of the grid in pixel coordinates. Read more
Source§

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]

Get the right-top position of the grid in pixel coordinates. Read more
Source§

fn offset_to_pixel(&self, offset_coordinate: OffsetCoordinate) -> [f32; 2]

Returns the pixel coordinates of the center of the given OffsetCoordinate. Read more
Source§

fn pixel_to_offset(&self, pixel: [f32; 2]) -> OffsetCoordinate

Returns the OffsetCoordinate which contains the given pixel coordinates. Read more
Source§

fn grid_coordinate_to_cell( &self, grid_coordinate: Self::GridCoordinateType, ) -> Option<Cell>

Convert GridCoordinateType to a Cell in the grid. Read more
Source§

fn distance_to(&self, start: Cell, dest: Cell) -> i32

Computes the distance from start to dest in the grid. Read more
Source§

fn neighbor(self, center: Cell, direction: Direction) -> Option<Cell>

Returns the neighbor of center in the given direction.
Source§

fn cells_at_distance( self, center: Cell, distance: u32, ) -> impl Iterator<Item = Cell>

Returns an iterator over all grid cells that are at a distance of distance from center. Read more
Source§

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 more
Source§

fn estimate_direction(&self, start: Cell, dest: Cell) -> Option<Direction>

Determine the direction of dest relative to start. Read more
Source§

fn width(&self) -> u32

Returns the grid width in cells (number of columns).
Source§

fn height(&self) -> u32

Returns the height of the grid in cells (number of rows).
Source§

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

Returns if the grid is wrapped in the Y direction (vertical wrapping). Read more
Source§

fn cell_to_offset(&self, cell: Cell) -> OffsetCoordinate

Converts a Cell to an OffsetCoordinate. Read more
Source§

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 more
Source§

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

Checks if the given OffsetCoordinate is within the grid bounds. Read more
Source§

impl GridSize for SquareGrid

Source§

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

Get world size type of the grid based on its size.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.