Skip to main content

Material

Struct Material 

Source
pub struct Material {
Show 28 fields pub refraction: f32, pub depth: f32, pub outer_refraction: f32, pub outer_depth: f32, pub pinch: f32, pub pinch_width: f32, pub sideways: f32, pub dispersion: f32, pub corner_dispersion: f32, pub blur: f32, pub magnify: f32, pub light_range: (f32, f32), pub dark_range: (f32, f32), pub saturation: f32, pub rim: f32, pub rim_width: f32, pub rim_base: f32, pub dark_edge: f32, pub light_spill: f32, pub inner_glow: f32, pub inner_shadow: f32, pub shadow: f32, pub shadow_radius: f32, pub shadow_y: f32, pub shadow_tint: f32, pub tint: Option<Color>, pub tint_follow: f32, pub glass_tint_response: f32,
}
Expand description

The optical parameters of glass. Lengths are in points.

The surface is flat in the middle and curves down near its outline. Light passing through the curved part bends towards the middle, so the edge shows the backdrop from further inside. Start from a preset such as Material::REGULAR and change what you need.

Fields§

§refraction: f32

How far the curved edge bends the backdrop towards the middle.

§depth: f32

Width of the curved edge, measured inwards from the outline.

§outer_refraction: f32

Bend in the opposite direction, in a thin ring right at the outline.

§outer_depth: f32

Width of the outer ring.

§pinch: f32

Outward bend in a wide zone further in, like the raised shoulder of a drop of liquid.

§pinch_width: f32

Width of the pinch zone.

§sideways: f32

0 bends equally in all directions. At 1 the main bend works only sideways and the pinch only up and down.

§dispersion: f32

Separation of colors at the edge, as a fraction of the bend.

§corner_dispersion: f32

0 separates colors evenly around the outline. At 1 only the corners do, with the order of the colors alternating from corner to corner.

§blur: f32

Blur radius of the backdrop.

§magnify: f32

Magnification of the backdrop. 1 shows it at its real size.

§light_range: (f32, f32)

Range the backdrop brightness is mapped to on light glass, as (darkest, brightest).

§dark_range: (f32, f32)

Range the backdrop brightness is mapped to on dark glass.

§saturation: f32

Color saturation of the backdrop. 1 keeps it unchanged.

§rim: f32

Strength of the bright edge that catches the light.

§rim_width: f32

Width of the bright edge.

§rim_base: f32

Part of the bright edge that shows all around, whatever the light direction.

§dark_edge: f32

Strength of the thin dark line just inside the outline.

§light_spill: f32

Light from the surroundings that spills onto the edge.

§inner_glow: f32

Glow on the side facing away from the light.

§inner_shadow: f32

Shade on the side facing the light.

§shadow: f32

Opacity of the drop shadow.

§shadow_radius: f32

Blur radius of the drop shadow.

§shadow_y: f32

Downward offset of the drop shadow.

§shadow_tint: f32

How much of the color of the light passing through the shadow carries, from 0 (gray) to 1.

§tint: Option<Color>

Colored glass. The alpha is the strength of the color.

§tint_follow: f32

How much the tint follows the brightness of the backdrop. 0 is a flat fill.

§glass_tint_response: f32

How much Theme::glass_tint and reduced transparency change this material, from 0 to 1. Use 0 for glass that must stay clear, such as a lens above its own label.

Implementations§

Source§

impl Material

Source

pub const REGULAR: Material

Controls and bars. Readable over any content.

Source

pub const CLEAR: Material

Clear glass that stays transparent, for controls over photos and video.

Source

pub const THICK: Material

Menus, sheets, windows and panels: thicker, with a deeper shadow and softer light.

Source

pub const LENS: Material

The lens a slider, switch or segment thumb turns into while it is held.

Source

pub const BLOB: Material

The selection of a tab bar while it is held: a clear blob that stands out from the bar. A thin rim shows the bar from further inside, and the wide zone behind it pulls the edge of the bar inwards.

Source

pub const BLOB_LABELS: Material

Bends the tab labels under Material::BLOB: near its outline they smear inwards.

Source

pub fn blur(radius: f32) -> Material

Glass that only blurs: no bend, edge, light, shadow or tint. See Painter::blur.

Source

pub fn tinted(self, color: Color) -> Self

Returns the material colored with color. Its alpha is the strength.

Source

pub fn scaled(self, k: f32) -> Material

Returns a material that looks the same on an element k times as large.

Source

pub fn lerp(&self, other: &Material, t: f32) -> Material

Mixes towards other: t = 0 gives self, 1 gives other. Used when one kind of glass turns into another.

Trait Implementations§

Source§

impl Clone for Material

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 Material

Source§

impl Debug for Material

Source§

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

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

impl PartialEq for Material

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 StructuralPartialEq for Material

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

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