Expand description
An axis aligned rectangle. Stored as two Ranges. It is a fully closed rectangle. Points exactly along the border of the rectangle are considered inside the rectangle.
Tuple Fields§
§0: [Range<T>; 2]
Implementations§
source§impl<T: Copy> Rect<T>
impl<T: Copy> Rect<T>
sourcepub fn new(a: T, b: T, c: T, d: T) -> Rect<T>
pub fn new(a: T, b: T, c: T, d: T) -> Rect<T>
(a,b) is the x component range. (c,d) is the y component range.
sourcepub fn get(&self) -> ((T, T), (T, T))
pub fn get(&self) -> ((T, T), (T, T))
(a,b) is the x component range. (c,d) is the y component range.
pub fn get_range(&self, axis: impl AxisTrait) -> &Range<T>
pub fn get_range_mut(&mut self, axis: impl AxisTrait) -> &mut Range<T>
source§impl<T: PartialOrd + Copy> Rect<T>
impl<T: PartialOrd + Copy> Rect<T>
pub fn contains_point(&self, a: [T; 2]) -> bool
source§impl<T: Ord + Copy> Rect<T>
impl<T: Ord + Copy> Rect<T>
pub fn equals(&self, a: &Rect<T>) -> bool
sourcepub fn subdivide<A: AxisTrait>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>)
pub fn subdivide<A: AxisTrait>(&self, axis: A, divider: T) -> (Rect<T>, Rect<T>)
Subdivides the rectangle. No floating point calculations are done (so no precision loss/rounding issues).
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.
sourcepub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Self
pub fn grow_to_fit(&mut self, rect: &Rect<T>) -> &mut Self
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
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.