pub struct Point<Unit> {
pub x: Unit,
pub y: Unit,
}
Expand description
A coordinate in a 2d space.
Fields§
§x: Unit
The x-axis component.
y: Unit
The y-axis component
Implementations§
source§impl<Unit> Point<Unit>
impl<Unit> Point<Unit>
sourcepub const fn new(x: Unit, y: Unit) -> Self
pub const fn new(x: Unit, y: Unit) -> Self
Returns a new point with the provided x
and y
components.
sourcepub fn squared(i: Unit) -> Selfwhere
Unit: Clone,
pub fn squared(i: Unit) -> Selfwhere Unit: Clone,
Returns a new point with both x
and y
initialized with i
.
sourcepub fn cast<NewUnit>(self) -> Point<NewUnit>where
Unit: Into<NewUnit>,
pub fn cast<NewUnit>(self) -> Point<NewUnit>where Unit: Into<NewUnit>,
Converts the contents of this point to NewUnit
using From
.
sourcepub fn try_cast<NewUnit>(self) -> Result<Point<NewUnit>, Unit::Error>where
Unit: TryInto<NewUnit>,
pub fn try_cast<NewUnit>(self) -> Result<Point<NewUnit>, Unit::Error>where Unit: TryInto<NewUnit>,
Converts the contents of this point to NewUnit
using TryFrom
.
Errors
Returns <NewUnit as TryFrom>::Error
when the inner type cannot be
converted. For this crate’s types, this genenerally will be
TryFromIntError
.
sourcepub fn map<NewUnit>(self, map: impl FnMut(Unit) -> NewUnit) -> Point<NewUnit>
pub fn map<NewUnit>(self, map: impl FnMut(Unit) -> NewUnit) -> Point<NewUnit>
Maps each component to map
and returns a new value with the mapped
components.
sourcepub fn dot(self, other: Point<Unit>) -> Unitwhere
Unit: Mul<Output = Unit> + Add<Output = Unit>,
pub fn dot(self, other: Point<Unit>) -> Unitwhere Unit: Mul<Output = Unit> + Add<Output = Unit>,
Returns the dot product of self
and other
.
sourcepub fn magnitude(self) -> Unitwhere
Unit: Mul<Output = Unit> + Add<Output = Unit> + Roots + Copy,
pub fn magnitude(self) -> Unitwhere Unit: Mul<Output = Unit> + Add<Output = Unit> + Roots + Copy,
Returns the magnitude of self, which is the absolute distance from 0,0.
Trait Implementations§
source§impl<Unit> AddAssign<Point<Unit>> for Size<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign<Point<Unit>> for Size<Unit>where Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Point<Unit>)
fn add_assign(&mut self, rhs: Point<Unit>)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign<Size<Unit>> for Point<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign<Size<Unit>> for Point<Unit>where Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Size<Unit>)
fn add_assign(&mut self, rhs: Size<Unit>)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign<Unit> for Point<Unit>where
Unit: AddAssign + Clone,
impl<Unit> AddAssign<Unit> for Point<Unit>where Unit: AddAssign + Clone,
source§fn add_assign(&mut self, rhs: Unit)
fn add_assign(&mut self, rhs: Unit)
Performs the
+=
operation. Read moresource§impl<Unit> AddAssign for Point<Unit>where
Unit: AddAssign,
impl<Unit> AddAssign for Point<Unit>where Unit: AddAssign,
source§fn add_assign(&mut self, rhs: Point<Unit>)
fn add_assign(&mut self, rhs: Point<Unit>)
Performs the
+=
operation. Read moresource§impl<'de, Unit> Deserialize<'de> for Point<Unit>where
Unit: Deserialize<'de>,
impl<'de, Unit> Deserialize<'de> for Point<Unit>where Unit: Deserialize<'de>,
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<Unit> DivAssign<Point<Unit>> for Size<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign<Point<Unit>> for Size<Unit>where Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Point<Unit>)
fn div_assign(&mut self, rhs: Point<Unit>)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign<Size<Unit>> for Point<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign<Size<Unit>> for Point<Unit>where Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Size<Unit>)
fn div_assign(&mut self, rhs: Size<Unit>)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign<Unit> for Point<Unit>where
Unit: DivAssign + Clone,
impl<Unit> DivAssign<Unit> for Point<Unit>where Unit: DivAssign + Clone,
source§fn div_assign(&mut self, rhs: Unit)
fn div_assign(&mut self, rhs: Unit)
Performs the
/=
operation. Read moresource§impl<Unit> DivAssign for Point<Unit>where
Unit: DivAssign,
impl<Unit> DivAssign for Point<Unit>where Unit: DivAssign,
source§fn div_assign(&mut self, rhs: Point<Unit>)
fn div_assign(&mut self, rhs: Point<Unit>)
Performs the
/=
operation. Read moresource§impl<T> FloatConversion for Point<T>where
T: FloatConversion,
impl<T> FloatConversion for Point<T>where T: FloatConversion,
§type Float = Point<<T as FloatConversion>::Float>
type Float = Point<<T as FloatConversion>::Float>
The type that represents this type in floating point form.
source§fn into_float(self) -> Self::Float
fn into_float(self) -> Self::Float
Returns this value in floating point form.
source§fn from_float(float: Self::Float) -> Self
fn from_float(float: Self::Float) -> Self
Converts from floating point to this form.
source§impl<Unit> From<PhysicalPosition<f64>> for Point<Unit>where
Unit: FloatConversion<Float = f32>,
impl<Unit> From<PhysicalPosition<f64>> for Point<Unit>where Unit: FloatConversion<Float = f32>,
source§impl<Unit> From<Point<Unit>> for Point2D<f32, UnknownUnit>where
Unit: FloatConversion<Float = f32>,
impl<Unit> From<Point<Unit>> for Point2D<f32, UnknownUnit>where Unit: FloatConversion<Float = f32>,
source§impl<Unit> From<Point2D<f32, UnknownUnit>> for Point<Unit>where
Unit: FloatConversion<Float = f32>,
impl<Unit> From<Point2D<f32, UnknownUnit>> for Point<Unit>where Unit: FloatConversion<Float = f32>,
source§impl<Unit> FromComponents<Unit> for Point<Unit>
impl<Unit> FromComponents<Unit> for Point<Unit>
source§fn from_components(components: (Unit, Unit)) -> Self
fn from_components(components: (Unit, Unit)) -> Self
Returns a new instance from the 2d vector components provided.
source§fn from_vec<Type>(other: Type) -> Selfwhere
Type: IntoComponents<Unit>,
fn from_vec<Type>(other: Type) -> Selfwhere Type: IntoComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<Unit> IntoComponents<Unit> for Point<Unit>
impl<Unit> IntoComponents<Unit> for Point<Unit>
source§fn into_components(self) -> (Unit, Unit)
fn into_components(self) -> (Unit, Unit)
Extracts this type’s 2d vector components.
source§fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
fn to_vec<Type>(self) -> Typewhere Type: FromComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<Unit> IntoSigned for Point<Unit>where
Unit: IntoSigned,
impl<Unit> IntoSigned for Point<Unit>where Unit: IntoSigned,
§type Signed = Point<<Unit as IntoSigned>::Signed>
type Signed = Point<<Unit as IntoSigned>::Signed>
The signed representation of this type.
source§fn into_signed(self) -> Self::Signed
fn into_signed(self) -> Self::Signed
Returns this value as an unsigned value. Values that are larger than can
fit in an
i32
are converted to i32::MAX
.source§impl<Unit> IntoUnsigned for Point<Unit>where
Unit: IntoUnsigned,
impl<Unit> IntoUnsigned for Point<Unit>where Unit: IntoUnsigned,
§type Unsigned = Point<<Unit as IntoUnsigned>::Unsigned>
type Unsigned = Point<<Unit as IntoUnsigned>::Unsigned>
The unsigned representation of this type.
source§fn into_unsigned(self) -> Self::Unsigned
fn into_unsigned(self) -> Self::Unsigned
Returns this value as an unsigned value. Negative values will be
converted to 0.
source§impl<Unit> MulAssign<Point<Unit>> for Size<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign<Point<Unit>> for Size<Unit>where Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Point<Unit>)
fn mul_assign(&mut self, rhs: Point<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign<Size<Unit>> for Point<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign<Size<Unit>> for Point<Unit>where Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Size<Unit>)
fn mul_assign(&mut self, rhs: Size<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign<Unit> for Point<Unit>where
Unit: MulAssign + Clone,
impl<Unit> MulAssign<Unit> for Point<Unit>where Unit: MulAssign + Clone,
source§fn mul_assign(&mut self, rhs: Unit)
fn mul_assign(&mut self, rhs: Unit)
Performs the
*=
operation. Read moresource§impl<Unit> MulAssign for Point<Unit>where
Unit: MulAssign,
impl<Unit> MulAssign for Point<Unit>where Unit: MulAssign,
source§fn mul_assign(&mut self, rhs: Point<Unit>)
fn mul_assign(&mut self, rhs: Point<Unit>)
Performs the
*=
operation. Read moresource§impl<Unit> Ord for Point<Unit>where
Unit: Ord + Copy + Mul<Output = Unit>,
impl<Unit> Ord for Point<Unit>where Unit: Ord + Copy + Mul<Output = Unit>,
source§impl<Unit: PartialEq> PartialEq for Point<Unit>
impl<Unit: PartialEq> PartialEq for Point<Unit>
source§impl<Unit> PartialOrd for Point<Unit>where
Unit: Ord + Copy + Mul<Output = Unit>,
impl<Unit> PartialOrd for Point<Unit>where Unit: Ord + Copy + Mul<Output = Unit>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<Unit> RemAssign<Point<Unit>> for Size<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign<Point<Unit>> for Size<Unit>where Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Point<Unit>)
fn rem_assign(&mut self, rhs: Point<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign<Size<Unit>> for Point<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign<Size<Unit>> for Point<Unit>where Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Size<Unit>)
fn rem_assign(&mut self, rhs: Size<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign<Unit> for Point<Unit>where
Unit: RemAssign + Clone,
impl<Unit> RemAssign<Unit> for Point<Unit>where Unit: RemAssign + Clone,
source§fn rem_assign(&mut self, rhs: Unit)
fn rem_assign(&mut self, rhs: Unit)
Performs the
%=
operation. Read moresource§impl<Unit> RemAssign for Point<Unit>where
Unit: RemAssign,
impl<Unit> RemAssign for Point<Unit>where Unit: RemAssign,
source§fn rem_assign(&mut self, rhs: Point<Unit>)
fn rem_assign(&mut self, rhs: Point<Unit>)
Performs the
%=
operation. Read moresource§impl<Unit> ScreenScale for Point<Unit>where
Unit: ScreenScale<Lp = Lp, Px = Px, UPx = UPx>,
impl<Unit> ScreenScale for Point<Unit>where Unit: ScreenScale<Lp = Lp, Px = Px, UPx = UPx>,
source§fn into_px(self, scale: Fraction) -> Self::Px
fn into_px(self, scale: Fraction) -> Self::Px
Converts this value from its current unit into device pixels (
Px
)
using the provided scale
factor.source§fn from_px(px: Self::Px, scale: Fraction) -> Self
fn from_px(px: Self::Px, scale: Fraction) -> Self
Converts from pixels into this type, using the provided
scale
factor.source§fn into_lp(self, scale: Fraction) -> Self::Lp
fn into_lp(self, scale: Fraction) -> Self::Lp
Converts this value from its current unit into device independent pixels
(
Lp
) using the provided scale
factor.source§fn from_lp(lp: Self::Lp, scale: Fraction) -> Self
fn from_lp(lp: Self::Lp, scale: Fraction) -> Self
Converts from Lp into this type, using the provided
scale
factor.source§impl<Unit> SubAssign<Point<Unit>> for Size<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign<Point<Unit>> for Size<Unit>where Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Point<Unit>)
fn sub_assign(&mut self, rhs: Point<Unit>)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign<Size<Unit>> for Point<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign<Size<Unit>> for Point<Unit>where Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Size<Unit>)
fn sub_assign(&mut self, rhs: Size<Unit>)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign<Unit> for Point<Unit>where
Unit: SubAssign + Clone,
impl<Unit> SubAssign<Unit> for Point<Unit>where Unit: SubAssign + Clone,
source§fn sub_assign(&mut self, rhs: Unit)
fn sub_assign(&mut self, rhs: Unit)
Performs the
-=
operation. Read moresource§impl<Unit> SubAssign for Point<Unit>where
Unit: SubAssign,
impl<Unit> SubAssign for Point<Unit>where Unit: SubAssign,
source§fn sub_assign(&mut self, rhs: Point<Unit>)
fn sub_assign(&mut self, rhs: Point<Unit>)
Performs the
-=
operation. Read moreimpl<Unit: Copy> Copy for Point<Unit>
impl<Unit: Eq> Eq for Point<Unit>
impl Pod for Point<Lp>
impl Pod for Point<Px>
impl Pod for Point<f32>
impl Pod for Point<i32>
impl Pod for Point<u32>
impl<Unit> StructuralEq for Point<Unit>
impl<Unit> StructuralPartialEq for Point<Unit>
Auto Trait Implementations§
impl<Unit> RefUnwindSafe for Point<Unit>where Unit: RefUnwindSafe,
impl<Unit> Send for Point<Unit>where Unit: Send,
impl<Unit> Sync for Point<Unit>where Unit: Sync,
impl<Unit> Unpin for Point<Unit>where Unit: Unpin,
impl<Unit> UnwindSafe for Point<Unit>where Unit: UnwindSafe,
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
Mutably borrows from an owned value. Read more
§impl<A> Cast for A
impl<A> Cast for A
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<Unit> IntoComponents<Unit> for Unitwhere
Unit: Copy,
impl<Unit> IntoComponents<Unit> for Unitwhere Unit: Copy,
source§fn into_components(self) -> (Unit, Unit)
fn into_components(self) -> (Unit, Unit)
Extracts this type’s 2d vector components.
source§fn to_vec<Type>(self) -> Typewhere
Type: FromComponents<Unit>,
fn to_vec<Type>(self) -> Typewhere Type: FromComponents<Unit>,
Converts this type to another type using
FromComponents
and
IntoComponents
.source§impl<T> Lp2D for Twhere
T: FromComponents<Lp>,
impl<T> Lp2D for Twhere T: FromComponents<Lp>,
source§fn points(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn points(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
Returns a new value containing the x and y components converted into
Lp
using Lp::points
/Lp::points_f
.source§fn cm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn cm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
source§fn mm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn mm(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
source§fn inches(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
fn inches(x: impl Into<FloatOrInt>, y: impl Into<FloatOrInt>) -> Self
Returns a new value containing the x and y components converted into
Lp
using Lp::inches
/Lp::inches_f
.