Skip to main content

FillRecipe

Enum FillRecipe 

Source
pub enum FillRecipe {
    Solid(RecipeColor),
    StateLayer {
        base: RecipeColor,
        overlay: RecipeColor,
        alpha: f32,
    },
    LinearGradient {
        stops: Vec<GradientStop>,
        angle_deg: f32,
    },
    RadialGradient {
        stops: Vec<GradientStop>,
        center: (f32, f32),
        radius: f32,
    },
    None,
}
Expand description

What the inside of the ShapeRecipe is filled with.

Solid and StateLayer both resolve to a flat Color (the latter by compositing an overlay over a base at a given alpha — the Material-3 / Fluent “state layer” model). LinearGradient / RadialGradient describe true gradients; the renderer paints them via the SDF gradient pipeline once a PaintProp carries them (see resolve_fill_to_paint).

Variants§

§

Solid(RecipeColor)

Single flat color.

§

StateLayer

overlay composited over base at alpha — a translucent “state layer” (M3 hover = 8 %, pressed = 12 % on-color over the base fill). Resolves to a flat Color, so it flows through the solid paint path with no gradient support required.

Fields

§overlay: RecipeColor
§alpha: f32
§

LinearGradient

Linear gradient at angle_deg (0° = top→bottom, 90° = leading→trailing).

Fields

§angle_deg: f32
§

RadialGradient

Radial gradient with normalized center (0.0..=1.0) and radius in normalized units of the bounding rect’s longer side.

Fields

§center: (f32, f32)
§radius: f32
§

None

No fill (transparent).

Implementations§

Source§

impl FillRecipe

Source

pub fn solid(color: impl Into<RecipeColor>) -> Self

Source

pub fn state_layer( base: impl Into<RecipeColor>, overlay: impl Into<RecipeColor>, alpha: f32, ) -> Self

A translucent state layer: overlay composited over base at alpha (clamped to 0.0..=1.0). Resolves to a flat Color.

Source

pub fn resolve_flat(&self, colors: &ColorTokens) -> Option<Color>

Resolve the flat-color variants (Solid, StateLayer, None) against colors. Gradient variants return None here — they are resolved to a Paint by resolve_fill_to_paint, not to a flat color. FillRecipe::None maps to Some(Color::TRANSPARENT).

Trait Implementations§

Source§

impl Clone for FillRecipe

Source§

fn clone(&self) -> FillRecipe

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 Debug for FillRecipe

Source§

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

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

impl<'de> Deserialize<'de> for FillRecipe

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for FillRecipe

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for FillRecipe

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for FillRecipe

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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