Struct graphics_shapes::coord::Coord

source ·
pub struct Coord {
    pub x: isize,
    pub y: isize,
}
Expand description

Represents a 2D point

Supports basic math functions

§Usage

let point = coord!(10,10);
assert_eq!(point + coord!(1.0,1.0), coord!(11, 11));
assert_eq!(point / 2.0, coord!(5,5));

let pos: Coord = (2.0, 3.0).into();
assert_eq!(pos.neg(), coord!(-2, -3));

Fields§

§x: isize§y: isize

Implementations§

source§

impl Coord

source

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

Create a new Coord, use (<number>, <number>).into() if not using isize

source

pub fn from_angle<P: Into<Coord>>( center: P, distance: usize, degrees: isize, ) -> Self

Calculate a point on a circle (where 0 is the top of the circle)

source§

impl Coord

source

pub fn distance<P: Into<Coord>>(self, rhs: P) -> usize

Distance between self and rhs

source

pub fn are_collinear<P1: Into<Coord>, P2: Into<Coord>>( self, b: P1, c: P2, ) -> bool

Returns true if self, b and c are collinear (all on a straight line)

source

pub fn is_between<P1: Into<Coord>, P2: Into<Coord>>(self, a: P1, b: P2) -> bool

Returns true if self is on a line between a and b

source

pub fn mid_point<P: Into<Coord>>(self, rhs: P) -> Coord

Point midway in between self and rhs Use lerp for other positions

source

pub fn angle_to<P: Into<Coord>>(self, rhs: P) -> isize

Angle in degrees from self to rhs 0 is the top of the circle

source

pub fn cross_product<P: Into<Coord>>(self, rhs: P) -> isize

source

pub fn dot_product<P: Into<Coord>>(self, rhs: P) -> isize

source

pub const fn perpendicular(self) -> Coord

Returns a perpendicular point

source

pub const fn abs(self) -> Coord

Returns absolute copy of point

Trait Implementations§

source§

impl<P: Into<Coord>> Add<P> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: P) -> Self::Output

Performs the + operation. Read more
source§

impl Add<f32> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: f32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<f64> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i128> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: i128) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i16> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: i16) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i32> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: i32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i64> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: i64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<i8> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: i8) -> Self::Output

Performs the + operation. Read more
source§

impl Add<isize> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: isize) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u128> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: u128) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u16> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: u16) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u32> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: u32) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u64> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: u64) -> Self::Output

Performs the + operation. Read more
source§

impl Add<u8> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: u8) -> Self::Output

Performs the + operation. Read more
source§

impl Add<usize> for Coord

source§

type Output = Coord

The resulting type after applying the + operator.
source§

fn add(self, rhs: usize) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for Coord

source§

fn clone(&self) -> Coord

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 Debug for Coord

source§

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

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

impl Default for Coord

source§

fn default() -> Coord

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

impl<'de> Deserialize<'de> for Coord

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 Div<f32> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
source§

impl Div<f64> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
source§

impl Div<i128> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i128) -> Self::Output

Performs the / operation. Read more
source§

impl Div<i16> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i16) -> Self::Output

Performs the / operation. Read more
source§

impl Div<i32> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> Self::Output

Performs the / operation. Read more
source§

impl Div<i64> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
source§

impl Div<i8> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: i8) -> Self::Output

Performs the / operation. Read more
source§

impl Div<isize> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: isize) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u128> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: u128) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u16> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: u16) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u32> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: u32) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u64> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
source§

impl Div<u8> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: u8) -> Self::Output

Performs the / operation. Read more
source§

impl Div<usize> for Coord

source§

type Output = Coord

The resulting type after applying the / operator.
source§

fn div(self, rhs: usize) -> Self::Output

Performs the / operation. Read more
source§

impl From<&(f32, f32)> for Coord

source§

fn from(nums: &(f32, f32)) -> Coord

Converts to this type from the input type.
source§

impl From<&(f64, f64)> for Coord

source§

fn from(nums: &(f64, f64)) -> Coord

Converts to this type from the input type.
source§

impl From<&(i128, i128)> for Coord

source§

fn from(nums: &(i128, i128)) -> Coord

Converts to this type from the input type.
source§

impl From<&(i16, i16)> for Coord

source§

fn from(nums: &(i16, i16)) -> Coord

Converts to this type from the input type.
source§

impl From<&(i32, i32)> for Coord

source§

fn from(nums: &(i32, i32)) -> Coord

Converts to this type from the input type.
source§

impl From<&(i64, i64)> for Coord

source§

fn from(nums: &(i64, i64)) -> Coord

Converts to this type from the input type.
source§

impl From<&(i8, i8)> for Coord

source§

fn from(nums: &(i8, i8)) -> Coord

Converts to this type from the input type.
source§

