Skip to main content

CornerRadii

Struct CornerRadii 

Source
pub struct CornerRadii {
    pub top_left: f64,
    pub top_right: f64,
    pub bottom_right: f64,
    pub bottom_left: f64,
}
Expand description

A radius for each corner of a rectangle, clockwise from the top left (docs/canvas.md “Rounded corners”). The shape a bar in a chart wants (rounded at its value end, square against its axis), a tab (rounded on top), or a card joined to its neighbor.

Radii are in points and never negative. CornerRadii::fitted shrinks them the way CSS does when two radii on one side would overlap, which is what a caller animating a radius or drawing a short bar needs to not think about.

Fields§

§top_left: f64§top_right: f64§bottom_right: f64§bottom_left: f64

Implementations§

Source§

impl CornerRadii

Source

pub fn uniform(r: f64) -> CornerRadii

The same radius on every corner: what Shape::RoundedRect draws.

Source

pub fn top(r: f64) -> CornerRadii

Rounded along the top edge, square along the bottom: a bar standing on its axis.

Source

pub fn bottom(r: f64) -> CornerRadii

Rounded along the bottom edge: a bar hanging below its axis.

Source

pub fn left(r: f64) -> CornerRadii

Rounded along the left edge: a bar growing leftward from its axis.

Source

pub fn right(r: f64) -> CornerRadii

Rounded along the right edge: a bar growing rightward from its axis.

Source

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

The four radii, clockwise from the top left.

Source

pub fn is_zero(self) -> bool

Whether every corner is square.

Source

pub fn is_uniform(self) -> bool

Whether every corner has the same radius, so the rectangle is a Shape::RoundedRect.

Source

pub fn fitted(self, size: Size) -> CornerRadii

These radii made to fit a size rectangle, the rule CSS uses for border-radius: a negative or non-finite radius is square, and when the two radii along any side add up to more than that side, every radius is scaled down by the same factor until none overlap. Scaling all four together keeps the corners in proportion, where clamping each one alone would turn a pill into a lopsided shape.

Trait Implementations§

Source§

impl Clone for CornerRadii

Source§

fn clone(&self) -> CornerRadii

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 CornerRadii

Source§

impl Debug for CornerRadii

Source§

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

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

impl Default for CornerRadii

Source§

fn default() -> CornerRadii

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

impl PartialEq for CornerRadii

Source§

fn eq(&self, other: &CornerRadii) -> 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 CornerRadii

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> ErasedDestructor for T
where T: 'static,

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> 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> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.