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
The horizontal x position of the bounding box.
y: f32
The vertical y position of the bounding box.
w: f32
The width of the bounding box.
h: f32
The height of the bounding box.
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
.
Sourcepub fn expand_sides(
&self,
left: f32,
top: f32,
right: f32,
bottom: f32,
) -> BoundingBox
pub fn expand_sides( &self, left: f32, top: f32, right: f32, bottom: f32, ) -> BoundingBox
Expands each side by the given separate amounts and returns a new BoundingBox
.
Sourcepub fn offset(&self, x: f32, y: f32) -> BoundingBox
pub fn offset(&self, x: f32, y: f32) -> BoundingBox
Shifts the bounding box by the given X and Y offsets and returns a new 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
.
Sourcepub fn intersection(&self, other: &BoundingBox) -> BoundingBox
pub fn intersection(&self, other: &BoundingBox) -> BoundingBox
Returns a new BoundingBox representing the intersection of the current bounding box and the given bounding box.
Sourcepub fn union(&self, other: &BoundingBox) -> BoundingBox
pub fn union(&self, other: &BoundingBox) -> BoundingBox
Returns a new BoundingBox representing the union of the current bounding box and the given bounding box.
Sourcepub fn intersects(&self, other: &BoundingBox) -> bool
pub fn intersects(&self, other: &BoundingBox) -> bool
Returns true if the current bounding box and the given bounding box intersect.
Sourcepub fn contains(&self, other: &BoundingBox) -> bool
pub fn contains(&self, other: &BoundingBox) -> bool
Returns true if the given bounding box is contained within the current bounding box.
Sourcepub fn contains_point(&self, x: f32, y: f32) -> bool
pub fn contains_point(&self, x: f32, y: f32) -> bool
Returns true if the given point is contained within the current bounding box.
Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BoundingBox
impl Debug for BoundingBox
Source§impl Default for BoundingBox
impl Default for BoundingBox
Source§fn default() -> BoundingBox
fn default() -> 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) -> Rect
fn from(bb: BoundingBox) -> Rect
Source§impl From<Rect> for BoundingBox
impl From<Rect> for BoundingBox
Source§fn from(bb: Rect) -> BoundingBox
fn from(bb: Rect) -> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
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>
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)
&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)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
Source§impl<T> ToStringLocalized for Twhere
T: ToString,
impl<T> ToStringLocalized for Twhere
T: ToString,
Source§fn to_string_local(&self, _cx: &impl DataContext) -> String
fn to_string_local(&self, _cx: &impl DataContext) -> String
String
via a translation using fluent.