impl From<&(isize, isize)> for Coord

source§

fn from(nums: &(isize, isize)) -> Coord

Converts to this type from the input type.
source§

impl From<&(u128, u128)> for Coord

source§

fn from(nums: &(u128, u128)) -> Coord

Converts to this type from the input type.
source§

impl From<&(u16, u16)> for Coord

source§

fn from(nums: &(u16, u16)) -> Coord

Converts to this type from the input type.
source§

impl From<&(u32, u32)> for Coord

source§

fn from(nums: &(u32, u32)) -> Coord

Converts to this type from the input type.
source§

impl From<&(u64, u64)> for Coord

source§

fn from(nums: &(u64, u64)) -> Coord

Converts to this type from the input type.
source§

impl From<&(u8, u8)> for Coord

source§

fn from(nums: &(u8, u8)) -> Coord

Converts to this type from the input type.
source§

impl From<&(usize, usize)> for Coord

source§

fn from(nums: &(usize, usize)) -> Coord

Converts to this type from the input type.
source§

impl From<&Coord> for Coord

source§

fn from(value: &Coord) -> Self

Converts to this type from the input type.
source§

impl From<(f32, f32)> for Coord

source§

fn from(nums: (f32, f32)) -> Coord

Converts to this type from the input type.
source§

impl From<(f64, f64)> for Coord

source§

fn from(nums: (f64, f64)) -> Coord

Converts to this type from the input type.
source§

impl From<(i128, i128)> for Coord

source§

fn from(nums: (i128, i128)) -> Coord

Converts to this type from the input type.
source§

impl From<(i16, i16)> for Coord

source§

fn from(nums: (i16, i16)) -> Coord

Converts to this type from the input type.
source§

impl From<(i32, i32)> for Coord

source§

fn from(nums: (i32, i32)) -> Coord

Converts to this type from the input type.
source§

impl From<(i64, i64)> for Coord

source§

fn from(nums: (i64, i64)) -> Coord

Converts to this type from the input type.
source§

impl From<(i8, i8)> for Coord

source§

fn from(nums: (i8, i8)) -> Coord

Converts to this type from the input type.
source§

impl From<(isize, isize)> for Coord

source§

fn from(nums: (isize, isize)) -> Coord

Converts to this type from the input type.
source§

impl From<(u128, u128)> for Coord

source§

fn from(nums: (u128, u128)) -> Coord

Converts to this type from the input type.
source§

impl From<(u16, u16)> for Coord

source§

fn from(nums: (u16, u16)) -> Coord

Converts to this type from the input type.
source§

impl From<(u32, u32)> for Coord

source§

fn from(nums: (u32, u32)) -> Coord

Converts to this type from the input type.
source§

impl From<(u64, u64)> for Coord

source§

fn from(nums: (u64, u64)) -> Coord

Converts to this type from the input type.
source§

impl From<(u8, u8)> for Coord

source§

fn from(nums: (u8, u8)) -> Coord

Converts to this type from the input type.
source§

impl From<(usize, usize)> for Coord

source§

fn from(nums: (usize, usize)) -> Coord

Converts to this type from the input type.
source§

impl Hash for Coord

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 Lerp for Coord

source§

fn lerp(self, end: Coord, percent: f32) -> Coord

calculate the point at percent between self and end Read more
source§

fn inv_lerp(self, end: Coord, point: Coord) -> f32

calculate the percent for point between self and end Read more
source§

impl<P: Into<Coord>> Mul<P> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: P) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f32> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f64> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i128> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i128) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i16> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i16) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i32> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i64> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<i8> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i8) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<isize> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: isize) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u128> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u128) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u16> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u16) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u32> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u32) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u64> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<u8> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: u8) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<usize> for Coord

source§

type Output = Coord

The resulting type after applying the * operator.
source§

fn mul(self, rhs: usize) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for Coord

source§

fn eq(&self, other: &Coord) -> 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 Serialize for Coord

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<P: Into<Coord>> Sub<P> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: P) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<f32> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<f64> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i128> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i128) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i16> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i16) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i32> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i64> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<i8> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: i8) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<isize> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: isize) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u128> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u128) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u16> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u16) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u32> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u32) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u64> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u64) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<u8> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: u8) -> Self::Output

Performs the - operation. Read more
source§

impl Sub<usize> for Coord

source§

type Output = Coord

The resulting type after applying the - operator.
source§

fn sub(self, rhs: usize) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for Coord

source§

impl Eq for Coord

source§

impl StructuralPartialEq for Coord

Auto Trait Implementations§

§

impl Freeze for Coord

§

impl RefUnwindSafe for Coord

§

impl Send for Coord

§

impl Sync for Coord

§

impl Unpin for Coord

§

impl UnwindSafe for Coord

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> AnyToAny for T
where T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.
source§

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