Implementations
sourceimpl<N: Number, U: Unit> Rect<N, U>
impl<N: Number, U: Unit> Rect<N, U>
pub fn new_u(
origin: impl Into<[N; 2]>,
size: impl Into<[N; 2]>,
unit: U
) -> Rect<N, U>
pub fn new_u_min_max(
min: impl Into<[N; 2]>,
max: impl Into<[N; 2]>,
unit: U
) -> Rect<N, U>
pub fn cast<NO: Number>(self) -> Option<Rect<NO, U>>
pub fn convert_def<UO: UnitCompatibility<N, U> + Default>(
self
) -> Option<Rect<N, UO>>
pub fn convert_u<UO: UnitCompatibility<N, U>>(
self,
to: UO
) -> Option<Rect<N, UO>>
sourcepub fn intersects_rect(&self, other: Rect<N, U>) -> bool
pub fn intersects_rect(&self, other: Rect<N, U>) -> bool
Checks if self intersects other. In other words it check if any of these rectangles touch each other. This is very useful in cull testing.
Arguments
other
: The other rectangle to check intersection with.
returns: bool
Examples
use mathie::Rect;
let rect = Rect::new_any([0.0, 0.0], [1.0, 1.0]);
assert!(rect.intersects_rect(Rect::new_any([0.0, 0.0], [1.0, 1.0])));
assert!(rect.intersects_rect(Rect::new_any([0.4, 0.4], [0.2, 0.2])));
assert!(rect.intersects_rect(Rect::new_any([1.0, 1.0], [1.0, 1.0])));
assert!(rect.intersects_rect(Rect::new_any([0.0, 0.5], [0.5, 1.0])));
assert!(!rect.intersects_rect(Rect::new_any([1.1, 1.1], [1.0, 1.0])));
assert!(!rect.intersects_rect(Rect::new_any([-0.1, -0.1], [0.09, 0.09])));
sourcepub fn contains_rect(&self, rect: Rect<N, U>) -> bool
pub fn contains_rect(&self, rect: Rect<N, U>) -> bool
Checks if self
contains other
, in other words, it checks if self
fully contains other
.
Arguments
other
: The other rectangle to check if it is inside self.
returns: bool
Examples
use mathie::Rect;
let rect = Rect::new_any([0.0, 0.0], [1.0, 1.0]);
assert!(rect.contains_rect(Rect::new_any([0.0, 0.0], [1.0, 1.0])));
assert!(rect.contains_rect(Rect::new_any([0.4, 0.4], [0.2, 0.2])));
assert!(!rect.contains_rect(Rect::new_any([1.0, 1.0], [1.0, 1.0])));
assert!(!rect.contains_rect(Rect::new_any([0.0, 0.5], [0.5, 1.0])));
assert!(!rect.contains_rect(Rect::new_any([1.1, 1.1], [1.0, 1.0])));
assert!(!rect.contains_rect(Rect::new_any([-0.1, -0.1], [0.09, 0.09])));
sourcepub fn contains_pos(&self, pos: Vec2D<N, U>) -> bool
pub fn contains_pos(&self, pos: Vec2D<N, U>) -> bool
Checks if this position is inside this rectangle
sourcepub fn bottom_right(self) -> Vec2D<N, U>
pub fn bottom_right(self) -> Vec2D<N, U>
Gets the bottom right corner
sourcepub fn bottom_left(self) -> Vec2D<N, U>
pub fn bottom_left(self) -> Vec2D<N, U>
Gets the bottom left corner
pub fn top(self) -> N
pub fn left(self) -> N
pub fn bottom(self) -> N
pub fn right(self) -> N
pub fn center(self) -> Vec2D<N, U>
pub fn min(self) -> Vec2D<N, U>
pub fn max(self) -> Vec2D<N, U>
Trait Implementations
sourceimpl<T: Number, U: Unit> AddAssign<Rect<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> AddAssign<Rect<T, U>> for Rect<T, U>
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl<T: Number, U: Unit> AddAssign<T> for Rect<T, U>
impl<T: Number, U: Unit> AddAssign<T> for Rect<T, U>
sourcefn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the +=
operation. Read more
sourceimpl<T: Number, U: Unit> AddAssign<Vec2D<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> AddAssign<Vec2D<T, U>> for Rect<T, U>
sourcefn add_assign(&mut self, rhs: Vec2D<T, U>)
fn add_assign(&mut self, rhs: Vec2D<T, U>)
Performs the +=
operation. Read more
sourceimpl<T: Number, U: Unit> DivAssign<Rect<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> DivAssign<Rect<T, U>> for Rect<T, U>
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /=
operation. Read more
sourceimpl<T: Number, U: Unit> DivAssign<T> for Rect<T, U>
impl<T: Number, U: Unit> DivAssign<T> for Rect<T, U>
sourcefn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the /=
operation. Read more
sourceimpl<T: Number, U: Unit> DivAssign<Vec2D<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> DivAssign<Vec2D<T, U>> for Rect<T, U>
sourcefn div_assign(&mut self, rhs: Vec2D<T, U>)
fn div_assign(&mut self, rhs: Vec2D<T, U>)
Performs the /=
operation. Read more
sourceimpl<T: Number, U: Unit> MulAssign<Rect<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> MulAssign<Rect<T, U>> for Rect<T, U>
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *=
operation. Read more
sourceimpl<T: Number, U: Unit> MulAssign<T> for Rect<T, U>
impl<T: Number, U: Unit> MulAssign<T> for Rect<T, U>
sourcefn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the *=
operation. Read more
sourceimpl<T: Number, U: Unit> MulAssign<Vec2D<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> MulAssign<Vec2D<T, U>> for Rect<T, U>
sourcefn mul_assign(&mut self, rhs: Vec2D<T, U>)
fn mul_assign(&mut self, rhs: Vec2D<T, U>)
Performs the *=
operation. Read more
sourceimpl<N: Number + Ord, U: Unit> Ord for Rect<N, U>
impl<N: Number + Ord, U: Unit> Ord for Rect<N, U>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<N: Number, U: Unit> PartialOrd<Rect<N, U>> for Rect<N, U>
impl<N: Number, U: Unit> PartialOrd<Rect<N, U>> for Rect<N, U>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T: Number, U: Unit> RemAssign<Rect<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> RemAssign<Rect<T, U>> for Rect<T, U>
sourcefn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the %=
operation. Read more
sourceimpl<T: Number, U: Unit> RemAssign<T> for Rect<T, U>
impl<T: Number, U: Unit> RemAssign<T> for Rect<T, U>
sourcefn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
Performs the %=
operation. Read more
sourceimpl<T: Number, U: Unit> RemAssign<Vec2D<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> RemAssign<Vec2D<T, U>> for Rect<T, U>
sourcefn rem_assign(&mut self, rhs: Vec2D<T, U>)
fn rem_assign(&mut self, rhs: Vec2D<T, U>)
Performs the %=
operation. Read more
sourceimpl<T: Number, U: Unit> SubAssign<Rect<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> SubAssign<Rect<T, U>> for Rect<T, U>
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -=
operation. Read more
sourceimpl<T: Number, U: Unit> SubAssign<T> for Rect<T, U>
impl<T: Number, U: Unit> SubAssign<T> for Rect<T, U>
sourcefn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the -=
operation. Read more
sourceimpl<T: Number, U: Unit> SubAssign<Vec2D<T, U>> for Rect<T, U>
impl<T: Number, U: Unit> SubAssign<Vec2D<T, U>> for Rect<T, U>
sourcefn sub_assign(&mut self, rhs: Vec2D<T, U>)
fn sub_assign(&mut self, rhs: Vec2D<T, U>)
Performs the -=
operation. Read more
impl<T: Copy + Number, U: Copy + Unit> Copy for Rect<T, U>
impl<N: Number, U: Unit> Eq for Rect<N, U>
Auto Trait Implementations
impl<T, U> RefUnwindSafe for Rect<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for Rect<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for Rect<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for Rect<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for Rect<T, U> where
T: UnwindSafe,
U: 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