Skip to main content

RSuperellipse

Struct RSuperellipse 

Source
pub struct RSuperellipse {
    pub left: f64,
    pub top: f64,
    pub right: f64,
    pub bottom: f64,
    pub tl_radius_x: f64,
    pub tl_radius_y: f64,
    pub tr_radius_x: f64,
    pub tr_radius_y: f64,
    pub br_radius_x: f64,
    pub br_radius_y: f64,
    pub bl_radius_x: f64,
    pub bl_radius_y: f64,
}
Expand description

Drawing a widget asks for: the filters an Image or BackdropFilter takes, a rounded or superelliptical rectangle a clipper answers, and the alignment a WidgetSpan places its placeholder by. An immutable rounded superellipse.

A rounded superellipse (not to be confused with a standard superellipse) is a shape formed by replacing the four curved corners of a superellipse with circular arcs.

Fields§

§left: f64

The offset of the left edge of this rectangle from the x axis.

§top: f64

The offset of the top edge of this rectangle from the y axis.

§right: f64

The offset of the right edge of this rectangle from the x axis.

§bottom: f64

The offset of the bottom edge of this rectangle from the y axis.

§tl_radius_x: f64

The top-left horizontal radius.

§tl_radius_y: f64

The top-left vertical radius.

§tr_radius_x: f64

The top-right horizontal radius.

§tr_radius_y: f64

The top-right vertical radius.

§br_radius_x: f64

The bottom-right horizontal radius.

§br_radius_y: f64

The bottom-right vertical radius.

§bl_radius_x: f64

The bottom-left horizontal radius.

§bl_radius_y: f64

The bottom-left vertical radius.

Implementations§

Source§

impl RSuperellipse

Source

pub const ZERO: RSuperellipse

All values set to zero.

Source

pub fn from_ltrbxy( left: f64, top: f64, right: f64, bottom: f64, radius_x: f64, radius_y: f64, ) -> RSuperellipse

Construct from left, top, right, bottom, and the same radii along the horizontal axis and the vertical axis.

Source

pub fn from_ltrbr( left: f64, top: f64, right: f64, bottom: f64, radius: Radius, ) -> RSuperellipse

Construct from left, top, right, bottom, and the same radius in each corner.

Source

pub fn from_rect_xy(rect: Rect, radius_x: f64, radius_y: f64) -> RSuperellipse

Construct from a bounding box and the same radii along each axis.

Source

pub fn from_rect_and_radius(rect: Rect, radius: Radius) -> RSuperellipse

Construct from a bounding box and a radius that is the same in each corner.

Source

pub fn from_ltrb_and_corners( left: f64, top: f64, right: f64, bottom: f64, top_left: Radius, top_right: Radius, bottom_right: Radius, bottom_left: Radius, ) -> RSuperellipse

Construct from left, top, right, bottom, and per-corner radii.

Source

pub fn from_rect_and_corners( rect: Rect, top_left: Radius, top_right: Radius, bottom_right: Radius, bottom_left: Radius, ) -> RSuperellipse

Construct from a bounding box and per-corner radii.

Source

pub fn tl_radius(self) -> Radius

The top-left Radius.

Source

pub fn tr_radius(self) -> Radius

The top-right Radius.

Source

pub fn br_radius(self) -> Radius

The bottom-right Radius.

Source

pub fn bl_radius(self) -> Radius

The bottom-left Radius.

Source

pub fn shift(self, offset: Offset) -> RSuperellipse

Returns a clone translated by the given offset.

Source

pub fn inflate(self, delta: f64) -> RSuperellipse

Returns a clone with edges and radii moved outwards by delta.

Source

pub fn deflate(self, delta: f64) -> RSuperellipse

Returns a clone with edges and radii moved inwards by delta.

Source

pub fn width(self) -> f64

The distance between the left and right edges.

Source

pub fn height(self) -> f64

The distance between the top and bottom edges.

Source

pub fn outer_rect(self) -> Rect

The bounding box of this rounded rectangle.

Source

pub fn safe_inner_rect(self) -> Rect

The non-rounded rectangle constrained by the smaller of the two diagonals through the middle of the curve corners.

Source

pub fn middle_rect(self) -> Rect

The rectangle formed from the inner-most centers of the corner ellipses.

Source

pub fn wide_middle_rect(self) -> Rect

The biggest rectangle entirely inside with the full width.

Source

pub fn tall_middle_rect(self) -> Rect

The biggest rectangle entirely inside with the full height.

Source

pub fn is_empty(self) -> bool

Whether this rounded rectangle encloses a non-zero area.

Source

pub fn is_finite(self) -> bool

Whether all coordinates are finite.

Source

pub fn is_rect(self) -> bool

Whether this is a simple rectangle with zero corner radii.

Source

pub fn is_stadium(self) -> bool

Whether this rounded rectangle has a side with no straight section.

Source

pub fn is_ellipse(self) -> bool

Whether this rounded rectangle has no side with a straight section.

Source

pub fn is_circle(self) -> bool

Whether this rounded rectangle would draw as a circle.

Source

pub fn shortest_side(self) -> f64

The lesser of the magnitudes of the width and the height.

Source

pub fn longest_side(self) -> f64

The greater of the magnitudes of the width and the height.

Source

pub fn has_nan(self) -> bool

Whether any of the dimensions are NaN.

Source

pub fn center(self) -> Offset

The offset halfway between the left and right and the top and bottom edges.

Source

pub fn scale_radii(self) -> RSuperellipse

Scales all radii so that on each side their sum will not exceed the width or height.

Source

pub fn lerp( a: Option<RSuperellipse>, b: Option<RSuperellipse>, t: f64, ) -> Option<RSuperellipse>

Linearly interpolate between two rounded rectangles.

If either is null, this function substitutes ZERO.

Source§

impl RSuperellipse

Source

pub fn contains(self, point: Offset) -> bool

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies inside the rounded superellipse.

Dart’s method is engine FFI (Impeller). Ours uses valo’s Impeller-port valo_geometry::RoundSuperellipse::contains.

Trait Implementations§

Source§

impl Clone for RSuperellipse

Source§

fn clone(&self) -> RSuperellipse

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 RSuperellipse

Source§

impl Debug for RSuperellipse

Source§

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

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

impl PartialEq for RSuperellipse

Source§

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

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

Source§

fn downcast(&self) -> &T

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

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

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