pub struct Offset(pub i32, pub i32);
Expand description
A (x, y)
offset, also known as a vector
This is a relative position. It can be added to or subtracted from a
Coord
, and it can be added to or subtracted from itself. It can be
negative. It can be multiplied by a scalar.
Offset
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 == Offset(0, 1)
and d == Offset(1, 0)
then
c != d && !(c < d) && !(c > d)
. Offset
does not implement Ord
.
This may be converted to Size
with from
/ into
.
Tuple Fields§
§0: i32
§1: i32
Implementations§
Source§impl Offset
impl Offset
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<'a> AddAssign<Offset> for Event<'a>
impl<'a> AddAssign<Offset> for Event<'a>
Source§fn add_assign(&mut self, offset: Offset)
fn add_assign(&mut self, offset: Offset)
+=
operation. Read moreSource§impl AddAssign<Offset> for PressStart
impl AddAssign<Offset> for PressStart
Source§fn add_assign(&mut self, offset: Offset)
fn add_assign(&mut self, offset: Offset)
+=
operation. Read moreSource§impl AddAssign<Offset> for Rect
impl AddAssign<Offset> for Rect
Source§fn add_assign(&mut self, offset: Offset)
fn add_assign(&mut self, offset: Offset)
+=
operation. Read moreSource§impl AddAssign for Offset
impl AddAssign for Offset
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl ConvApprox<DVec2> for Offset
impl ConvApprox<DVec2> for Offset
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 ConvApprox<Point> for Offset
Available on crate feature accesskit
only.
impl ConvApprox<Point> for Offset
accesskit
only.Source§fn try_conv_approx(point: Point) -> Result<Self>
fn try_conv_approx(point: Point) -> Result<Self>
Source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Source§impl ConvApprox<Vec2> for Offset
impl ConvApprox<Vec2> for Offset
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 Offset
impl ConvFloat<DVec2> for Offset
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 Offset
impl ConvFloat<Vec2> for Offset
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 Offset
impl<'de> Deserialize<'de> for Offset
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 for Offset
impl PartialOrd for Offset
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<Offset> for Rect
impl SubAssign<Offset> for Rect
Source§fn sub_assign(&mut self, offset: Offset)
fn sub_assign(&mut self, offset: Offset)
-=
operation. Read moreSource§impl SubAssign for Offset
impl SubAssign for Offset
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreimpl Copy for Offset
impl Eq for Offset
impl StructuralPartialEq for Offset
Auto Trait Implementations§
impl Freeze for Offset
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
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()
.