Struct euclid::TypedRect[][src]

#[repr(C)]
pub struct TypedRect<T, U = UnknownUnit> { pub origin: TypedPoint2D<T, U>, pub size: TypedSize2D<T, U>, }

A 2d Rectangle optionally tagged with a unit.

Fields

Methods

impl<T, U> TypedRect<T, U>
[src]

Constructor.

impl<T, U> TypedRect<T, U> where
    T: Copy + Zero
[src]

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]

Returns the same rectangle, translated by a vector.

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.

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.

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.

Calculate the size and position of an outer rectangle.

Add the offsets to all sides. The expanded rectangle is returned.

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]

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 + Clone + PartialOrd + Add<T, Output = T> + Sub<T, Output = T> + Zero
[src]

impl<T, U> TypedRect<T, U>
[src]

impl<T: Copy + PartialEq + Zero, U> TypedRect<T, U>
[src]

Constructor, setting all sides to zero.

Returns true if the size is zero, regardless of the origin's value.

impl<T: Copy, Unit> TypedRect<T, Unit>
[src]

Drop the units, preserving only the numeric value.

Tag a unitless value with units.

impl<T0: NumCast + Copy, Unit> TypedRect<T0, Unit>
[src]

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.

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]

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).

Return a rectangle with edges rounded to integer coordinates, such that the original rectangle contains the resulting rectangle.

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]

Cast into an f32 rectangle.

Cast into an f64 rectangle.

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.

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.

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.

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: Hash, U> Hash for TypedRect<T, U>
[src]

Feeds this value into the given [Hasher]. Read more

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> Clone for TypedRect<T, U>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: PartialEq, U> PartialEq<TypedRect<T, U>> for TypedRect<T, U>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: Eq, U> Eq for TypedRect<T, U>
[src]

impl<T: Debug, U> Debug for TypedRect<T, U>
[src]

Formats the value using the given formatter. Read more

impl<T: Display, U> Display for TypedRect<T, U>
[src]

Formats the value using the given formatter. Read more

impl<T: Copy + Mul<T, Output = T>, U> Mul<T> for TypedRect<T, U>
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U> Div<T> for TypedRect<T, U>
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<T: Copy + Mul<T, Output = T>, U1, U2> Mul<TypedScale<T, U1, U2>> for TypedRect<T, U1>
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<T: Copy + Div<T, Output = T>, U1, U2> Div<TypedScale<T, U1, U2>> for TypedRect<T, U2>
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<T, U> From<TypedSize2D<T, U>> for TypedRect<T, U> where
    T: Copy + Zero
[src]

Performs the conversion.

Auto Trait Implementations

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