pub struct Rectangle<T> {
pub min: Point<T, T>,
pub max: Point<T, T>,
}Expand description
Represents a rectangle in 2D space
Fields§
§min: Point<T, T>§max: Point<T, T>Implementations§
Source§impl<T: Clone + Ord + Copy + Add<Output = T>> Rectangle<T>
impl<T: Clone + Ord + Copy + Add<Output = T>> Rectangle<T>
Sourcepub fn from_dimensions(origin: Point<T, T>, width: T, height: T) -> Self
pub fn from_dimensions(origin: Point<T, T>, width: T, height: T) -> Self
Creates a rectangle from origin, width, and height
Sourcepub fn overlaps(&self, other: &Self) -> bool
pub fn overlaps(&self, other: &Self) -> bool
Checks if this rectangle overlaps with another
§Examples
use physdes::{Point, vlsi_ops::Rectangle};
let rect1 = Rectangle::new(Point::new(0, 0), Point::new(10, 10));
let rect2 = Rectangle::new(Point::new(5, 5), Point::new(15, 15));
assert!(rect1.overlaps(&rect2));
let rect3 = Rectangle::new(Point::new(20, 20), Point::new(30, 30));
assert!(!rect1.overlaps(&rect3));Sourcepub fn contains(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
Checks if this rectangle contains another rectangle
Sourcepub fn contains_point(&self, point: &Point<T, T>) -> bool
pub fn contains_point(&self, point: &Point<T, T>) -> bool
Checks if this rectangle contains a point
Sourcepub fn intersect(&self, other: &Self) -> Option<Self>where
T: Add<Output = T>,
pub fn intersect(&self, other: &Self) -> Option<Self>where
T: Add<Output = T>,
Computes the intersection with another rectangle
Returns None if the rectangles don’t overlap
Sourcepub fn bounding_rect(&self, other: &Self) -> Self
pub fn bounding_rect(&self, other: &Self) -> Self
Computes the bounding rectangle of two rectangles
Trait Implementations§
Source§impl<T: PartialEq> PartialEq for Rectangle<T>
impl<T: PartialEq> PartialEq for Rectangle<T>
impl<T: Eq> Eq for Rectangle<T>
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> Freeze for Rectangle<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rectangle<T>where
T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where
T: Send,
impl<T> Sync for Rectangle<T>where
T: Sync,
impl<T> Unpin for Rectangle<T>where
T: Unpin,
impl<T> UnsafeUnpin for Rectangle<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Rectangle<T>where
T: UnwindSafe,
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