pub struct Rectangle<T = f32> {
    pub x: T,
    pub y: T,
    pub width: T,
    pub height: T,
}Expand description
An axis-aligned rectangle.
Fields§
§x: TX coordinate of the top-left corner.
y: TY coordinate of the top-left corner.
width: TWidth of the rectangle.
height: THeight of the rectangle.
Implementations§
Source§impl Rectangle<f32>
 
impl Rectangle<f32>
Sourcepub const INFINITE: Self
 
pub const INFINITE: Self
A rectangle starting at negative infinity and with infinite width and height.
Sourcepub fn with_radius(radius: f32) -> Self
 
pub fn with_radius(radius: f32) -> Self
Creates a new square Rectangle with the center at the origin and
with the given radius.
Sourcepub fn with_vertices(
    top_left: Point,
    top_right: Point,
    bottom_left: Point,
) -> (Rectangle, Radians)
 
pub fn with_vertices( top_left: Point, top_right: Point, bottom_left: Point, ) -> (Rectangle, Radians)
Sourcepub fn offset(&self, container: &Rectangle) -> Vector
 
pub fn offset(&self, container: &Rectangle) -> Vector
Computes the offset that must be applied to the Rectangle to be placed
inside the given container.
Sourcepub fn is_within(&self, container: &Rectangle) -> bool
 
pub fn is_within(&self, container: &Rectangle) -> bool
Returns true if the current Rectangle is within the given
container. Includes the right and bottom edges.
Sourcepub fn intersection(&self, other: &Rectangle<f32>) -> Option<Rectangle<f32>>
 
pub fn intersection(&self, other: &Rectangle<f32>) -> Option<Rectangle<f32>>
Computes the intersection with the given Rectangle.
Sourcepub fn intersects(&self, other: &Self) -> bool
 
pub fn intersects(&self, other: &Self) -> bool
Returns whether the Rectangle intersects with the given one.
Sourcepub fn snap(self) -> Option<Rectangle<u32>>
 
pub fn snap(self) -> Option<Rectangle<u32>>
Snaps the Rectangle to unsigned integer coordinates.
Trait Implementations§
Source§impl Mul<Transformation> for Rectangle
 
impl Mul<Transformation> for Rectangle
impl<T: Copy> Copy for Rectangle<T>
impl<T: Eq> Eq for Rectangle<T>
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> Freeze for Rectangle<T>where
    T: Freeze,
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§
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