[][src]Struct broccoli::Rect

#[must_use]pub struct Rect<T> {
    pub x: Range<T>,
    pub y: Range<T>,
}

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]

pub fn inner_into<A>(&self) -> Rect<A> where
    S: Into<A>, 
[src]

#[must_use]pub fn inner_try_into<A>(&self) -> Result<Rect<A>, <S as TryInto<A>>::Error> where
    S: TryInto<A>, 
[src]

impl<T> Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Copy
[src]

#[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]

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]

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]

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]

pub fn grow(&mut self, radius: T) -> &mut Rect<T>[src]

Grow a rectangle of a radius.

impl<T> Rect<T> where
    T: Add<T, Output = T> + Sub<T, Output = T> + Mul<T, Output = T> + PartialOrd<T> + Copy
[src]

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]

pub fn derive_center(&self) -> Vec2<T>[src]

impl<T> Rect<T> where
    T: PartialOrd<T> + Copy
[src]

pub fn subdivide<A>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>) where
    A: Axis
[src]

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]

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]

type Num = N

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]

impl<T> Clone for Rect<T> where
    T: Clone
[src]

impl<T> Copy for Rect<T> where
    T: Copy
[src]

impl<T> Debug for Rect<T> where
    T: Debug
[src]

impl<T> Eq for Rect<T> where
    T: Eq
[src]

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]

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.