pub struct Rect {
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}Expand description
A rectangular area in the terminal.
Fields§
§x: u16Column of the top-left corner.
y: u16Row of the top-left corner.
width: u16Width in columns.
height: u16Height in rows.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn new(x: u16, y: u16, width: u16, height: u16) -> Self
pub const fn new(x: u16, y: u16, width: u16, height: u16) -> Self
Create a new rect, clamping width/height so the rect does not overflow
u16.
Sourcepub const fn inner(self, margin: Margin) -> Self
pub const fn inner(self, margin: Margin) -> Self
Shrink this rect by the given margin on all sides.
Sourcepub const fn outer(self, margin: Margin) -> Self
pub const fn outer(self, margin: Margin) -> Self
Expand this rect by the given margin on all sides.
Sourcepub fn offset(self, offset: Offset) -> Self
pub fn offset(self, offset: Offset) -> Self
Move this rect by the given offset, clamping to the valid u16 range.
Sourcepub const fn resize(self, size: Size) -> Self
pub const fn resize(self, size: Size) -> Self
Resize this rect to the given dimensions, keeping the top-left corner.
Sourcepub fn intersection(self, other: Self) -> Self
pub fn intersection(self, other: Self) -> Self
The overlap between self and other.
Returns a zero-area rect if they do not intersect.
Sourcepub const fn intersects(self, other: Self) -> bool
pub const fn intersects(self, other: Self) -> bool
Returns true if self and other overlap.
Sourcepub const fn contains(self, position: Position) -> bool
pub const fn contains(self, position: Position) -> bool
Returns true if the given position lies inside this rect.
Sourcepub const fn columns(self) -> Columns ⓘ
pub const fn columns(self) -> Columns ⓘ
Iterate over each column in this rect as a 1-cell-wide Rect.
Sourcepub const fn as_position(self) -> Position
pub const fn as_position(self) -> Position
Return the top-left corner as a Position.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.