#[repr(C)]pub struct Rect {
pub x0: f64,
pub y0: f64,
pub x1: f64,
pub y1: f64,
}
Expand description
A rectangle. Derived from kurbo.
Fields§
§x0: f64
The minimum x coordinate (left edge).
y0: f64
The minimum y coordinate (top edge in y-down spaces).
x1: f64
The maximum x coordinate (right edge).
y1: f64
The maximum y coordinate (bottom edge in y-down spaces).
Implementations§
source§impl Rect
impl Rect
sourcepub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
pub const fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> Rect
A new rectangle from minimum and maximum coordinates.
sourcepub fn from_points(p0: impl Into<Point>, p1: impl Into<Point>) -> Rect
pub fn from_points(p0: impl Into<Point>, p1: impl Into<Point>) -> Rect
A new rectangle from two points.
The result will have non-negative width and height.
sourcepub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect
pub fn from_origin_size(origin: impl Into<Point>, size: impl Into<Size>) -> Rect
A new rectangle from origin and size.
The result will have non-negative width and height.
sourcepub fn with_origin(self, origin: impl Into<Point>) -> Rect
pub fn with_origin(self, origin: impl Into<Point>) -> Rect
Create a new Rect
with the same size as self
and a new origin.
sourcepub fn with_size(self, size: impl Into<Size>) -> Rect
pub fn with_size(self, size: impl Into<Size>) -> Rect
Create a new Rect
with the same origin as self
and a new size.
sourcepub fn height(&self) -> f64
pub fn height(&self) -> f64
The height of the rectangle.
Note: nothing forbids negative height.
sourcepub fn origin(&self) -> Point
pub fn origin(&self) -> Point
The origin of the rectangle.
This is the top left corner in a y-down space and with non-negative width and height.
sourcepub fn abs(&self) -> Rect
pub fn abs(&self) -> Rect
Take absolute value of width and height.
The resulting rect has the same extents as the original, but is guaranteed to have non-negative width and height.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this rectangle has zero area.
Note: a rectangle with negative area is not considered empty.
sourcepub fn union(&self, other: Rect) -> Rect
pub fn union(&self, other: Rect) -> Rect
The smallest rectangle enclosing two rectangles.
Results are valid only if width and height are non-negative.
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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)