pub struct Rect<T> {
pub x: T,
pub y: T,
pub width: T,
pub height: T,
}Fields§
§x: T§y: T§width: T§height: TImplementations§
Source§impl<T> Rect<T>
impl<T> Rect<T>
Sourcepub fn from_pos_and_size(pos: Vec2<T>, size: Size<T>) -> Self
pub fn from_pos_and_size(pos: Vec2<T>, size: Size<T>) -> Self
Create a new rectangle from a position and a size.
Sourcepub fn aspect_ratio(&self) -> f32
pub fn aspect_ratio(&self) -> f32
Returns the aspect ratio of the rectangle.
Sourcepub fn intersection(&self, other: &Self) -> Option<Self>
pub fn intersection(&self, other: &Self) -> Option<Self>
Get the intersection of two rectangles.
Source§impl Rect<f32>
impl Rect<f32>
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Check if the rectangle intersects another rectangle.
Sourcepub fn contains_point(&self, point: Vec2<f32>) -> bool
pub fn contains_point(&self, point: Vec2<f32>) -> bool
Check if the rectangle contains a point.
Sourcepub fn contains_rect(&self, other: &Self) -> bool
pub fn contains_rect(&self, other: &Self) -> bool
Check if the rectangle contains another rectangle.
Trait Implementations§
impl<T: Copy> Copy for Rect<T>
impl<T: Eq> Eq for Rect<T>
impl<T> StructuralPartialEq for Rect<T>
Auto Trait Implementations§
impl<T> Freeze for Rect<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rect<T>where
T: RefUnwindSafe,
impl<T> Send for Rect<T>where
T: Send,
impl<T> Sync for Rect<T>where
T: Sync,
impl<T> Unpin for Rect<T>where
T: Unpin,
impl<T> UnwindSafe for Rect<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