Skip to main content

BorderRadius

Struct BorderRadius 

Source
pub struct BorderRadius {
    pub top_left: f32,
    pub top_right: f32,
    pub bottom_right: f32,
    pub bottom_left: f32,
}
Expand description

Corner radii, per corner (logical px). From<f32> covers the uniform case: anywhere a radius is expected, a plain 10.0 still works.

Fields§

§top_left: f32

The top-left corner’s radius, in logical pixels.

§top_right: f32

The top-right corner’s radius, in logical pixels.

§bottom_right: f32

The bottom-right corner’s radius, in logical pixels.

§bottom_left: f32

The bottom-left corner’s radius, in logical pixels.

Implementations§

Source§

impl BorderRadius

Source

pub const ZERO: Self

No rounding at all.

Source

pub fn lerp(self, other: BorderRadius, t: f32) -> BorderRadius

Each corner t of the way from self to other.

Not clamped: a corner past its target is what a spring asks for at the end of its travel, and the one rule for a radius in flight is this one — an animated container and a decoration transition both go through it.

Source

pub const fn uniform(radius: f32) -> Self

The same radius on all four corners.

Source

pub const fn top(radius: f32) -> Self

Only the top corners rounded (headers, rising sheets).

Source

pub const fn bottom(radius: f32) -> Self

Only the bottom corners rounded.

Source

pub const fn left(radius: f32) -> Self

Only the left corners rounded.

Source

pub const fn right(radius: f32) -> Self

Only the right corners rounded.

With left this completes the set: a shape rounded on one vertical edge is what a side panel wants — square where it meets the window, round where it meets the content — and until now only the horizontal pair (top, bottom) existed.

Source

pub fn clamped(self) -> Self

Radii clamped at zero — a negative radius is meaningless when painting.

Source

pub fn inflate(self, by: f32) -> Self

Every corner grown by by — the envelope of a blurred shadow.

Source

pub fn scale(self, factor: f32) -> Self

Every radius multiplied by factor (DPI scaling).

Source

pub fn to_array(self) -> [f32; 4]

[tl, tr, br, bl], ready for the GPU.

Trait Implementations§

Source§

impl Clone for BorderRadius

Source§

fn clone(&self) -> Self

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 Copy for BorderRadius

Source§

impl Debug for BorderRadius

Source§

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

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

impl Default for BorderRadius

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<f32> for BorderRadius

Source§

fn from(radius: f32) -> Self

Converts to this type from the input type.
Source§

impl Lerp for BorderRadius

Source§

fn lerp(self, other: Self, t: f32) -> Self

Interpolates from self (at t=0) to other (at t=1).
Source§

impl PartialEq for BorderRadius

Source§

fn eq(&self, other: &Self) -> bool

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BorderRadius

Auto Trait Implementations§

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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.