pub struct Rectangle<T> {
pub min: Point<T>,
pub max: Point<T>,
}
Expand description
Fields§
§min: Point<T>
origin x points of the rectangle
max: Point<T>
origin y points of the rectangle
Implementations§
Source§impl<T> Rectangle<T>
Constructors for rectangle_2d
impl<T> Rectangle<T>
Constructors for rectangle_2d
Sourcepub fn from_anchor<P>(origin: P, width: T, height: T) -> Rectangle<T>
pub fn from_anchor<P>(origin: P, width: T, height: T) -> Rectangle<T>
Sourcepub fn from_center<P>(center: P, width: T, height: T) -> Rectangle<T>
pub fn from_center<P>(center: P, width: T, height: T) -> Rectangle<T>
pub fn from_origin(width: T, height: T) -> Rectangle<T>
Sourcepub fn from_min_max<P1, P2>(min: P1, max: P2) -> Rectangle<T>
pub fn from_min_max<P1, P2>(min: P1, max: P2) -> Rectangle<T>
Source§impl<T> Rectangle<T>
impl<T> Rectangle<T>
Sourcepub fn width(&self) -> T
pub fn width(&self) -> T
Get the width of the rectangle
§Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.width(), 1.0);
Sourcepub fn height(&self) -> T
pub fn height(&self) -> T
Get the height of the rectangle
§Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.height(), 1.0);
Sourcepub fn origin(&self) -> Point<T>where
T: Clone,
pub fn origin(&self) -> Point<T>where
T: Clone,
Get the origin of the rectangle
§Examples
let rect = Rectangle::from_center((0.0, 0.0), 1.0,1.0);
assert_eq!(rect.origin(), -Point::new(0.5, 0.5));
Sourcepub fn center(&self) -> Point<T>
pub fn center(&self) -> Point<T>
Get the center point of the rectangle
§Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.center(), Point::new(0.5, 0.5));
pub fn contains(&self, point: &Point<T>) -> boolwhere
T: Clone + PartialOrd,
Trait Implementations§
Source§impl<T> BitAndAssign for Rectangle<T>where
T: PartialOrd,
impl<T> BitAndAssign for Rectangle<T>where
T: PartialOrd,
Source§fn bitand_assign(&mut self, rhs: Rectangle<T>)
fn bitand_assign(&mut self, rhs: Rectangle<T>)
Returns the intersection of two rectangles, possibly with negative area, meaning the empty set
Source§impl<T> BitOrAssign for Rectangle<T>where
T: PartialOrd,
impl<T> BitOrAssign for Rectangle<T>where
T: PartialOrd,
Source§fn bitor_assign(&mut self, rhs: Rectangle<T>)
fn bitor_assign(&mut self, rhs: Rectangle<T>)
Returns a larger rectangle that encompasses these two rectangles
Source§impl<T> Shape2D for Rectangle<T>
impl<T> Shape2D for Rectangle<T>
Source§fn is_valid(&self) -> bool
fn is_valid(&self) -> bool
A valid rectangle means it has a positive area.
§Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert!(rect.is_valid());
Source§fn vertices<'a>(
&'a self,
_: usize,
) -> <Rectangle<T> as Shape2D>::VertexIterator<'a>
fn vertices<'a>( &'a self, _: usize, ) -> <Rectangle<T> as Shape2D>::VertexIterator<'a>
Returns four vertices counterclockwise in the ↑Y coordinate system
Source§fn edges<'a>(&'a self, _: usize) -> <Rectangle<T> as Shape2D>::LineIterator<'a>
fn edges<'a>(&'a self, _: usize) -> <Rectangle<T> as Shape2D>::LineIterator<'a>
Returns four edges counterclockwise in the ↑Y coordinate system
Source§type VertexIterator<'a> = IntoIter<Point<T>>
where
T: 'a
type VertexIterator<'a> = IntoIter<Point<T>> where T: 'a
The value type of the shape.
Source§type LineIterator<'a> = IntoIter<Line<T>>
where
T: 'a
type LineIterator<'a> = IntoIter<Line<T>> where T: 'a
The value type of the shape.
impl<T> Copy for Rectangle<T>where
T: Copy,
impl<T> Eq for Rectangle<T>where
T: Eq,
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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