pub struct Rect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}Expand description
An axis-aligned rectangle defined by its top-left corner and dimensions.
Fields§
§x: f64The x coordinate of the left edge.
y: f64The y coordinate of the top edge.
width: f64The width of the rectangle (must be non-negative for well-formed rects).
height: f64The height of the rectangle (must be non-negative for well-formed rects).
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(x: f64, y: f64, width: f64, height: f64) -> Self
pub fn new(x: f64, y: f64, width: f64, height: f64) -> Self
Creates a new rectangle from a top-left corner and dimensions.
Sourcepub fn from_points(p1: Point, p2: Point) -> Self
pub fn from_points(p1: Point, p2: Point) -> Self
Creates the smallest axis-aligned rectangle that contains both points.
The two points may be any pair of opposite corners; the result is always a rectangle with non-negative width and height.
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