pub struct RectU16 {
pub x0: u16,
pub y0: u16,
pub x1: u16,
pub y1: u16,
}Expand description
An axis-aligned rectangle with u16 coordinates, stored as two corners (x0, y0) and
(x1, y1).
(x0, y0) is the top-left (minimum) corner and (x1, y1) is the bottom-right (maximum) corner.
The rectangle is considered to be empty when x0 >= x1 or y0 >= y1.
Fields§
§x0: u16The minimum x coordinate (left edge).
y0: u16The minimum y coordinate (top edge).
x1: u16The maximum x coordinate (right edge, exclusive).
y1: u16The maximum y coordinate (bottom edge, exclusive).
Implementations§
Source§impl RectU16
impl RectU16
Sourcepub const INVERTED: RectU16
pub const INVERTED: RectU16
An empty, maximally inverted rectangle, useful as a starting value for incremental union operations.
Has (x0, y0) = (u16::MAX, u16::MAX) and (x1, y1) = (0, 0).
Sourcepub const fn new(x0: u16, y0: u16, x1: u16, y1: u16) -> RectU16
pub const fn new(x0: u16, y0: u16, x1: u16, y1: u16) -> RectU16
Create a new rectangle from its corner coordinates.
Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Returns true if the rectangle has zero area (x0 >= x1 or y0 >= y1).
Sourcepub const fn contains(self, x: u16, y: u16) -> bool
pub const fn contains(self, x: u16, y: u16) -> bool
Check if a point (x, y) is contained within this rectangle.
Returns true if x0 <= x < x1 and y0 <= y < y1.
Sourcepub const fn intersect(self, other: RectU16) -> RectU16
pub const fn intersect(self, other: RectU16) -> RectU16
Compute the intersection of two rectangles.
The result may have zero area if the rectangles do not overlap, but is never inverted.
Sourcepub const fn expand(self, padding: PaddingU16) -> RectU16
pub const fn expand(self, padding: PaddingU16) -> RectU16
Expand this rectangle by the given left, top, right, and bottom padding.
Sourcepub fn relative_to_origin(self, origin: (u16, u16)) -> RectU16
pub fn relative_to_origin(self, origin: (u16, u16)) -> RectU16
Return this rectangle relative to origin, clamping negative coordinates to zero.
Sourcepub fn shift(self, shift: (i32, i32)) -> RectU16
pub fn shift(self, shift: (i32, i32)) -> RectU16
Return a shifted version of the rectangle, clamping negative coordinates to zero.
Sourcepub const fn union(&mut self, other: RectU16)
pub const fn union(&mut self, other: RectU16)
Expand this rectangle to also cover other (union in place).
The union of self with a Self::INVERTED returns self.
Trait Implementations§
impl Copy for RectU16
impl Eq for RectU16
Source§impl RectExt for RectU16
impl RectExt for RectU16
Source§fn snap_to_tile_coordinates(self) -> RectU16
fn snap_to_tile_coordinates(self) -> RectU16
impl StructuralPartialEq for RectU16
Auto Trait Implementations§
impl Freeze for RectU16
impl RefUnwindSafe for RectU16
impl Send for RectU16
impl Sync for RectU16
impl Unpin for RectU16
impl UnsafeUnpin for RectU16
impl UnwindSafe for RectU16
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
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§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
key and return true if they are equal.