[−][src]Struct broccoli::Rect
An axis aligned rectangle. Stored as two Ranges. It is a semi-closed rectangle. A point is considered inside the rectangle if it is in [start,end) for both x and y.
Fields
x: Range<T>
y: Range<T>
Implementations
impl<S> Rect<S> where
S: Copy,
[src]
S: Copy,
pub fn inner_into<A>(&self) -> Rect<A> where
S: Into<A>,
[src]
S: Into<A>,
#[must_use]pub fn inner_try_into<A>(&self) -> Result<Rect<A>, <S as TryInto<A>>::Error> where
S: TryInto<A>,
[src]
S: TryInto<A>,
impl<T> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
#[must_use]pub fn from_point(point: Vec2<T>, radius: Vec2<T>) -> Rect<T>
[src]
Create a rectangle from a point and radius.
impl<T> Rect<T>
[src]
#[must_use]pub fn get_range(&self, axis: impl Axis) -> &Range<T>
[src]
Get the range of one axis.
#[must_use]pub fn get_range_mut(&mut self, axis: impl Axis) -> &mut Range<T>
[src]
Get the mutable range of one axis.
impl<T> Rect<T>
[src]
#[must_use]pub fn new(a: T, b: T, c: T, d: T) -> Rect<T>
[src]
(a,b) is the x component range. (c,d) is the y component range.
impl<T> Rect<T> where
T: Copy,
[src]
T: Copy,
pub fn top_left(&self) -> Vec2<T>
[src]
pub fn get_corners(&self) -> [Vec2<T>; 4]
[src]
Returns each corner in this order: topleft topright bottomright bottomleft
pub fn inner_as<B>(&self) -> Rect<B> where
B: 'static + Copy,
T: AsPrimitive<B>,
[src]
B: 'static + Copy,
T: AsPrimitive<B>,
pub fn get(&self) -> ((T, T), (T, T))
[src]
(a,b) is the x component range. (c,d) is the y component range.
impl<T> Rect<T> where
T: PartialOrd<T> + Copy,
[src]
T: PartialOrd<T> + Copy,
pub fn contains_point(&self, a: Vec2<T>) -> bool
[src]
Returns true if the point is contained in the the ranges of both axis.
impl<T> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,
impl<T> Rect<T> where
T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + PartialOrd<T> + Copy,
[src]
T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + PartialOrd<T> + Copy,
pub fn distance_squared_to_point(&self, point: Vec2<T>) -> Option<T>
[src]
If the point is outisde the rectangle, returns the squared distance from a point to a rectangle. If the point is inside the rectangle, it will return None.
impl<T> Rect<T> where
T: Copy + Num,
[src]
T: Copy + Num,
pub fn derive_center(&self) -> Vec2<T>
[src]
impl<T> Rect<T> where
T: PartialOrd<T> + Copy,
[src]
T: PartialOrd<T> + Copy,
pub fn subdivide<A>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>) where
A: Axis,
[src]
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].
pub fn is_valid(&self) -> bool
[src]
Returns true if the rectangle's ranges are not degenerate.
pub fn contains_rect(&self, rect: &Rect<T>) -> bool
[src]
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>
[src]
pub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Rect<T>
[src]
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
[src]
impl<T> Rect<T> where
T: Ord + Copy,
[src]
T: Ord + Copy,
pub fn get_intersect_rect(&self, other: &Rect<T>) -> Option<Rect<T>>
[src]
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<N: Num> Aabb for Rect<N>
[src]
impl<B> AsMut<[B; 4]> for Rect<B>
[src]
impl<B> AsRef<[B; 4]> for Rect<B>
[src]
impl<N> AsRef<Rect<N>> for Rect<NotNan<N>> where
N: FloatCore,
[src]
N: FloatCore,
impl<T> Clone for Rect<T> where
T: Clone,
[src]
T: Clone,
impl<T> Copy for Rect<T> where
T: Copy,
[src]
T: Copy,
impl<T> Debug for Rect<T> where
T: Debug,
[src]
T: Debug,
impl<T> Eq for Rect<T> where
T: Eq,
[src]
T: Eq,
impl<'a, B> From<&'a [B; 4]> for &'a Rect<B>
[src]
impl<'a, B> From<&'a mut [B; 4]> for &'a mut Rect<B>
[src]
impl<B> From<[B; 4]> for Rect<B>
[src]
impl<B> Into<[B; 4]> for Rect<B>
[src]
impl<T> PartialEq<Rect<T>> for Rect<T> where
T: PartialEq<T>,
[src]
T: PartialEq<T>,
impl<T> StructuralEq for Rect<T>
[src]
impl<T> StructuralPartialEq for Rect<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Rect<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Rect<T> where
T: Send,
T: Send,
impl<T> Sync for Rect<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Rect<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Rect<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,