Struct piet::RadialGradient

source ·
pub struct RadialGradient { /* private fields */ }
Expand description

A description of a radial gradient in the unit rect, which can be resolved to a fixed gradient.

The center and origin are given in UnitPoint coordinates.

The center parameter specifies the center of the circle, so that points of distance radius from the center map to 1.0 in the gradient stops. The origin parameter specifies the point that maps to 0.0 in the gradient stops. Using the same origin and center gives a radially symmetric gradient; using different points is useful for simulating lighting effects. See configuring a radial gradient for a fuller explanation.

By default, origin and center are both at the center (0.5, 0.5) point. This can be changed during construction with the with_center and with_origin builder methods.

The ScaleMode describes how the gradient is mapped to a non-square rectangle; by default this will expand on the longest axis, but this can be changed with the with_scale_mode builder method.

Implementations§

source§

impl RadialGradient

source

pub fn new(radius: f64, stops: impl GradientStops) -> Self

Creates a simple RadialGradient. This gradient has origin and center set to (0.5, 0.5), and uses the Fill ScaleMode. These attributes can be modified with the with_center, with_origin, and with_scale_mode builder methods.

source

pub fn with_center(self, center: UnitPoint) -> Self

A builder-style method for changing the center of the gradient. This does not change the origin; in the common case, you will want to change both values.

See the main RadialGradient docs for an explanation of center vs. origin.

source

pub fn with_origin(self, origin: UnitPoint) -> Self

A builder-style method for changing the origin of the gradient.

See the main RadialGradient docs for an explanation of center vs. origin.

source

pub fn with_scale_mode(self, scale_mode: ScaleMode) -> Self

A builder-style method for changing the ScaleMode of the gradient.

Trait Implementations§

source§

impl Clone for RadialGradient

source§

fn clone(&self) -> RadialGradient

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for RadialGradient

source§

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

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

impl From<RadialGradient> for PaintBrush

source§

fn from(src: RadialGradient) -> PaintBrush

Converts to this type from the input type.
source§

impl<P: RenderContext> IntoBrush<P> for RadialGradient

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
    T: Clone,

§

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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.