[][src]Struct axgeom::Rect

#[repr(C)]
#[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>[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::Error> where
    S: TryInto<A>, 
[src]

impl<T: Copy + Sub<Output = T> + Add<Output = T>> Rect<T>[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(xstart: T, xend: T, ystart: T, yend: T) -> Rect<T>[src]

Constructor. (xstart,xend) is the x component range. (ystart,yend) is the y component range.

impl<T: Copy> Rect<T>[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: 'static + Copy>(&self) -> Rect<B> where
    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: PartialOrd + Copy> Rect<T>[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: Copy + Sub<Output = T> + Add<Output = T>> Rect<T>[src]

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

Grow a rectangle of a radius.

impl<T: Copy + PartialOrd + Sub<Output = T> + Mul<Output = T> + Add<Output = T>> Rect<T>[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 the closest corner of the rectangle. If the point is inside the rectangle, it will return None.

pub fn furthest_distance_squared_to_point(&self, point: Vec2<T>) -> T[src]

If the point is outisde the rectangle, returns the squared distance from a point to the furthest corner of the rectangle.

impl<T: Num + Copy> Rect<T>[src]

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

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

pub fn subdivide<A: Axis>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>)[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 Self[src]

pub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Self[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: Ord + Copy> Rect<T>[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<B> AsMut<[B; 4]> for Rect<B>[src]

impl<B> AsRef<[B; 4]> for Rect<B>[src]

impl<N: FloatCore> AsRef<Rect<N>> for Rect<NotNan<N>>[src]

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

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

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

impl<T: Eq> Eq for Rect<T>[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> PartialEq<Rect<T>> for Rect<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> 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.