Struct orbtk_utils::Rectangle
source · [−]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
sourceimpl Rectangle
impl Rectangle
sourcepub fn new(position: impl Into<Point>, size: impl Into<Size>) -> Self
pub fn new(position: impl Into<Point>, size: impl Into<Size>) -> Self
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 RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more