pub struct Rect {
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}Expand description
A rectangle for scissor regions, layout bounds, and hit testing.
Uses terminal coordinates (0-indexed, origin at top-left).
Fields§
§x: u16Left edge (inclusive).
y: u16Top edge (inclusive).
width: u16Width in cells.
height: u16Height in cells.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn from_size(width: u16, height: u16) -> Rect
pub const fn from_size(width: u16, height: u16) -> Rect
Create a rectangle from origin with given size.
Sourcepub fn intersection(&self, other: &Rect) -> Rect
pub fn intersection(&self, other: &Rect) -> Rect
Compute the intersection with another rectangle.
Returns an empty rectangle if the rectangles don’t overlap.
Sourcepub fn inner(&self, margin: Sides) -> Rect
pub fn inner(&self, margin: Sides) -> Rect
Create a new rectangle inside the current one with the given margin.
Sourcepub fn union(&self, other: &Rect) -> Rect
pub fn union(&self, other: &Rect) -> Rect
Create a new rectangle that is the union of this rectangle and another.
The result is the smallest rectangle that contains both.
Sourcepub fn intersection_opt(&self, other: &Rect) -> Option<Rect>
pub fn intersection_opt(&self, other: &Rect) -> Option<Rect>
Compute the intersection with another rectangle, returning None if no overlap.
Trait Implementations§
impl Copy for Rect
impl Eq 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