[][src]Struct chickenwire::coordinate::offset::Offset

pub struct Offset {
    pub col: i32,
    pub row: i32,
}

Offset coordinates treat the HexGrid as a square grid with offsetting indentations on the rows/columns.

Fields

col: i32row: i32

Methods

impl Offset[src]

pub const ORIGIN: Offset[src]

Offset coordinate origin of (0, 0).

pub fn from_coords(col: i32, row: i32) -> Self[src]

Create an Offset from two i32 values.

Examples

use chickenwire::coordinate::offset::Offset;

assert_eq!(
    Offset::from_coords(1, 2),
    Offset { col: 1, row: 2 }
);

pub fn oflat_to_cube(self) -> Cube[src]

Converts an Offset to a Cube, assuming the HexGrid has Parity::Odd and Tilt::Flat parameters.

pub fn eflat_to_cube(self) -> Cube[src]

Converts an Offset to a Cube, assuming the HexGrid has Parity::Even and Tilt::Flat parameters.

pub fn osharp_to_cube(self) -> Cube[src]

Converts an Offset to a Cube, assuming the HexGrid has Parity::Odd and Tilt::Sharp parameters.

pub fn esharp_to_cube(self) -> Cube[src]

Converts an Offset to a Cube, assuming the HexGrid has Parity::Even and Tilt::Sharp parameters.

pub fn oflat_neighbors(self) -> Vec<Self>[src]

Calculates the Offset coordinates of the hexes surrounding the calling instance, in the context of a HexGrid with Parity::Odd and Tilt::Flat parameters.

pub fn eflat_neighbors(self) -> Vec<Self>[src]

Calculates the Offset coordinates of the hexes surrounding the calling instance, in the context of a HexGrid with Parity::Even and Tilt::Flat parameters.

pub fn osharp_neighbors(self) -> Vec<Self>[src]

Calculates the Offset coordinates of the hexes surrounding the calling instance, in the context of a HexGrid with Parity::Odd and Tilt::Sharp parameters.

pub fn esharp_neighbors(self) -> Vec<Self>[src]

Calculates the Offset coordinates of the hexes surrounding the calling instance, in the context of a HexGrid with Parity::Even and Tilt::Sharp parameters.

pub fn dist(self, other: Self) -> i32[src]

Calculates the distance between two Offset coordinates.

Trait Implementations

impl From<(i32, i32)> for Offset[src]

Create an Offset from an (i32, i32).

impl From<MultiCoord> for Offset[src]

Create an Offset from a MultiCoord.

Panics

Panics when given a non-Offset MultiCoord.

impl From<Offset> for CoordSys[src]

Creates a CoordSys::Offset from an Offset.

impl From<Offset> for MultiCoord[src]

Creates a MultiCoord from an Offset.

impl Ord for Offset[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

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

Restrict a value to a certain interval. Read more

impl PartialOrd<Offset> for Offset[src]

impl PartialEq<Offset> for Offset[src]

impl Default for Offset[src]

impl Clone for Offset[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Eq for Offset[src]

impl Copy for Offset[src]

impl Debug for Offset[src]

impl Hash for Offset[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for Offset

impl Unpin for Offset

impl Sync for Offset

impl UnwindSafe for Offset

impl RefUnwindSafe for Offset

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<N> NodeTrait for N where
    N: Copy + Ord + Hash
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]