pub struct RoundedRectangle<T = f32> { /* private fields */ }Expand description
A struct representing an axis-aligned rounded rectangle. Two points and a value of type ‘T’ are stored: the top left vertex, the bottom right vertex and the radius of the rounded corners.
Implementations§
Source§impl<T> RoundedRectangle<T>
impl<T> RoundedRectangle<T>
Sourcepub const fn new(
top_left: Vector2<T>,
bottom_right: Vector2<T>,
radius: T,
) -> Self
pub const fn new( top_left: Vector2<T>, bottom_right: Vector2<T>, radius: T, ) -> Self
Constructs a new RoundedRectangle. The top left vertex must be above
and to the left of the bottom right vertex. A negative radius won’t be
checked. A big radius (larger than half the width or height)
might produce unexpected behavior but it won’t be checked.
Sourcepub fn from_tuples(top_left: (T, T), bottom_right: (T, T), radius: T) -> Self
pub fn from_tuples(top_left: (T, T), bottom_right: (T, T), radius: T) -> Self
Constructs a new RoundedRectangle. The top left vertex must be above
and to the left of the bottom right vertex. A negative radius won’t be
checked. A big radius (larger than half the width or height)
might produce unexpected behavior but it won’t be checked.
Note: a negative radius won’t be checked at runtime.
Sourcepub fn from_rectangle(rect: Rectangle<T>, radius: T) -> Self
pub fn from_rectangle(rect: Rectangle<T>, radius: T) -> Self
Constructs a new RoundedRectangle from a Rectangle and a radius.
A negative radius won’t be checked.
A big radius (larger than half the width or height) might produce
unexpected behavior but it won’t be checked.
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> RoundedRectangle<T>
impl<T: Copy> RoundedRectangle<T>
Sourcepub fn bottom_left(&self) -> Vector2<T>
pub fn bottom_left(&self) -> Vector2<T>
Returns a vector representing the bottom left vertex.
Sourcepub fn as_rectangle(&self) -> &Rectangle<T>
pub fn as_rectangle(&self) -> &Rectangle<T>
Returns a Rectangle representing the rectangle that encloses this
rounded rectangle.
Source§impl<T: Sub<Output = T> + Copy> RoundedRectangle<T>
impl<T: Sub<Output = T> + Copy> RoundedRectangle<T>
Source§impl<T> RoundedRectangle<T>
impl<T> RoundedRectangle<T>
Source§impl<T: PartialEq> RoundedRectangle<T>
impl<T: PartialEq> RoundedRectangle<T>
Sourcepub fn is_zero_area(&self) -> bool
pub fn is_zero_area(&self) -> bool
Returns true if the rectangle containing this rounded rectangle has
zero area. (the radius is not taken into account)
Source§impl<T: PartialOrd> RoundedRectangle<T>
impl<T: PartialOrd> RoundedRectangle<T>
Sourcepub fn is_positive_area(&self) -> bool
pub fn is_positive_area(&self) -> bool
Returns true if the rectangle containing this rounded rectangle has
positive area. (the radius is not taken into account)
Source§impl<T: Copy> RoundedRectangle<T>
impl<T: Copy> RoundedRectangle<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 rounded rectangle, whose vertices are offset relative to the current rounded rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.
Source§impl<T: Copy> RoundedRectangle<T>
impl<T: Copy> RoundedRectangle<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 rounded 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>> RoundedRectangle<T>
impl<T: AsPrimitive<f32>> RoundedRectangle<T>
Sourcepub fn into_f32(self) -> RoundedRectangle<f32>
pub fn into_f32(self) -> RoundedRectangle<f32>
Returns a new rounded rectangle where the coordinates and the radius
have been cast to f32 values, using the as operator.
Source§impl<T: AsPrimitive<f32> + Copy> RoundedRectangle<T>
impl<T: AsPrimitive<f32> + Copy> RoundedRectangle<T>
Sourcepub fn as_f32(&self) -> RoundedRectangle<f32>
pub fn as_f32(&self) -> RoundedRectangle<f32>
Returns a new rectangle where the coordinates have been cast to f32
values, using the as operator.
Trait Implementations§
Source§impl<T> AsRef<RoundedRectangle<T>> for RoundedRectangle<T>
impl<T> AsRef<RoundedRectangle<T>> for RoundedRectangle<T>
Source§impl<T: Clone> Clone for RoundedRectangle<T>
impl<T: Clone> Clone for RoundedRectangle<T>
Source§fn clone(&self) -> RoundedRectangle<T>
fn clone(&self) -> RoundedRectangle<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for RoundedRectangle<T>
impl<T: Debug> Debug for RoundedRectangle<T>
impl<T: Eq> Eq for RoundedRectangle<T>
Source§impl<T: PartialEq> PartialEq for RoundedRectangle<T>
impl<T: PartialEq> PartialEq for RoundedRectangle<T>
impl<T: PartialEq> StructuralPartialEq for RoundedRectangle<T>
Auto Trait Implementations§
impl<T> Freeze for RoundedRectangle<T>where
T: Freeze,
impl<T> RefUnwindSafe for RoundedRectangle<T>where
T: RefUnwindSafe,
impl<T> Send for RoundedRectangle<T>where
T: Send,
impl<T> Sync for RoundedRectangle<T>where
T: Sync,
impl<T> Unpin for RoundedRectangle<T>where
T: Unpin,
impl<T> UnsafeUnpin for RoundedRectangle<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for RoundedRectangle<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