pub struct Rectangle<T = f32> { /* private fields */ }Expand description
A struct representing an axis-aligned rectangle. Two points are stored: the top left vertex, and the bottom right vertex.
Implementations§
Source§impl<T> Rectangle<T>
impl<T> Rectangle<T>
Sourcepub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
pub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
Constructs a new Rectangle. The top left vertex must be above and to
the left of the bottom right vertex.
Sourcepub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
pub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
Constructs a new Rectangle. The top left vertex must be above and to
the left of the bottom right vertex.
Sourcepub const fn bottom_right(&self) -> &Vector2<T>
pub const fn bottom_right(&self) -> &Vector2<T>
Returns a reference to the bottom right vertex.
Source§impl<T: Copy> Rectangle<T>
impl<T: Copy> Rectangle<T>
Sourcepub fn rounded(&self, radius: T) -> RoundedRectangle<T>
pub fn rounded(&self, radius: T) -> RoundedRectangle<T>
Returns a new RoundedRectangle which has the same sizes of Self and
a radius of T
Sourcepub fn bottom_left(&self) -> Vector2<T>
pub fn bottom_left(&self) -> Vector2<T>
Returns a vector representing the bottom left vertex.
Source§impl<T: PartialOrd<T> + Copy> Rectangle<T>
impl<T: PartialOrd<T> + Copy> Rectangle<T>
Source§impl<T: PartialOrd + Copy> Rectangle<T>
impl<T: PartialOrd + Copy> Rectangle<T>
Source§impl<T: PrimitiveZero> Rectangle<T>
impl<T: PrimitiveZero> Rectangle<T>
Source§impl<T: PartialEq> Rectangle<T>
impl<T: PartialEq> Rectangle<T>
Sourcepub fn is_zero_area(&self) -> bool
pub fn is_zero_area(&self) -> bool
Returns true if the rectangle has zero area.
Source§impl<T: PartialOrd> Rectangle<T>
impl<T: PartialOrd> Rectangle<T>
Sourcepub fn is_positive_area(&self) -> bool
pub fn is_positive_area(&self) -> bool
Returns true if the rectangle has an area greater than zero.
Source§impl<T: Copy> Rectangle<T>
impl<T: Copy> Rectangle<T>
Sourcepub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are offset relative to the current rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.
Source§impl<T: Copy> Rectangle<T>
impl<T: Copy> Rectangle<T>
Sourcepub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are negatively offset relative to the current rectangle by the specified amount. This is equivalent to subtracting the specified vector to each vertex.
Source§impl<T: AsPrimitive<f32>> Rectangle<T>
impl<T: AsPrimitive<f32>> Rectangle<T>
Trait Implementations§
impl<T: Eq> Eq for Rectangle<T>
impl<T: PartialEq> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> Freeze for Rectangle<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rectangle<T>where
T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where
T: Send,
impl<T> Sync for Rectangle<T>where
T: Sync,
impl<T> Unpin for Rectangle<T>where
T: Unpin,
impl<T> UnsafeUnpin for Rectangle<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Rectangle<T>where
T: UnwindSafe,
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more