pub struct Rect {
pub origin: Point,
pub size: Size,
}Expand description
An axis-aligned rectangle in logical-pixel space, defined by its top-left
origin and its size.
Fields§
§origin: Point§size: SizeImplementations§
Source§impl Rect
impl Rect
pub const ZERO: Self
pub const fn new(origin: Point, size: Size) -> Self
Sourcepub const fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
pub const fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
Construct from individual coordinates.
Sourcepub fn from_points(a: Point, b: Point) -> Self
pub fn from_points(a: Point, b: Point) -> Self
Construct from two corner points (in any order).
pub fn min_x(self) -> f64
pub fn min_y(self) -> f64
pub fn max_x(self) -> f64
pub fn max_y(self) -> f64
pub fn width(self) -> f64
pub fn height(self) -> f64
pub fn center(self) -> Point
pub fn is_empty(self) -> bool
Sourcepub fn contains(self, p: Point) -> bool
pub fn contains(self, p: Point) -> bool
True if p lies within the rectangle (left/top inclusive,
right/bottom exclusive — the standard half-open convention for
pixel coverage and hit-testing).
Sourcepub fn inset(self, insets: Insets) -> Rect
pub fn inset(self, insets: Insets) -> Rect
Shrink inward by insets on each edge, clamping to a non-negative size.
Sourcepub fn intersection(self, other: Rect) -> Option<Rect>
pub fn intersection(self, other: Rect) -> Option<Rect>
The overlapping region of two rectangles, or None if disjoint.
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