pub struct Coord(pub i32, pub i32);
Expand description
A 2D coordinate, also known as a point
A coordinate (or point) is an absolute position. One cannot add a point to
a point. The difference between two points is an Offset
.
Coord
implements PartialOrd
such that the comparison must be true of
all components: for example a < b == a.0 < b.0 && a.1 < b.1
.
If c == Coord(0, 1)
and d == Coord(1, 0)
then
c != d && !(c < d) && !(c > d)
. Coord
does not implement Ord
.
Tuple Fields§
§0: i32
§1: i32
Implementations§
Source§impl Coord
impl Coord
Sourcepub fn as_physical(self) -> Position
pub fn as_physical(self) -> Position
Convert to a “physical” winit::dpi::Position
This implies that the Coord
was calculated using the correct
scale factor. Before the window has been constructed (when the
scale factor is supposedly unknown) this should not be used.
Source§impl Coord
impl Coord
Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Restrict a value to the specified interval, componentwise
Sourcepub fn distance_l1(self) -> i32
pub fn distance_l1(self) -> i32
Return the L1 (rectilinear / taxicab) distance
Sourcepub fn distance_l_inf(self) -> i32
pub fn distance_l_inf(self) -> i32
Return the L-inf (max) distance
Sourcepub fn extract<D: Directional>(self, dir: D) -> i32
pub fn extract<D: Directional>(self, dir: D) -> i32
Extract one component, based on a direction
This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.
Sourcepub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
pub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
Set one component of self, based on a direction
This does not negate components when the direction is reversed.
Trait Implementations§
Source§impl AddAssign<Offset> for Coord
impl AddAssign<Offset> for Coord
Source§fn add_assign(&mut self, rhs: Offset)
fn add_assign(&mut self, rhs: Offset)
+=
operation. Read moreSource§impl AddAssign<Size> for Coord
impl AddAssign<Size> for Coord
Source§fn add_assign(&mut self, rhs: Size)
fn add_assign(&mut self, rhs: Size)
+=
operation. Read moreSource§impl ConvApprox<DVec2> for Coord
impl ConvApprox<DVec2> for Coord
Source§fn try_conv_approx(arg: DVec2) -> Result<Self>
fn try_conv_approx(arg: DVec2) -> Result<Self>
Source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Source§impl<X: CastApprox<i32>> ConvApprox<PhysicalPosition<X>> for Coord
impl<X: CastApprox<i32>> ConvApprox<PhysicalPosition<X>> for Coord
Source§fn try_conv_approx(pos: PhysicalPosition<X>) -> Result<Self>
fn try_conv_approx(pos: PhysicalPosition<X>) -> Result<Self>
Source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Source§impl ConvApprox<Point> for Coord
Available on crate feature accesskit
only.
impl ConvApprox<Point> for Coord
accesskit
only.Source§fn try_conv_approx(p: Point) -> Result<Self>
fn try_conv_approx(p: Point) -> Result<Self>
Source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Source§impl ConvApprox<Vec2> for Coord
impl ConvApprox<Vec2> for Coord
Source§fn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
Source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Source§impl ConvFloat<DVec2> for Coord
impl ConvFloat<DVec2> for Coord
Source§fn try_conv_trunc(x: DVec2) -> Result<Self>
fn try_conv_trunc(x: DVec2) -> Result<Self>
Source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Source§impl ConvFloat<Vec2> for Coord
impl ConvFloat<Vec2> for Coord
Source§fn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
Source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Source§impl<'de> Deserialize<'de> for Coord
impl<'de> Deserialize<'de> for Coord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialOrd<Coord> for DVec2
impl PartialOrd<Coord> for DVec2
Source§impl PartialOrd<Coord> for Vec2
impl PartialOrd<Coord> for Vec2
Source§impl PartialOrd for Coord
impl PartialOrd for Coord
Source§impl SubAssign<Offset> for Coord
impl SubAssign<Offset> for Coord
Source§fn sub_assign(&mut self, rhs: Offset)
fn sub_assign(&mut self, rhs: Offset)
-=
operation. Read moreSource§impl SubAssign<Size> for Coord
impl SubAssign<Size> for Coord
Source§fn sub_assign(&mut self, rhs: Size)
fn sub_assign(&mut self, rhs: Size)
-=
operation. Read moreimpl Copy for Coord
impl Eq for Coord
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
Source§fn try_conv_approx(x: S) -> Result<T, Error>
fn try_conv_approx(x: S) -> Result<T, Error>
Source§fn conv_approx(x: S) -> T
fn conv_approx(x: S) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.