pub struct WorldGrid {
    pub world_pos: Vec2,
    /* private fields */
}
Expand description

A sized grid with a custom pivot for translating between aligned grid points and world space.

Fields

world_pos: Vec2

Implementations

Create a grid with it’s world position set to origin.

Returns the tile position of a given tile.

A tile’s “position” refers to the bottom left point on the tile.

Returns the center point of a given tile.

Returns the position of the given tile in world space.

A tile’s “position” refers to the bottom left point on the tile.

Return’s the center of the given tile in world space.

Whether or not the given grid position is inside the grid bounds.

A grid’s bounds are determined by it’s pivot - a grid’s pivot always sits on the world origin.

Whether or not the given 2d index is inside the grid bounds.

Convert a grid point to it’s corresponding 2d index.

Returns none if the given grid point is out of bounds.

Converts from a local grid position to it’s corresponding 2d index.

This function will return out of bounds values if given out of bounds grid positions. For a bound-checked version use try_grid_to_index_2d

Convert from a 2d index to it’s corresponding grid position.

An iterator over the tile position of every tile in the grid.

A tile’s “position” refers to the bottom left point on the tile.

An iterator over the tile center of every tile in the grid.

An iterator over the tile position of every tile in the grid.

A tile’s “position” refers to the bottom left point on the tile.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.