pub struct Rect {
pub left: f32,
pub top: f32,
pub right: f32,
pub bottom: f32,
}Expand description
A rectangle defined by its bounds in floating-point coordinates.
Fields§
§left: f32§top: f32§right: f32§bottom: f32Implementations§
Source§impl Rect
impl Rect
Sourcepub fn from_xywh(x: f32, y: f32, w: f32, h: f32) -> Option<Rect>
pub fn from_xywh(x: f32, y: f32, w: f32, h: f32) -> Option<Rect>
Creates a rectangle from a position and size. Returns None for
non-positive width/height or non-finite coordinates.
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 a rectangle from bounds, normalizing the order of the edges.
pub fn width(&self) -> f32
pub fn height(&self) -> f32
pub fn center(&self) -> Point
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