Struct rten_imageproc::Point

source ·
pub struct Point<T: Coord = i32> {
    pub x: T,
    pub y: T,
}
Expand description

A point defined by X and Y coordinates.

Fields§

§x: T§y: T

Implementations§

source§

impl<T: Coord> Point<T>

source

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

Construct a point from X and Y coordinates.

source

pub fn move_to(&mut self, y: T, x: T)

Set the coordinates of this point.

source

pub fn translate(self, y: T, x: T) -> Self

source

pub fn move_by(&mut self, y: T, x: T)

source§

impl Point<f32>

source

pub fn distance(self, other: Self) -> f32

source

pub fn vec_to(self, other: Self) -> Vec2

Return the vector from this point to another point.

source

pub fn to_vec(self) -> Vec2

Return the vector from the origin to this point.

source§

impl Point<i32>

source

pub fn coord(self) -> [usize; 2]

Return self as a [y, x] array. This is useful for indexing into an image or matrix.

Panics if the X or Y coordinates of the point are negative.

source

pub fn neighbors(self) -> [Point; 8]

Return the neighbors of the current point in clockwise order, starting from the point directly above self.

source

pub fn to_f32(self) -> Point<f32>

source

pub fn distance(self, other: Point<i32>) -> f32

Trait Implementations§

source§

impl<T: Clone + Coord> Clone for Point<T>

source§

fn clone(&self) -> Point<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: Coord> Debug for Point<T>

source§

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

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

impl<T: Default + Coord> Default for Point<T>

source§

fn default() -> Point<T>

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

impl<T: PartialEq + Coord> PartialEq for Point<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Copy + Coord> Copy for Point<T>

source§

impl<T: Eq + Coord> Eq for Point<T>

source§

impl<T: Coord> StructuralPartialEq for Point<T>

Auto Trait Implementations§

§

impl<T> Freeze for Point<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Point<T>
where T: RefUnwindSafe,

§

impl<T> Send for Point<T>
where T: Send,

§

impl<T> Sync for Point<T>
where T: Sync,

§

impl<T> Unpin for Point<T>
where T: Unpin,

§

impl<T> UnwindSafe for Point<T>
where T: UnwindSafe,

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> 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> 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,

§

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>,

§

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>,

§

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.