Type Alias Delta

Source
pub type Delta<T> = Vec2<T>;
Expand description

A type alias that semantically expresses an offset/delta.

Aliased Type§

struct Delta<T> {
    pub x: T,
    pub y: T,
}

Fields§

§x: T§y: T

Implementations

Source§

impl<T> Vec2<T>

Source

pub const fn new(x: T, y: T) -> Self

Creates a mew position.

Source

pub fn map<U>(self, f: impl FnMut(T) -> U) -> Vec2<U>

Maps a function over the vector.

Source§

impl<T> Vec2<T>
where T: Zero + Unity,

Source

pub const LEFT: Self

The vector pointing one pixel to the left.

Source

pub const UP: Self

The vector pointing one pixel up.

Source

pub const RIGHT: Self

The vector pointing one pixel to the right.

Source

pub const DOWN: Self

The vector pointing one pixel down.

Source

pub fn random_cardinal_with(rng: &mut impl Rng) -> Self

Randomly one of the four cardinal rotations with the given rng.

Source

pub fn random_cardinal() -> Self

Randomly one of the four cardinal rotations with the thread-local rng.

Source§

impl<T> Vec2<T>
where T: Add<Output = T> + Mul<Output = T> + Sqrt + Copy,

Source

pub fn length(&self) -> T

The vector’s length.

Trait Implementations

Source§

impl<T> Add for Vec2<T>
where T: Add<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vec2<T>) -> Self

Performs the + operation. Read more
Source§

impl<T> AddAssign for Vec2<T>
where T: AddAssign<T>,

Source§

fn add_assign(&mut self, rhs: Vec2<T>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Vec2<T>

Source§

fn clone(&self) -> Vec2<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Vec2<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Vec2<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for Vec2<T>
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<Direction> for Vec2<T>
where T: Zero + Unity,

Source§

fn from(direction: Direction) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Vec2<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Neg for Vec2<T>
where T: Neg<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for Vec2<T>

Source§

fn eq(&self, other: &Vec2<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Vec2<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Sub for Vec2<T>
where T: Sub<Output = T>,

Source§

type Output = Vec2<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec2<T>) -> Self

Performs the - operation. Read more
Source§

impl<T> SubAssign for Vec2<T>
where T: SubAssign<T>,

Source§

fn sub_assign(&mut self, rhs: Vec2<T>)

Performs the -= operation. Read more
Source§

impl<T> Zero for Vec2<T>
where T: Zero,

Source§

const ZERO: Self

The origin.

Source§

impl<T: Copy> Copy for Vec2<T>

Source§

impl<T: Eq> Eq for Vec2<T>

Source§

impl<T> StructuralPartialEq for Vec2<T>