#[repr(C)]pub struct Rectangle<T = f32> { /* private fields */ }Expand description
A struct representing an axis-aligned rectangle. Two points are stored: the top left vertex, and the bottom right vertex.
Implementations
sourceimpl<T> Rectangle<T>
impl<T> Rectangle<T>
sourcepub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
pub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
Constructs a new Rectangle. The top left vertex must be above and to
the left of the bottom right vertex.
sourcepub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
pub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
Constructs a new Rectangle. The top left vertex must be above and to
the left of the bottom right vertex.
sourcepub const fn bottom_right(&self) -> &Vector2<T>
pub const fn bottom_right(&self) -> &Vector2<T>
Returns a reference to the bottom right vertex.
sourceimpl<T: PartialOrd<T> + Copy> Rectangle<T>
impl<T: PartialOrd<T> + Copy> Rectangle<T>
sourceimpl<T: PrimitiveZero> Rectangle<T>
impl<T: PrimitiveZero> Rectangle<T>
sourceimpl<T: PartialEq> Rectangle<T>
impl<T: PartialEq> Rectangle<T>
sourcepub fn is_zero_area(&self) -> bool
pub fn is_zero_area(&self) -> bool
Returns true if the rectangle has zero area.
sourceimpl<T: Copy> Rectangle<T>where
Vector2<T>: Add<Output = Vector2<T>>,
impl<T: Copy> Rectangle<T>where
Vector2<T>: Add<Output = Vector2<T>>,
sourcepub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are offset relative to the current rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.
sourceimpl<T: Copy> Rectangle<T>where
Vector2<T>: Sub<Output = Vector2<T>>,
impl<T: Copy> Rectangle<T>where
Vector2<T>: Sub<Output = Vector2<T>>,
sourcepub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are negatively offset relative to the current rectangle by the specified amount. This is equivalent to subtracting the specified vector to each vertex.
Trait Implementations
sourceimpl<T: PartialEq> PartialEq<Rectangle<T>> for Rectangle<T>
impl<T: PartialEq> PartialEq<Rectangle<T>> for Rectangle<T>
impl<T: Eq> Eq for Rectangle<T>
impl<T> StructuralEq for Rectangle<T>
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Rectangle<T>where
T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where
T: Send,
impl<T> Sync for Rectangle<T>where
T: Sync,
impl<T> Unpin for Rectangle<T>where
T: Unpin,
impl<T> UnwindSafe for Rectangle<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more