Struct Point

Source
pub struct Point {
    pub x: i32,
    pub y: i32,
}
Expand description

Helper struct defining a 2D point in space.

Fields§

§x: i32

The point’s X location

§y: i32

The point’s Y location

Implementations§

Source§

impl Point

Source

pub fn new<T>(x: T, y: T) -> Point
where T: TryInto<i32>,

Create a new point from an x/y coordinate.

Source

pub const fn constant(x: i32, y: i32) -> Point

Create a new point from i32, this can be constant

Source

pub fn zero() -> Point

Create a zero point

Source

pub fn from_tuple<T>(t: (T, T)) -> Point
where T: TryInto<i32>,

Create a point from a tuple of two i32s

Source

pub fn to_index<T>(self, width: T) -> usize
where T: TryInto<usize>,

Helper for map index conversion

Source

pub fn to_tuple(self) -> (i32, i32)

Converts the point to an i32 tuple

Source

pub fn to_unsigned_tuple(self) -> (usize, usize)

Converts the point to a usize tuple

§Panics

This can panic if X or Y are not convertible to a usize.

Source

pub fn to_vec2(self) -> Vec2

Converts the point to an UltraViolet vec2

Source

pub fn from_vec2(v: Vec2) -> Point

Creates a point from an UltraViolet vec2

Trait Implementations§

Source§

impl Add<i32> for Point

Support adding an int to a point

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, rhs: i32) -> Point

Performs the + operation. Read more
Source§

impl Add for Point

Overloads: We support basic point math Support adding a point to a point

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Point) -> Point

Performs the + operation. Read more
Source§

impl AddAssign for Point

Source§

fn add_assign(&mut self, other: Point)

Performs the += operation. Read more
Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

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 Point

Source§

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

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

impl Div<f32> for Point

Support dividing a point by an f32

Source§

type Output = Point

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Point

Performs the / operation. Read more
Source§

impl Div<i32> for Point

Support dividing a point by an int

Source§

type Output = Point

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i32) -> Point

Performs the / operation. Read more
Source§

impl Div for Point

Support dividing a point by a point

Source§

type Output = Point

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Point) -> Point

Performs the / operation. Read more
Source§

impl DivAssign for Point

Source§

fn div_assign(&mut self, other: Point)

Performs the /= operation. Read more
Source§

impl From<(f32, f32)> for Point

Source§

fn from(item: (f32, f32)) -> Point

Converts to this type from the input type.
Source§

impl From<(i32, i32)> for Point

Source§

fn from(item: (i32, i32)) -> Point

Converts to this type from the input type.
Source§

impl From<Vec2> for Point

Source§

fn from(item: Vec2) -> Point

Converts to this type from the input type.
Source§

impl Hash for Point

Source§

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

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 Mul<f32> for Point

Support multiplying a point by an f32

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Point

Performs the * operation. Read more
Source§

impl Mul<i32> for Point

Support multiplying a point by an int

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i32) -> Point

Performs the * operation. Read more
Source§

impl Mul for Point

Support multiplying a point by a point

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Point) -> Point

Performs the * operation. Read more
Source§

impl MulAssign for Point

Source§

fn mul_assign(&mut self, other: Point)

Performs the *= operation. Read more
Source§

impl PartialEq for Point

Source§

fn eq(&self, other: &Point) -> 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 Sub<i32> for Point

Support subtracting an int from a point

Source§

type Output = Point

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: i32) -> Point

Performs the - operation. Read more
Source§

impl Sub for Point

Support subtracting a point from a point

Source§

type Output = Point

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Point) -> Point

Performs the - operation. Read more
Source§

impl SubAssign for Point

Source§

fn sub_assign(&mut self, other: Point)

Performs the -= operation. Read more
Source§

impl Copy for Point

Source§

impl Eq for Point

Source§

impl StructuralPartialEq for Point

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnwindSafe for Point

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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