[−][src]Struct euclid::TypedRect
A 2d Rectangle optionally tagged with a unit.
Fields
origin: TypedPoint2D<T, U>
size: TypedSize2D<T, U>
Methods
impl<T, U> TypedRect<T, U>
[src]
impl<T, U> TypedRect<T, U>
pub fn new(origin: TypedPoint2D<T, U>, size: TypedSize2D<T, U>) -> Self
[src]
pub fn new(origin: TypedPoint2D<T, U>, size: TypedSize2D<T, U>) -> Self
Constructor.
impl<T, U> TypedRect<T, U> where
T: Copy + Zero,
[src]
impl<T, U> TypedRect<T, U> where
T: Copy + Zero,
pub fn from_size(size: TypedSize2D<T, U>) -> Self
[src]
pub fn from_size(size: TypedSize2D<T, U>) -> Self
Creates a rect of the given size, at offset zero.
impl<T, U> TypedRect<T, U> where
T: Copy + Clone + Zero + PartialOrd + PartialEq + Add<T, Output = T> + Sub<T, Output = T>,
[src]
impl<T, U> TypedRect<T, U> where
T: Copy + Clone + Zero + PartialOrd + PartialEq + Add<T, Output = T> + Sub<T, Output = T>,
pub fn intersects(&self, other: &Self) -> bool
[src]
pub fn intersects(&self, other: &Self) -> bool
pub fn max_x(&self) -> T
[src]
pub fn max_x(&self) -> T
pub fn min_x(&self) -> T
[src]
pub fn min_x(&self) -> T
pub fn max_y(&self) -> T
[src]
pub fn max_y(&self) -> T
pub fn min_y(&self) -> T
[src]
pub fn min_y(&self) -> T
pub fn max_x_typed(&self) -> Length<T, U>
[src]
pub fn max_x_typed(&self) -> Length<T, U>
pub fn min_x_typed(&self) -> Length<T, U>
[src]
pub fn min_x_typed(&self) -> Length<T, U>
pub fn max_y_typed(&self) -> Length<T, U>
[src]
pub fn max_y_typed(&self) -> Length<T, U>
pub fn min_y_typed(&self) -> Length<T, U>
[src]
pub fn min_y_typed(&self) -> Length<T, U>
pub fn intersection(&self, other: &Self) -> Option<Self>
[src]
pub fn intersection(&self, other: &Self) -> Option<Self>
pub fn translate(&self, by: &TypedVector2D<T, U>) -> Self
[src]
pub fn translate(&self, by: &TypedVector2D<T, U>) -> Self
Returns the same rectangle, translated by a vector.
pub fn contains(&self, other: &TypedPoint2D<T, U>) -> bool
[src]
pub fn contains(&self, other: &TypedPoint2D<T, U>) -> bool
Returns true if this rectangle contains the point. Points are considered in the rectangle if they are on the left or top edge, but outside if they are on the right or bottom edge.
pub fn contains_rect(&self, rect: &Self) -> bool
[src]
pub fn contains_rect(&self, rect: &Self) -> bool
Returns true if this rectangle contains the interior of rect. Always returns true if rect is empty, and always returns false if rect is nonempty but this rectangle is empty.
pub fn inflate(&self, width: T, height: T) -> Self
[src]
pub fn inflate(&self, width: T, height: T) -> Self
pub fn inflate_typed(&self, width: Length<T, U>, height: Length<T, U>) -> Self
[src]
pub fn inflate_typed(&self, width: Length<T, U>, height: Length<T, U>) -> Self
pub fn top_right(&self) -> TypedPoint2D<T, U>
[src]
pub fn top_right(&self) -> TypedPoint2D<T, U>
pub fn bottom_left(&self) -> TypedPoint2D<T, U>
[src]
pub fn bottom_left(&self) -> TypedPoint2D<T, U>
pub fn bottom_right(&self) -> TypedPoint2D<T, U>
[src]
pub fn bottom_right(&self) -> TypedPoint2D<T, U>
pub fn translate_by_size(&self, size: &TypedSize2D<T, U>) -> Self
[src]
pub fn translate_by_size(&self, size: &TypedSize2D<T, U>) -> Self
pub fn inner_rect(&self, offsets: TypedSideOffsets2D<T, U>) -> Self
[src]
pub fn inner_rect(&self, offsets: TypedSideOffsets2D<T, U>) -> Self
Calculate the size and position of an inner rectangle.
Subtracts the side offsets from all sides. The horizontal and vertical offsets must not be larger than the original side length.
pub fn outer_rect(&self, offsets: TypedSideOffsets2D<T, U>) -> Self
[src]
pub fn outer_rect(&self, offsets: TypedSideOffsets2D<T, U>) -> Self
Calculate the size and position of an outer rectangle.
Add the offsets to all sides. The expanded rectangle is returned.
pub fn from_points<I>(points: I) -> Self where
I: IntoIterator,
I::Item: Borrow<TypedPoint2D<T, U>>,
[src]
pub fn from_points<I>(points: I) -> Self where
I: IntoIterator,
I::Item: Borrow<TypedPoint2D<T, U>>,
Returns the smallest rectangle defined by the top/bottom/left/right-most points provided as parameter.
Note: This function has a behavior that can be surprising because
the right-most and bottom-most points are exactly on the edge
of the rectangle while the contains
function is has exclusive
semantic on these edges. This means that the right-most and bottom-most
points provided to from_points
will count as not contained by the rect.
This behavior may change in the future.
impl<T, U> TypedRect<T, U> where
T: Copy + One + Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
[src]
impl<T, U> TypedRect<T, U> where
T: Copy + One + Add<Output = T> + Sub<Output = T> + Mul<Output = T>,
pub fn lerp(&self, other: Self, t: T) -> Self
[src]
pub fn lerp(&self, other: Self, t: T) -> Self
Linearly interpolate between this rectangle and another rectangle.
t
is expected to be between zero and one.
impl<T, U> TypedRect<T, U> where
T: Copy + One + Add<Output = T> + Div<Output = T>,
[src]
impl<T, U> TypedRect<T, U> where
T: Copy + One + Add<Output = T> + Div<Output = T>,
pub fn center(&self) -> TypedPoint2D<T, U>
[src]
pub fn center(&self) -> TypedPoint2D<T, U>
impl<T, U> TypedRect<T, U> where
T: Copy + Clone + PartialOrd + Add<T, Output = T> + Sub<T, Output = T> + Zero,
[src]
impl<T, U> TypedRect<T, U> where
T: Copy + Clone + PartialOrd + Add<T, Output = T> + Sub<T, Output = T> + Zero,
impl<T, U> TypedRect<T, U>
[src]
impl<T, U> TypedRect<T, U>
impl<T: Copy + PartialEq + Zero, U> TypedRect<T, U>
[src]
impl<T: Copy + PartialEq + Zero, U> TypedRect<T, U>
pub fn zero() -> Self
[src]
pub fn zero() -> Self
Constructor, setting all sides to zero.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the size is zero, regardless of the origin's value.
impl<T: Copy, Unit> TypedRect<T, Unit>
[src]
impl<T: Copy, Unit> TypedRect<T, Unit>
pub fn to_untyped(&self) -> Rect<T>
[src]
pub fn to_untyped(&self) -> Rect<T>
Drop the units, preserving only the numeric value.
pub fn from_untyped(r: &Rect<T>) -> TypedRect<T, Unit>
[src]
pub fn from_untyped(r: &Rect<T>) -> TypedRect<T, Unit>
Tag a unitless value with units.
impl<T0: NumCast + Copy, Unit> TypedRect<T0, Unit>
[src]
impl<T0: NumCast + Copy, Unit> TypedRect<T0, Unit>
pub fn cast<T1: NumCast + Copy>(&self) -> TypedRect<T1, Unit>
[src]
pub fn cast<T1: NumCast + Copy>(&self) -> TypedRect<T1, Unit>
Cast from one numeric representation to another, preserving the units.
When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), round_in or round_out() before casting.
pub fn try_cast<T1: NumCast + Copy>(&self) -> Option<TypedRect<T1, Unit>>
[src]
pub fn try_cast<T1: NumCast + Copy>(&self) -> Option<TypedRect<T1, Unit>>
Fallible cast from one numeric representation to another, preserving the units.
When casting from floating point to integer coordinates, the decimals are truncated as one would expect from a simple cast, but this behavior does not always make sense geometrically. Consider using round(), round_in or round_out() before casting.
impl<T: Floor + Ceil + Round + Add<T, Output = T> + Sub<T, Output = T>, U> TypedRect<T, U>
[src]
impl<T: Floor + Ceil + Round + Add<T, Output = T> + Sub<T, Output = T>, U> TypedRect<T, U>
pub fn round(&self) -> Self
[src]
pub fn round(&self) -> Self
Return a rectangle with edges rounded to integer coordinates, such that the returned rectangle has the same set of pixel centers as the original one. Edges at offset 0.5 round up. Suitable for most places where integral device coordinates are needed, but note that any translation should be applied first to avoid pixel rounding errors. Note that this is not rounding to nearest integer if the values are negative. They are always rounding as floor(n + 0.5).
pub fn round_in(&self) -> Self
[src]
pub fn round_in(&self) -> Self
Return a rectangle with edges rounded to integer coordinates, such that the original rectangle contains the resulting rectangle.
pub fn round_out(&self) -> Self
[src]
pub fn round_out(&self) -> Self
Return a rectangle with edges rounded to integer coordinates, such that the original rectangle is contained in the resulting rectangle.
impl<T: NumCast + Copy, Unit> TypedRect<T, Unit>
[src]
impl<T: NumCast + Copy, Unit> TypedRect<T, Unit>
pub fn to_f32(&self) -> TypedRect<f32, Unit>
[src]
pub fn to_f32(&self) -> TypedRect<f32, Unit>
Cast into an f32
rectangle.
pub fn to_f64(&self) -> TypedRect<f64, Unit>
[src]
pub fn to_f64(&self) -> TypedRect<f64, Unit>
Cast into an f64
rectangle.
pub fn to_usize(&self) -> TypedRect<usize, Unit>
[src]
pub fn to_usize(&self) -> TypedRect<usize, Unit>
Cast into an usize
rectangle, truncating decimals if any.
When casting from floating point rectangles, it is worth considering whether
to round()
, round_in()
or round_out()
before the cast in order to
obtain the desired conversion behavior.
pub fn to_u32(&self) -> TypedRect<u32, Unit>
[src]
pub fn to_u32(&self) -> TypedRect<u32, Unit>
Cast into an u32
rectangle, truncating decimals if any.
When casting from floating point rectangles, it is worth considering whether
to round()
, round_in()
or round_out()
before the cast in order to
obtain the desired conversion behavior.
pub fn to_i32(&self) -> TypedRect<i32, Unit>
[src]
pub fn to_i32(&self) -> TypedRect<i32, Unit>
Cast into an i32
rectangle, truncating decimals if any.
When casting from floating point rectangles, it is worth considering whether
to round()
, round_in()
or round_out()
before the cast in order to
obtain the desired conversion behavior.
pub fn to_i64(&self) -> TypedRect<i64, Unit>
[src]
pub fn to_i64(&self) -> TypedRect<i64, Unit>
Cast into an i64
rectangle, truncating decimals if any.
When casting from floating point rectangles, it is worth considering whether
to round()
, round_in()
or round_out()
before the cast in order to
obtain the desired conversion behavior.
Trait Implementations
impl<T: PartialEq, U> PartialEq<TypedRect<T, U>> for TypedRect<T, U>
[src]
impl<T: PartialEq, U> PartialEq<TypedRect<T, U>> for TypedRect<T, U>
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: Eq, U> Eq for TypedRect<T, U>
[src]
impl<T: Eq, U> Eq for TypedRect<T, U>
impl<T, U> From<TypedSize2D<T, U>> for TypedRect<T, U> where
T: Copy + Zero,
[src]
impl<T, U> From<TypedSize2D<T, U>> for TypedRect<T, U> where
T: Copy + Zero,
fn from(size: TypedSize2D<T, U>) -> Self
[src]
fn from(size: TypedSize2D<T, U>) -> Self
Performs the conversion.
impl<T: Display, U> Display for TypedRect<T, U>
[src]
impl<T: Display, U> Display for TypedRect<T, U>
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Debug, U> Debug for TypedRect<T, U>
[src]
impl<T: Debug, U> Debug for TypedRect<T, U>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Copy + Mul<T, Output = T>, U> Mul<T> for TypedRect<T, U>
[src]
impl<T: Copy + Mul<T, Output = T>, U> Mul<T> for TypedRect<T, U>
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, scale: T) -> Self
[src]
fn mul(self, scale: T) -> Self
Performs the *
operation.
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
[src]
impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
type Output = TypedRect<T, U2>
The resulting type after applying the *
operator.
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U2>
[src]
fn mul(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U2>
Performs the *
operation.
impl<T: Copy + Div<T, Output = T>, U> Div<T> for TypedRect<T, U>
[src]
impl<T: Copy + Div<T, Output = T>, U> Div<T> for TypedRect<T, U>
type Output = Self
The resulting type after applying the /
operator.
fn div(self, scale: T) -> Self
[src]
fn div(self, scale: T) -> Self
Performs the /
operation.
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
[src]
impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
type Output = TypedRect<T, U1>
The resulting type after applying the /
operator.
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U1>
[src]
fn div(self, scale: TypedScale<T, U1, U2>) -> TypedRect<T, U1>
Performs the /
operation.
impl<T: Hash, U> Hash for TypedRect<T, U>
[src]
impl<T: Hash, U> Hash for TypedRect<T, U>
fn hash<H: Hasher>(&self, h: &mut H)
[src]
fn hash<H: Hasher>(&self, h: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Copy, U> Copy for TypedRect<T, U>
[src]
impl<T: Copy, U> Copy for TypedRect<T, U>
impl<T: Copy, U> Clone for TypedRect<T, U>
[src]
impl<T: Copy, U> Clone for TypedRect<T, U>
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Serialize, U> Serialize for TypedRect<T, U>
[src]
impl<T: Serialize, U> Serialize for TypedRect<T, U>
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de, T: Copy + Deserialize<'de>, U> Deserialize<'de> for TypedRect<T, U>
[src]
impl<'de, T: Copy + Deserialize<'de>, U> Deserialize<'de> for TypedRect<T, U>
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<T, U> Send for TypedRect<T, U> where
T: Send,
U: Send,
impl<T, U> Send for TypedRect<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for TypedRect<T, U> where
T: Sync,
U: Sync,
impl<T, U> Sync for TypedRect<T, U> where
T: Sync,
U: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> ToString for T where
T: Display + ?Sized,
[src]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,