pub struct Rect {
pub origin: Point,
pub size: Size,
}Fields§
§origin: PointTop-left corner.
size: SizeWidth and height.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
Construct a rectangle from explicit x, y, width, height.
Sourcepub const fn from_origin_size(origin: Point, size: Size) -> Self
pub const fn from_origin_size(origin: Point, size: Size) -> Self
Sourcepub fn contains(&self, p: Point) -> bool
pub fn contains(&self, p: Point) -> bool
Returns true if p lies within the rectangle (inclusive of the
top/left edges, exclusive of the bottom/right edges).
Sourcepub fn intersects(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Returns true if this rectangle shares any interior area with other.
Sourcepub fn intersection(&self, other: &Rect) -> Option<Rect>
pub fn intersection(&self, other: &Rect) -> Option<Rect>
Returns the overlapping rectangle, or None if the two do not overlap.
Sourcepub fn union(&self, other: &Rect) -> Rect
pub fn union(&self, other: &Rect) -> Rect
Returns the smallest rectangle enclosing both self and other.
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