pub struct Rect {
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}Expand description
An axis-aligned rectangle in the cell grid.
The rectangle is anchored at its top-left corner (x, y) and extends
width cells to the right and height cells down. The right and
bottom edges are exclusive: a cell at (x, y) is contained iff
left() <= x < right() and top() <= y < bottom().
Fields§
§x: u16Column of the top-left corner.
y: u16Row of the top-left corner.
width: u16Width in cells.
height: u16Height in cells.
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 rectangle from (x, y, width, height).
width and height are clamped so that right() and bottom()
stay within u16.
Sourcepub fn contains(self, pos: impl Into<Position>) -> bool
pub fn contains(self, pos: impl Into<Position>) -> bool
True when pos lies inside the rectangle.
Sourcepub fn intersection(self, other: Self) -> Self
pub fn intersection(self, other: Self) -> Self
The largest rectangle contained in both self and other.
Trait Implementations§
Source§impl Bounded for Rect
impl Bounded for Rect
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,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of [
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString]. Read more