pub struct Rect {
pub origin: Point,
pub size: Size,
}Expand description
An axis-aligned rectangle defined by origin + size.
Origin + size is the canonical representation. Edge accessors
(left, top, right, bottom) are provided for convenience.
Fields§
§origin: Point§size: SizeImplementations§
Source§impl Rect
impl Rect
pub const ZERO: Self
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub fn from_origin_size(origin: Point, size: Size) -> Self
Sourcepub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Self
pub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Self
Construct from left, top, right, bottom edges.
pub fn x(&self) -> f32
pub fn y(&self) -> f32
pub fn width(&self) -> f32
pub fn height(&self) -> f32
pub fn left(&self) -> f32
pub fn top(&self) -> f32
pub fn right(&self) -> f32
pub fn bottom(&self) -> f32
pub fn center(&self) -> Point
pub fn is_empty(&self) -> bool
pub fn contains_point(&self, p: Point) -> bool
pub fn contains_rect(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Sourcepub fn intersection(&self, other: &Rect) -> Option<Self>
pub fn intersection(&self, other: &Rect) -> Option<Self>
Returns the intersection of two rects, or None if they don’t overlap.
Sourcepub fn inset(&self, top: f32, right: f32, bottom: f32, left: f32) -> Self
pub fn inset(&self, top: f32, right: f32, bottom: f32, left: f32) -> Self
Shrink each edge inward by per-edge amounts. Clamps size to zero.
Sourcepub fn outset(&self, top: f32, right: f32, bottom: f32, left: f32) -> Self
pub fn outset(&self, top: f32, right: f32, bottom: f32, left: f32) -> Self
Expand each edge outward by per-edge amounts.
pub fn translate(&self, offset: Offset) -> Self
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnsafeUnpin for Rect
impl UnwindSafe for Rect
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