Expand description
An axis aligned rectangle. Stored as two Ranges.
Fields
x: Range<T>
y: Range<T>
Implementations
sourceimpl<T> Rect<T> where
T: Sub<T, Output = T> + Add<T, Output = T> + Copy,
impl<T> Rect<T> where
T: Sub<T, Output = T> + Add<T, Output = T> + Copy,
sourcepub fn from_point(point: Vec2<T>, radius: Vec2<T>) -> Rect<T>
pub fn from_point(point: Vec2<T>, radius: Vec2<T>) -> Rect<T>
Create a rectangle from a point and radius.
sourceimpl<T> Rect<T> where
T: Copy,
impl<T> Rect<T> where
T: Copy,
sourceimpl<T> Rect<T> where
T: PartialOrd<T> + Copy,
impl<T> Rect<T> where
T: PartialOrd<T> + Copy,
sourcepub fn contains_point(&self, a: Vec2<T>) -> bool
pub fn contains_point(&self, a: Vec2<T>) -> bool
Returns true if the point is contained in the the ranges of both axis.
sourceimpl<T> Rect<T> where
T: Sub<T, Output = T> + Mul<T, Output = T> + Add<T, Output = T> + Copy + PartialOrd<T>,
impl<T> Rect<T> where
T: Sub<T, Output = T> + Mul<T, Output = T> + Add<T, Output = T> + Copy + PartialOrd<T>,
sourcepub fn distance_squared_to_point(&self, point: Vec2<T>) -> Option<T>
pub fn distance_squared_to_point(&self, point: Vec2<T>) -> Option<T>
If the point is outside the rectangle, returns the squared distance from the closest corner of the rectangle. If the point is inside the rectangle, it will return None.
sourcepub fn furthest_distance_squared_to_point(&self, point: Vec2<T>) -> T
pub fn furthest_distance_squared_to_point(&self, point: Vec2<T>) -> T
If the point is outside the rectangle, returns the squared distance from a point to the furthest corner of the rectangle.
sourceimpl<T> Rect<T> where
T: PartialOrd<T> + Copy,
impl<T> Rect<T> where
T: PartialOrd<T> + Copy,
sourcepub fn subdivide<A>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>) where
A: Axis,
pub fn subdivide<A>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>) where
A: Axis,
Subdivides the rectangle.
No floating point calculations are done.
Important to note that a point that was in the original rectangle,
could actually be inside both subdivded rectangles.
This is because the ranges are inclusive on both sides [start,end]
.
sourcepub fn contains_rect(&self, rect: &Rect<T>) -> bool
pub fn contains_rect(&self, rect: &Rect<T>) -> bool
Returns true if the specified rect is inside of this rect.
pub fn grow_to_fit_point(&mut self, point: Vec2<T>) -> &mut Rect<T>
sourcepub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Rect<T>
pub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Rect<T>
Grow the rectangle to fit the specified rectangle by replacing values with the specified rectangle. No floating point computations.
pub fn intersects_rect(&self, other: &Rect<T>) -> bool
sourceimpl<T> Rect<T> where
T: PartialOrd<T> + Copy,
impl<T> Rect<T> where
T: PartialOrd<T> + Copy,
sourcepub fn get_intersect_rect(&self, other: &Rect<T>) -> Option<Rect<T>>
pub fn get_intersect_rect(&self, other: &Rect<T>) -> Option<Rect<T>>
Get an intersecting rectangle. No floating point calculations as the new rectangle is made up of values from this rectangle and the specified rectangle.
Trait Implementations
impl<T> Copy for Rect<T> where
T: Copy,
impl<T> Eq for Rect<T> where
T: Eq,
impl<'a, N> ManySwap for Rect<N>
impl<'a, N> ManySwap for &'a mut Rect<N>
impl<T> StructuralEq for Rect<T>
impl<T> StructuralPartialEq for Rect<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Rect<T> where
T: RefUnwindSafe,
impl<T> Send for Rect<T> where
T: Send,
impl<T> Sync for Rect<T> where
T: Sync,
impl<T> Unpin for Rect<T> where
T: Unpin,
impl<T> UnwindSafe for Rect<T> where
T: UnwindSafe,
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
impl<T> Pointable for T
impl<T> Pointable for T
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)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more