#[repr(C)]pub struct Rect<T = f32> {
pub origin: Point<T>,
pub size: Size<T>,
}Expand description
Axis-Aligned Bounding Box (AABB) Rectangle.
Fields§
§origin: Point<T>§size: Size<T>Implementations§
Source§impl Rect
impl Rect
pub const ZERO: Rect
pub const fn from_xywh(x: f32, y: f32, width: f32, height: f32) -> Rect
pub fn x(self) -> f32
pub fn y(self) -> f32
pub fn width(self) -> f32
pub fn height(self) -> f32
pub fn min_x(self) -> f32
pub fn max_x(self) -> f32
pub fn min_y(self) -> f32
pub fn max_y(self) -> f32
pub fn contains_point(self, p: Point) -> bool
pub fn intersects(self, other: Rect) -> bool
Sourcepub fn intersection(self, other: Rect) -> Option<Rect>
pub fn intersection(self, other: Rect) -> Option<Rect>
Computes intersection rect with another rectangle.
Sourcepub fn union(self, other: Rect) -> Rect
pub fn union(self, other: Rect) -> Rect
Computes minimal bounding rect containing both rectangles.
Sourcepub fn deflate(self, insets: EdgeInsets) -> Rect
pub fn deflate(self, insets: EdgeInsets) -> Rect
Deflates rectangle by insets (e.g. for padding/borders).
Sourcepub fn inflate(self, insets: EdgeInsets) -> Rect
pub fn inflate(self, insets: EdgeInsets) -> Rect
Inflates rectangle by insets (e.g. for margins/hit-testing).
Trait Implementations§
impl<T> Copy for Rect<T>where
T: Copy,
impl<T> StructuralPartialEq for Rect<T>where
T: PartialEq,
Auto Trait Implementations§
impl<T> Forget for Rect<T>
impl<T> Freeze for Rect<T>
impl<T> Move for Rect<T>
impl<T> RefUnwindSafe for Rect<T>
impl<T> Send for Rect<T>
impl<T> Sync for Rect<T>
impl<T> Unpin for Rect<T>
impl<T> UnsafeUnpin for Rect<T>
impl<T> UnwindSafe for Rect<T>
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