pub struct BoundingRect {
pub left: i32,
pub top: i32,
pub right: i32,
pub bottom: i32,
}Expand description
The rectangle that bounds an object
Fields§
§left: i32§top: i32§right: i32§bottom: i32Implementations§
Source§impl BoundingRect
impl BoundingRect
pub fn new_x_y_w_h(x: i32, y: i32, w: i32, h: i32) -> Self
pub fn width(self) -> i32
pub fn height(self) -> i32
pub fn is_empty(self) -> bool
pub fn center(self) -> PointI32
pub fn left_top(&self) -> PointI32
pub fn top_left(&self) -> PointI32
pub fn top_right(&self) -> PointI32
pub fn bottom_left(&self) -> PointI32
pub fn right_bottom(&self) -> PointI32
pub fn bottom_right(&self) -> PointI32
Sourcepub fn sq_dist(self, other: Self) -> i32
pub fn sq_dist(self, other: Self) -> i32
Calculates the squared distance betweeen the center of two BoundingRects.
pub fn aspect_ratio(self) -> f64
pub fn aspect_ratio_doubled(self) -> i32
pub fn add_x_y(&mut self, x: i32, y: i32)
pub fn merge(&mut self, other: Self)
pub fn clear(&mut self)
pub fn hit(self, other: Self) -> bool
pub fn clip(&mut self, other: Self)
pub fn squared(self) -> Self
pub fn translate(&mut self, p: PointI32)
Sourcepub fn have_point_on_boundary(&self, p: PointI32, tolerance: usize) -> bool
pub fn have_point_on_boundary(&self, p: PointI32, tolerance: usize) -> bool
Tolerance means:
1. Extend each boundary on both sides by tolerance units along its direction.
2. true is returned iff p lies on either one of the extended boundaries.
A point p lying on boundary “strictly” means this function returns true with p
and tolerance set as 0.
pub fn have_point_inside(&self, p: PointI32) -> bool
Sourcepub fn have_point_on_boundary_or_inside(
&self,
p: PointI32,
boundary_tolerance: usize,
) -> bool
pub fn have_point_on_boundary_or_inside( &self, p: PointI32, boundary_tolerance: usize, ) -> bool
For definition of boundary_tolerance, see BoundingRect::have_point_on_boundary().
Sourcepub fn get_closest_point_inside(&self, p: PointI32) -> PointI32
pub fn get_closest_point_inside(&self, p: PointI32) -> PointI32
Given a point on the boundary, return the closest point inside the bounding rect. The behavior is undefined unless ‘p’ is a point on boundary (strictly) and the area of this rect is larger than 1.
Sourcepub fn get_closest_point_outside(&self, p: PointI32) -> PointI32
pub fn get_closest_point_outside(&self, p: PointI32) -> PointI32
Given a point on the boundary, return the closest point outside the bounding rect. Note that if ‘p’ is a corner, there are three closest points, but the diagonal one is always returned. The behavior is undefined unless ‘p’ is a point on boundary (strictly).
Trait Implementations§
Source§impl Bound for BoundingRect
impl Bound for BoundingRect
Source§impl Clone for BoundingRect
impl Clone for BoundingRect
Source§fn clone(&self) -> BoundingRect
fn clone(&self) -> BoundingRect
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BoundingRect
impl Debug for BoundingRect
Source§impl Default for BoundingRect
impl Default for BoundingRect
Source§fn default() -> BoundingRect
fn default() -> BoundingRect
Source§impl PartialEq for BoundingRect
impl PartialEq for BoundingRect
impl Copy for BoundingRect
impl Eq for BoundingRect
impl StructuralPartialEq for BoundingRect
Auto Trait Implementations§
impl Freeze for BoundingRect
impl RefUnwindSafe for BoundingRect
impl Send for BoundingRect
impl Sync for BoundingRect
impl Unpin for BoundingRect
impl UnwindSafe for BoundingRect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more