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.