Expand description
Unsigned-int coordinates
Fields
x: u32y: u32Implementations
sourceimpl Coord
impl Coord
pub const ZERO: Coord = _
sourcepub fn to_2d_idx(self, width: u32) -> u32
pub fn to_2d_idx(self, width: u32) -> u32
Get this as an index into an array representing a 2d array.
(AKA, y * width + x.)
sourcepub fn neighbors4(self) -> Vec<Coord>
pub fn neighbors4(self) -> Vec<Coord>
Get a list of this coordinate’s orthagonal neighbors.
They are given in clockwise order starting with the neighbor to the north,
as if each of Direction4::DIRECTIONS had been added to them.
If a neighbor is out of bounds, it is skipped in the output.
There may be 2, 3, or 4 neighbors:
- 2 if this is at
(0, 0) - 3 if this is on an edge (
xoryare 0) - 4 otherwise.
sourcepub fn neighbors8(self) -> Vec<Coord>
pub fn neighbors8(self) -> Vec<Coord>
Get a list of this coordinate’s orthagonal and diagonal neighbors.
They are given in clockwise order starting with the neighbor to the north,
as if each of Direction8::DIRECTIONS had been added to them.
If a neighbor is out of bounds, it is skipped in the output.
There may be 3, 5, or 8 neighbors:
- 3 if this is at
(0, 0) - 5 if this is on an edge (
xoryare 0) - 8 otherwise.
Direction8::DIRECTIONS: super::Direction8::DIRECTIONS
pub fn area(self, width: u32, height: u32) -> Area
Trait Implementations
sourceimpl AddAssign<Coord> for Coord
impl AddAssign<Coord> for Coord
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the += operation. Read more
sourceimpl MulAssign<Coord> for Coord
impl MulAssign<Coord> for Coord
sourcefn mul_assign(&mut self, rhs: Coord)
fn mul_assign(&mut self, rhs: Coord)
Performs the *= operation. Read more
sourceimpl MulAssign<u32> for Coord
impl MulAssign<u32> for Coord
sourcefn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
Performs the *= operation. Read more
sourceimpl SubAssign<Coord> for Coord
impl SubAssign<Coord> for Coord
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -= operation. Read more
sourceimpl TryFrom<CoordVec> for Coord
impl TryFrom<CoordVec> for Coord
Try to convert an ICoord to a Coord. Will return Error if the ICoord has any negatives in it.
impl Copy for Coord
impl Eq for Coord
impl StructuralEq for Coord
impl StructuralPartialEq for Coord
Auto Trait Implementations
impl RefUnwindSafe for Coord
impl Send for Coord
impl Sync for Coord
impl Unpin for Coord
impl UnwindSafe for Coord
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more