[−][src]Struct euclid::Scale
A scaling factor between two different units of measurement.
This is effectively a type-safe float, intended to be used in combination with other types like
length::Length
to enforce conversion between systems of measurement at compile time.
Src
and Dst
represent the units before and after multiplying a value by a Scale
. They
may be types without values, such as empty enums. For example:
use euclid::Scale; use euclid::Length; enum Mm {}; enum Inch {}; let mm_per_inch: Scale<f32, Inch, Mm> = Scale::new(25.4); let one_foot: Length<f32, Inch> = Length::new(12.0); let one_foot_in_mm: Length<f32, Mm> = one_foot * mm_per_inch;
Methods
impl<T, Src, Dst> Scale<T, Src, Dst>
[src]
impl<T: Clone, Src, Dst> Scale<T, Src, Dst>
[src]
impl<Src, Dst> Scale<f32, Src, Dst>
[src]
pub const ONE: Self
[src]
Identity scaling, could be used to safely transit from one space to another.
impl<T: Clone + One + Div<T, Output = T>, Src, Dst> Scale<T, Src, Dst>
[src]
impl<T: NumCast + Clone, Src, Dst0> Scale<T, Src, Dst0>
[src]
pub fn cast<T1: NumCast + Clone>(&self) -> Scale<T1, Src, Dst0>
[src]
Cast from one numeric representation to another, preserving the units.
pub fn try_cast<T1: NumCast + Clone>(&self) -> Option<Scale<T1, Src, Dst0>>
[src]
Fallible cast from one numeric representation to another, preserving the units.
impl<T, Src, Dst> Scale<T, Src, Dst> where
T: Copy + Clone + Mul<T, Output = T> + Neg<Output = T> + PartialEq + One,
[src]
T: Copy + Clone + Mul<T, Output = T> + Neg<Output = T> + PartialEq + One,
pub fn transform_point(&self, point: Point2D<T, Src>) -> Point2D<T, Dst>
[src]
Returns the given point transformed by this scale.
pub fn transform_vector(&self, vec: Vector2D<T, Src>) -> Vector2D<T, Dst>
[src]
Returns the given vector transformed by this scale.
pub fn transform_size(&self, size: Size2D<T, Src>) -> Size2D<T, Dst>
[src]
Returns the given vector transformed by this scale.
pub fn transform_rect(&self, rect: &Rect<T, Src>) -> Rect<T, Dst>
[src]
Returns the given rect transformed by this scale.
pub fn inverse(&self) -> Scale<T, Dst, Src>
[src]
Returns the inverse of this scale.
pub fn is_identity(&self) -> bool
[src]
Returns true if this scale has no effect.
Trait Implementations
impl<T: Debug, Src, Dst> Debug for Scale<T, Src, Dst>
[src]
impl<T: Display, Src, Dst> Display for Scale<T, Src, Dst>
[src]
impl<T: PartialEq, Src, Dst> PartialEq<Scale<T, Src, Dst>> for Scale<T, Src, Dst>
[src]
fn eq(&self, other: &Scale<T, Src, Dst>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: Clone + Add<T, Output = T>, Src, Dst> Add<Scale<T, Src, Dst>> for Scale<T, Src, Dst>
[src]
type Output = Scale<T, Src, Dst>
The resulting type after applying the +
operator.
fn add(self, other: Scale<T, Src, Dst>) -> Scale<T, Src, Dst>
[src]
impl<T: Clone + Sub<T, Output = T>, Src, Dst> Sub<Scale<T, Src, Dst>> for Scale<T, Src, Dst>
[src]
type Output = Scale<T, Src, Dst>
The resulting type after applying the -
operator.
fn sub(self, other: Scale<T, Src, Dst>) -> Scale<T, Src, Dst>
[src]
impl<T, U1, U2> Mul<Scale<T, U1, U2>> for Box2D<T, U1> where
T: Copy + Mul<T, Output = T>,
[src]
T: Copy + Mul<T, Output = T>,
type Output = Box2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Box2D<T, U2>
[src]
impl<Src, Dst, T: Clone + Mul<T, Output = T>> Mul<Scale<T, Src, Dst>> for Length<T, Src>
[src]
type Output = Length<T, Dst>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, Src, Dst>) -> Length<T, Dst>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Point2D<T, U1>
[src]
type Output = Point2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Point2D<T, U2>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Point3D<T, U1>
[src]
type Output = Point3D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Point3D<T, U2>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Rect<T, U1>
[src]
type Output = Rect<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Rect<T, U2>
[src]
impl<T: Clone + Mul<T, Output = T>, A, B, C> Mul<Scale<T, B, C>> for Scale<T, A, B>
[src]
type Output = Scale<T, A, C>
The resulting type after applying the *
operator.
fn mul(self, other: Scale<T, B, C>) -> Scale<T, A, C>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Size2D<T, U1>
[src]
type Output = Size2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Size2D<T, U2>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Size3D<T, U1>
[src]
type Output = Size3D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Size3D<T, U2>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Vector2D<T, U1>
[src]
type Output = Vector2D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Self::Output
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<Scale<T, U1, U2>> for Vector3D<T, U1>
[src]
type Output = Vector3D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Self::Output
[src]
impl<T, U1, U2> Mul<Scale<T, U1, U2>> for Box3D<T, U1> where
T: Copy + Mul<T, Output = T>,
[src]
T: Copy + Mul<T, Output = T>,
type Output = Box3D<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: Scale<T, U1, U2>) -> Box3D<T, U2>
[src]
impl<T, U1, U2> Div<Scale<T, U1, U2>> for Box2D<T, U2> where
T: Copy + Div<T, Output = T>,
[src]
T: Copy + Div<T, Output = T>,
type Output = Box2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Box2D<T, U1>
[src]
impl<Src, Dst, T: Clone + Div<T, Output = T>> Div<Scale<T, Src, Dst>> for Length<T, Dst>
[src]
type Output = Length<T, Src>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, Src, Dst>) -> Length<T, Src>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Point2D<T, U2>
[src]
type Output = Point2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Point2D<T, U1>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Point3D<T, U2>
[src]
type Output = Point3D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Point3D<T, U1>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Rect<T, U2>
[src]
type Output = Rect<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Rect<T, U1>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Size2D<T, U2>
[src]
type Output = Size2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Size2D<T, U1>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Size3D<T, U2>
[src]
type Output = Size3D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Size3D<T, U1>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Vector2D<T, U2>
[src]
type Output = Vector2D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Self::Output
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<Scale<T, U1, U2>> for Vector3D<T, U2>
[src]
type Output = Vector3D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Self::Output
[src]
impl<T, U1, U2> Div<Scale<T, U1, U2>> for Box3D<T, U2> where
T: Copy + Div<T, Output = T>,
[src]
T: Copy + Div<T, Output = T>,
type Output = Box3D<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: Scale<T, U1, U2>) -> Box3D<T, U1>
[src]
impl<T: Copy, Src, Dst> Copy for Scale<T, Src, Dst>
[src]
impl<T: Clone, Src, Dst> Clone for Scale<T, Src, Dst>
[src]
Auto Trait Implementations
impl<T, Src, Dst> Unpin for Scale<T, Src, Dst> where
Dst: Unpin,
Src: Unpin,
T: Unpin,
Dst: Unpin,
Src: Unpin,
T: Unpin,
impl<T, Src, Dst> Send for Scale<T, Src, Dst> where
Dst: Send,
Src: Send,
T: Send,
Dst: Send,
Src: Send,
T: Send,
impl<T, Src, Dst> Sync for Scale<T, Src, Dst> where
Dst: Sync,
Src: Sync,
T: Sync,
Dst: Sync,
Src: Sync,
T: Sync,
impl<T, Src, Dst> UnwindSafe for Scale<T, Src, Dst> where
Dst: UnwindSafe,
Src: UnwindSafe,
T: UnwindSafe,
Dst: UnwindSafe,
Src: UnwindSafe,
T: UnwindSafe,
impl<T, Src, Dst> RefUnwindSafe for Scale<T, Src, Dst> where
Dst: RefUnwindSafe,
Src: RefUnwindSafe,
T: RefUnwindSafe,
Dst: RefUnwindSafe,
Src: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,