Struct BoundingBox
pub struct BoundingBox {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}
Expand description
Represents an axis-aligned bounding box.
Fields§
§x: f32
§y: f32
§w: f32
§h: f32
Implementations§
§impl BoundingBox
impl BoundingBox
pub fn from_min_max(
min_x: f32,
min_y: f32,
max_x: f32,
max_y: f32,
) -> BoundingBox
pub fn from_min_max( min_x: f32, min_y: f32, max_x: f32, max_y: f32, ) -> BoundingBox
Construct a BoundingBox
from checked minimum and maximum values.
pub fn center_left(&self) -> (f32, f32)
pub fn center_left(&self) -> (f32, f32)
Left center of bounds.
pub fn center_right(&self) -> (f32, f32)
pub fn center_right(&self) -> (f32, f32)
Right center of bounds.
pub fn center_top(&self) -> (f32, f32)
pub fn center_top(&self) -> (f32, f32)
Top center of bounds.
pub fn center_bottom(&self) -> (f32, f32)
pub fn center_bottom(&self) -> (f32, f32)
Bottom center of bounds.
pub fn bottom_left(&self) -> (f32, f32)
pub fn bottom_left(&self) -> (f32, f32)
Bottom left point of bounds.
pub fn bottom_right(&self) -> (f32, f32)
pub fn bottom_right(&self) -> (f32, f32)
Bottom right point of bounds.
pub fn shrink(&self, amount: f32) -> BoundingBox
pub fn shrink(&self, amount: f32) -> BoundingBox
Shrinks by some amount
in both directions and returns a new BoundingBox
.
pub fn shrink_horizontal(&self, amount: f32) -> BoundingBox
pub fn shrink_horizontal(&self, amount: f32) -> BoundingBox
Shrinks by some amount
horizontally and returns a new BoundingBox
.
pub fn shrink_vertical(&self, amount: f32) -> BoundingBox
pub fn shrink_vertical(&self, amount: f32) -> BoundingBox
Shrinks by some amount
vertically and returns a new BoundingBox
.
pub fn shrink_sides(
&self,
left: f32,
top: f32,
right: f32,
bottom: f32,
) -> BoundingBox
pub fn shrink_sides( &self, left: f32, top: f32, right: f32, bottom: f32, ) -> BoundingBox
Shrinks each side by the given separate amounts and returns a new BoundingBox
.
pub fn expand_sides( &self, left: f32, top: f32, right: f32, bottom: f32, ) -> BoundingBox
pub fn offset(&self, x: f32, y: f32) -> BoundingBox
pub fn expand(&self, amount: f32) -> BoundingBox
pub fn expand(&self, amount: f32) -> BoundingBox
Expands by some amount
in both directions and returns a new BoundingBox
.
pub fn expand_horizontal(&self, amount: f32) -> BoundingBox
pub fn expand_horizontal(&self, amount: f32) -> BoundingBox
Expands by some amount
horizontally and returns a new BoundingBox
.
pub fn expand_vertical(&self, amount: f32) -> BoundingBox
pub fn expand_vertical(&self, amount: f32) -> BoundingBox
Expands by some amount
vertically and returns a new BoundingBox
.
pub fn intersection(&self, other: &BoundingBox) -> BoundingBox
pub fn union(&self, other: &BoundingBox) -> BoundingBox
pub fn intersects(&self, other: &BoundingBox) -> bool
pub fn contains(&self, other: &BoundingBox) -> bool
pub fn contains_point(&self, x: f32, y: f32) -> bool
pub fn diagonal(&self) -> f32
Trait Implementations§
§impl Clone for BoundingBox
impl Clone for BoundingBox
§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for BoundingBox
impl Debug for BoundingBox
§impl Default for BoundingBox
impl Default for BoundingBox
§fn default() -> BoundingBox
fn default() -> BoundingBox
Returns the “default value” for a type. Read more
§impl Display for BoundingBox
impl Display for BoundingBox
§impl From<BoundingBox> for Rect
impl From<BoundingBox> for Rect
§fn from(bb: BoundingBox) -> Rect
fn from(bb: BoundingBox) -> Rect
Converts to this type from the input type.
§impl From<Rect> for BoundingBox
impl From<Rect> for BoundingBox
§fn from(bb: Rect) -> BoundingBox
fn from(bb: Rect) -> BoundingBox
Converts to this type from the input type.
§impl PartialEq for BoundingBox
impl PartialEq for BoundingBox
impl Copy for BoundingBox
impl StructuralPartialEq for BoundingBox
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnwindSafe for BoundingBox
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.