Skip to main content

RoundedRectangle

Struct RoundedRectangle 

Source
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: Copy + Neg<Output = T> + Add<Output = T>> RoundedRectangle<T>

Source

pub fn inner(&self) -> Rectangle<T>

returns a Rectangle representing the inner rectangle of this rounded rectangle.

Source§

impl<T> RoundedRectangle<T>

Source

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.

Source

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.

Source

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.

Source

pub const fn top_left(&self) -> &Vector2<T>

Returns a reference to the top left vertex.

Source

pub const fn bottom_right(&self) -> &Vector2<T>

Returns a reference to the bottom right vertex.

Source§

impl<T: Copy> RoundedRectangle<T>

Source

pub fn top_right(&self) -> Vector2<T>

Returns a vector representing the top right vertex.

Source

pub fn bottom_left(&self) -> Vector2<T>

Returns a vector representing the bottom left vertex.

Source

pub fn radius(&self) -> T

Returns the radius of the rounded corners.

Source

pub fn left(&self) -> T

Returns the x value of the left border

Source

pub fn right(&self) -> T

Returns the x value of the right border

Source

pub fn top(&self) -> T

Returns the y value of the top border

Source

pub fn bottom(&self) -> T

Returns the y value of the bottom border

Source

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>

Source

pub fn width(&self) -> T

Returns the width of the rounded rectangle.

Source

pub fn height(&self) -> T

Returns the height of the rounded rectangle.

Source

pub fn size(&self) -> Vector2<T>

Returns a Vector2 containing the width and height of the rounded rectangle.

Source§

impl<T> RoundedRectangle<T>
where T: AsPrimitive<f32> + PartialOrd + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Neg<Output = T> + Div<Output = f32> + Div<f32, Output = T> + Zero,

Source

pub fn contains(&self, point: Vector2<T>) -> bool

Returns true if the specified point is inside this rounded rectangle. Note: this is always inclusive, in contrast to the contains method of Rect which is sometimes exclusive.

Source§

impl<T: PartialEq> RoundedRectangle<T>

Source

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>

Source

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>
where Vector2<T>: Add<Output = Vector2<T>>,

Source

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>
where Vector2<T>: Sub<Output = Vector2<T>>,

Source

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>

Source

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>

Source

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>

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for RoundedRectangle<T>

Source§

fn clone(&self) -> RoundedRectangle<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for RoundedRectangle<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq> Eq for RoundedRectangle<T>

Source§

impl<T: PartialEq> PartialEq for RoundedRectangle<T>

Source§

fn eq(&self, other: &RoundedRectangle<T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

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.
Source§

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.
Source§

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.
Source§

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.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more