pub struct Rectangle { /* private fields */ }
Expand description
A Rectangle
is normally expressed as a top-left corner and a size
§Examples
let rectangle = Rectangle::new((0., 5.),(10., 7.));
assert_eq!(rectangle.x(), 0.);
assert_eq!(rectangle.y(), 5.);
assert_eq!(rectangle.width(), 10.);
assert_eq!(rectangle.height(), 7.);
Implementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn new(position: impl Into<Point>, size: impl Into<Size>) -> Rectangle
pub fn new(position: impl Into<Point>, size: impl Into<Size>) -> Rectangle
Create a new rectangle with the given parameters.
Sourcepub fn set_position(&mut self, position: impl Into<Point>)
pub fn set_position(&mut self, position: impl Into<Point>)
Sets position.
Sourcepub fn set_height(&mut self, height: impl Into<f64>)
pub fn set_height(&mut self, height: impl Into<f64>)
Sets the height.
Sourcepub fn set_size(&mut self, width: impl Into<f64>, height: impl Into<f64>)
pub fn set_size(&mut self, width: impl Into<f64>, height: impl Into<f64>)
Sets the size with width and height.
Sourcepub fn contains(&self, point: impl Into<Point>) -> bool
pub fn contains(&self, point: impl Into<Point>) -> bool
Checks if this rect contains the given point
.
Sourcepub fn contains_rect(&self, rect: &Rectangle) -> bool
pub fn contains_rect(&self, rect: &Rectangle) -> bool
Checks if this rect contains the given rect
.
Sourcepub fn intersects(&self, rect: &Rectangle) -> bool
pub fn intersects(&self, rect: &Rectangle) -> bool
Checks if this rect intersects with the given rect
.
Sourcepub fn join_with_rectangle(&mut self, other: &Rectangle)
pub fn join_with_rectangle(&mut self, other: &Rectangle)
Joins this rectangle with another one, the result is a rectangle in which the two parents fit.
Sourcepub fn join_with_point(&mut self, point: &Point)
pub fn join_with_point(&mut self, point: &Point)
Extends this rectangle to cover the given point.
Trait Implementations§
impl Copy for Rectangle
impl StructuralPartialEq for Rectangle
Auto Trait Implementations§
impl Freeze for Rectangle
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
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
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more