Skip to main content

Radius

Struct Radius 

Source
pub struct Radius {
    pub x: f64,
    pub y: f64,
}
Expand description

A radius for either circular or elliptical shapes.

Fields§

§x: f64

The radius value on the horizontal axis.

§y: f64

The radius value on the vertical axis.

Implementations§

Source§

impl Radius

Source

pub const ZERO: Radius

A radius with x and y values set to zero.

You can use Radius::ZERO with RRect or RSuperellipse to have right-angle corners.

Source

pub const fn circular(radius: f64) -> Radius

Constructs a circular radius. x and y will have the same radius value.

Source

pub const fn elliptical(x: f64, y: f64) -> Radius

Constructs an elliptical radius with the given radii.

Source

pub fn clamp(&self, minimum: Option<Radius>, maximum: Option<Radius>) -> Radius

Returns this Radius, with values clamped to the given min and max Radius values.

The minimum value defaults to Radius::circular(f64::NEG_INFINITY), and the maximum value defaults to Radius::circular(f64::INFINITY).

Source

pub fn clamp_values( &self, minimum_x: Option<f64>, minimum_y: Option<f64>, maximum_x: Option<f64>, maximum_y: Option<f64>, ) -> Radius

Returns this Radius, with values clamped to the given min and max values in each dimension.

The minimum_x and minimum_y values default to f64::NEG_INFINITY, and the maximum_x and maximum_y values default to f64::INFINITY.

Source

pub fn truncating_div(&self, operand: f64) -> Radius

Integer (truncating) division operator.

Returns a radius whose coordinates are the coordinates of this radius divided by the scalar operand, rounded towards zero.

Source

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

Linearly interpolate between two radii.

If either is null, this function substitutes Radius::ZERO instead.

The t argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning a (or something equivalent to a), 1.0 meaning that the interpolation has finished, returning b (or something equivalent to b), and values in between meaning that the interpolation is at the relevant point on the timeline between a and b. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves such as Curves.elasticInOut).

Values for t are usually obtained from an Animation<double>, such as an AnimationController.

Trait Implementations§

Source§

impl Add for Radius

Binary addition operator.

Returns a radius whose x value is the sum of the x values of the two operands, and whose y value is the sum of the y values of the two operands.

Source§

type Output = Radius

The resulting type after applying the + operator.
Source§

fn add(self, other: Radius) -> Radius

Performs the + operation. Read more
Source§

impl Clone for Radius

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 Radius

Source§

impl Debug for Radius

Source§

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

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

impl Div<f64> for Radius

Division operator.

Returns a radius whose coordinates are the coordinates of the left-hand-side operand (a radius) divided by the scalar right-hand-side operand (an f64).

Source§

type Output = Radius

The resulting type after applying the / operator.
Source§

fn div(self, operand: f64) -> Radius

Performs the / operation. Read more
Source§

impl Mul<f64> for Radius

Multiplication operator.

Returns a radius whose coordinates are the coordinates of the left-hand-side operand (a radius) multiplied by the scalar right-hand-side operand (an f64).

Source§

type Output = Radius

The resulting type after applying the * operator.
Source§

fn mul(self, operand: f64) -> Radius

Performs the * operation. Read more
Source§

impl Neg for Radius

Unary negation operator.

Returns a Radius with the distances negated.

Radiuses with negative values aren’t geometrically meaningful, but could occur as part of expressions. For example, negating a radius of one pixel and then adding the result to another radius is equivalent to subtracting a radius of one pixel from the other.

Source§

type Output = Radius

The resulting type after applying the - operator.
Source§

fn neg(self) -> Radius

Performs the unary - operation. Read more
Source§

impl PartialEq for Radius

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 Rem<f64> for Radius

Modulo (remainder) operator.

Returns a radius whose coordinates are the remainder of dividing the coordinates of the left-hand-side operand (a radius) by the scalar right-hand-side operand (an f64).

Source§

type Output = Radius

The resulting type after applying the % operator.
Source§

fn rem(self, operand: f64) -> Radius

Performs the % operation. Read more
Source§

impl StructuralPartialEq for Radius

Source§

impl Sub for Radius

Binary subtraction operator.

Returns a radius whose x value is the left-hand-side operand’s x minus the right-hand-side operand’s x and whose y value is the left-hand-side operand’s y minus the right-hand-side operand’s y.

Source§

type Output = Radius

The resulting type after applying the - operator.
Source§

fn sub(self, other: Radius) -> Radius

Performs the - operation. Read more

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

Source§

fn downcast(&self) -> &T

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> 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,