Struct vizia_core::layout::bounds::BoundingBox
source · 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§
source§impl BoundingBox
impl BoundingBox
sourcepub 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.
sourcepub fn center_left(&self) -> (f32, f32)
pub fn center_left(&self) -> (f32, f32)
Left center of bounds.
sourcepub fn center_right(&self) -> (f32, f32)
pub fn center_right(&self) -> (f32, f32)
Right center of bounds.
sourcepub fn center_top(&self) -> (f32, f32)
pub fn center_top(&self) -> (f32, f32)
Top center of bounds.
sourcepub fn center_bottom(&self) -> (f32, f32)
pub fn center_bottom(&self) -> (f32, f32)
Bottom center of bounds.
sourcepub fn bottom_left(&self) -> (f32, f32)
pub fn bottom_left(&self) -> (f32, f32)
Bottom left point of bounds.
sourcepub fn bottom_right(&self) -> (f32, f32)
pub fn bottom_right(&self) -> (f32, f32)
Bottom right point of bounds.
sourcepub 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
.
sourcepub 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
.
sourcepub 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
.
sourcepub 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
sourcepub 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
.
sourcepub 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
.
sourcepub 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: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
pub fn intersects(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
pub fn contains_point(&self, x: f32, y: f32) -> bool
pub fn diagonal(&self) -> f32
Trait Implementations§
source§impl Clone for BoundingBox
impl Clone for BoundingBox
source§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 moresource§impl Debug for BoundingBox
impl Debug for BoundingBox
source§impl Default for BoundingBox
impl Default for BoundingBox
source§impl Display for BoundingBox
impl Display for BoundingBox
source§impl From<BoundingBox> for Rect
impl From<BoundingBox> for Rect
source§fn from(bb: BoundingBox) -> Self
fn from(bb: BoundingBox) -> Self
Converts to this type from the input type.
source§impl From<Rect> for BoundingBox
impl From<Rect> for BoundingBox
source§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.