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: f32The horizontal x position of the bounding box.
y: f32The vertical y position of the bounding box.
w: f32The width of the bounding box.
h: f32The height of the bounding box.
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 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.
pub 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.
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 intersection(&self, other: &BoundingBox) -> BoundingBox
Returns a new BoundingBox representing the intersection of the current bounding box and the given bounding box.
pub 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.
pub 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.
pub 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.
pub 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§
§impl Clone for BoundingBox
impl Clone for BoundingBox
§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 more§impl Debug for BoundingBox
impl Debug for BoundingBox
§impl Default for BoundingBox
impl Default for BoundingBox
§fn default() -> BoundingBox
fn default() -> BoundingBox
§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
§impl From<Rect> for BoundingBox
impl From<Rect> for BoundingBox
§fn from(bb: Rect) -> BoundingBox
fn from(bb: Rect) -> BoundingBox
§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
§impl<T> ToStringLocalized for Twhere
T: ToString,
impl<T> ToStringLocalized for Twhere
T: ToString,
§fn to_string_local(&self, _cx: &impl DataContext) -> String
fn to_string_local(&self, _cx: &impl DataContext) -> String
String via a translation using fluent.