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: i32

Implementations§

source§

impl BoundingRect

source

pub fn new_x_y_w_h(x: i32, y: i32, w: i32, h: i32) -> Self

source

pub fn width(self) -> i32

source

pub fn height(self) -> i32

source

pub fn is_empty(self) -> bool

source

pub fn center(self) -> PointI32

source

pub fn left_top(&self) -> PointI32

source

pub fn top_left(&self) -> PointI32

source

pub fn top_right(&self) -> PointI32

source

pub fn bottom_left(&self) -> PointI32

source

pub fn right_bottom(&self) -> PointI32

source

pub fn bottom_right(&self) -> PointI32

source

pub fn sq_dist(self, other: Self) -> i32

Calculates the squared distance betweeen the center of two BoundingRects.

source

pub fn aspect_ratio(self) -> f64

source

pub fn aspect_ratio_doubled(self) -> i32

source

pub fn add_x_y(&mut self, x: i32, y: i32)

source

pub fn merge(&mut self, other: Self)

source

pub fn clear(&mut self)

source

pub fn hit(self, other: Self) -> bool

source

pub fn clip(&mut self, other: Self)

source

pub fn squared(self) -> Self

source

pub fn translate(&mut self, p: PointI32)

source

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.

source

pub fn have_point_inside(&self, p: PointI32) -> bool

source

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().

source

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.

source

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).

source

pub fn get_boundary_points_from( &self, p: PointI32, clockwise: bool ) -> Vec<PointI32>

Starting from ‘p’, copy the boundary points into a new Vec following the orientation specified by ‘clockwise’ and return it. The behavior is undefined unless ‘p’ is a point on boundary (strictly).

Trait Implementations§

source§

impl Bound for BoundingRect

source§

fn bound(&self) -> BoundingRect

source§

fn overlaps<B: Bound>(&self, other: &B) -> bool

source§

impl Clone for BoundingRect

source§

fn clone(&self) -> BoundingRect

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for BoundingRect

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for BoundingRect

source§

fn default() -> BoundingRect

Returns the “default value” for a type. Read more
source§

impl PartialEq for BoundingRect

source§

fn eq(&self, other: &BoundingRect) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for BoundingRect

source§

impl Eq for BoundingRect

source§

impl StructuralPartialEq for BoundingRect

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.