pub struct Rect { /* private fields */ }
Expand description
A rectangle defined by left, top, right and bottom edges.
Can have zero width and/or height. But not a negative one.
Guarantees
- All values are finite.
- Left edge is <= right.
- Top edge is <= bottom.
- Width and height are <= f32::MAX.
Implementations§
source§impl Rect
impl Rect
sourcepub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Option<Rect>
pub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Option<Rect>
Creates new Rect
.
sourcepub fn round(&self) -> Option<IntRect>
pub fn round(&self) -> Option<IntRect>
Converts into an IntRect
by adding 0.5 and discarding the fractional portion.
Width and height are guarantee to be >= 1.
sourcepub fn round_out(&self) -> Option<IntRect>
pub fn round_out(&self) -> Option<IntRect>
Converts into an IntRect
rounding outwards.
Width and height are guarantee to be >= 1.
sourcepub fn intersect(&self, other: &Rect) -> Option<Rect>
pub fn intersect(&self, other: &Rect) -> Option<Rect>
Returns an intersection of two rectangles.
Returns None
otherwise.
sourcepub fn from_points(points: &[Point]) -> Option<Rect>
pub fn from_points(points: &[Point]) -> Option<Rect>
Creates a Rect from Point array.
Returns None if count is zero or if Point array contains an infinity or NaN.
Trait Implementations§
source§impl PartialEq<Rect> for Rect
impl PartialEq<Rect> for Rect
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin 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