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§
§impl Rect
impl Rect
pub 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.
pub 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.
pub fn intersect(&self, other: &Rect) -> Option<Rect>
pub fn intersect(&self, other: &Rect) -> Option<Rect>
Returns an intersection of two rectangles.
Returns None otherwise.
pub 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.
pub fn outset(&self, dx: f32, dy: f32) -> Option<Rect>
pub fn outset(&self, dx: f32, dy: f32) -> Option<Rect>
Outsets the rectangle by the specified offset.
pub fn transform(&self, ts: Transform) -> Option<Rect>
pub fn transform(&self, ts: Transform) -> Option<Rect>
Transforms the rect using the provided Transform.
This method is expensive.
pub fn bbox_transform(&self, bbox: NonZeroRect) -> Rect
pub fn bbox_transform(&self, bbox: NonZeroRect) -> Rect
Applies a bounding box transform.
pub fn to_non_zero_rect(&self) -> Option<NonZeroRect>
pub fn to_non_zero_rect(&self) -> Option<NonZeroRect>
Converts into NonZeroRect.
Trait Implementations§
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