Skip to main content

Glass

Struct Glass 

Source
pub struct Glass {
Show 22 fields pub variant: GlassVariant, pub shape: LiquidShape, pub tint: Option<Color>, pub blur_radius: Option<f32>, pub saturation: Option<f32>, pub refraction_depth: f32, pub refraction_curve: f32, pub dispersion: f32, pub transmission_refraction: f32, pub meniscus_absorption: f32, pub fold_depth: f32, pub optical_zoom: f32, pub rim_reflection: f32, pub ink_recolor: Option<(Color, f32)>, pub highlight: f32, pub lift: Option<f32>, pub contrast: Option<f32>, pub shadow: bool, pub shadow_style: Option<GlassShadow>, pub clip: bool, pub foreground: Option<Color>, pub adaptive_frost: f32,
}
Expand description

Builder describing a glass material. Resolved against the theme at the composition site, then evaluated per frame for density and dynamics.

Fields§

§variant: GlassVariant§shape: LiquidShape§tint: Option<Color>

Tint over the refracted backdrop; defaults to the theme’s glass tint.

§blur_radius: Option<f32>

Backdrop blur radius in dp (defaults per variant).

§saturation: Option<f32>

Saturation boost (defaults per variant).

§refraction_depth: f32

wcKSRD refraction depth as a fraction of the shape inradius.

§refraction_curve: f32

Normalized wcKSRD ray-return exponent.

§dispersion: f32

Normalized wcKSRD spectral ray separation.

§transmission_refraction: f32

Fraction of the wcKSRD displacement applied to the transmitted backdrop. The mirrored meniscus follows its own optical path.

§meniscus_absorption: f32

Energy removed from the transmitted ray at the meniscus. Reflection and spectral return follow independent paths.

§fold_depth: f32

Depth of the rim fold band in dp: the raised lens rim replays its interior mirrored toward the edge (a pure displacement). Zero disables the fold.

§optical_zoom: f32

Uniform face magnification of a riding lens (1.0 = no zoom): the backdrop projects enlarged across the whole face while the rim band keeps the wcKSRD edge mapping.

§rim_reflection: f32

Meniscus rim reflectivity multiplier (1.0 = the reference toggle’s visible rim line; near 0 = the segmented lens’s invisible body).

§ink_recolor: Option<(Color, f32)>

Optical ink recolor: the lens recolors dark transmitted ink toward this color at the given strength (the reference tab bubble’s color-mask act). None = off.

§highlight: f32

Specular rim intensity.

§lift: Option<f32>

Screen-lift override (brightening toward white; negative darkens). Defaults per variant.

§contrast: Option<f32>

Tone-compression override around the shader’s mid pivot (<1 pulls every backdrop toward mid-luminance — the reference dark menu reads bright magenta over deep purple AND dim gray over white through one law). Defaults per variant.

§shadow: bool

Drop shadow below the glass.

§shadow_style: Option<GlassShadow>

Per-surface shadow override.

§clip: bool

Clip the layer to shape. Morphing glass disables this — coverage comes entirely from the shader’s SDF.

§foreground: Option<Color>

Foreground color whose contrast the frost must protect. None uses the theme label color.

§adaptive_frost: f32

Strength of backdrop+foreground frost adaptation.

Implementations§

Source§

impl Glass

Source

pub fn regular() -> Self

Source

pub fn clear() -> Self

Source

pub fn lens() -> Self

The interactive lens bubble (reference: the iOS toggle/tab-bar drag lens): fully transparent, magnifying dome across the whole element, strong rainbow rim.

Source

pub fn shape(self, shape: LiquidShape) -> Self

Source

pub fn tint(self, tint: Color) -> Self

Source

pub fn blur_radius(self, radius_dp: f32) -> Self

Source

pub fn saturation(self, saturation: f32) -> Self

Source

pub fn refraction_depth(self, fraction: f32) -> Self

Source

pub fn refraction_curve(self, curve: f32) -> Self

Source

pub fn dispersion(self, strength: f32) -> Self

Source

pub fn transmission_refraction(self, strength: f32) -> Self

Source

pub fn meniscus_absorption(self, strength: f32) -> Self

Source

pub fn fold_depth(self, depth_dp: f32) -> Self

Sets the rim fold band depth in dp (zero disables the fold).

Source

pub fn optical_zoom(self, zoom: f32) -> Self

Sets the uniform face magnification of a riding lens (1.0 = none).

Source

pub fn rim_reflection(self, reflectivity: f32) -> Self

Sets the meniscus rim reflectivity (1.0 = full reference line).

Source

pub fn ink_recolor(self, color: Color, strength: f32) -> Self

The lens recolors dark transmitted ink toward color at strength (0..1) — the reference bubble’s color-mask act as a material optic.

Source

pub fn highlight(self, highlight: f32) -> Self

Source

pub fn lift(self, lift: f32) -> Self

Overrides the screen-lift (how hard the glass brightens what it shows; the bar lens uses a near-zero lift to stay transmissive).

Source

pub fn contrast(self, contrast: f32) -> Self

Overrides the tone compression around the shader’s mid pivot (values below one pull every backdrop toward mid-luminance).

Source

pub fn adaptive_frost(self, foreground: Color, strength: f32) -> Self

Source

pub fn shadow(self, shadow: bool) -> Self

Source

pub fn shadow_style(self, shadow: GlassShadow) -> Self

Source

pub fn no_clip(self) -> Self

Disables the layer clip: the shader’s SDF coverage is the only shape (required while morphing across geometry the clip can’t follow).

Trait Implementations§

Source§

impl Clone for Glass

Source§

fn clone(&self) -> Glass

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 Glass

Source§

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

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

impl Default for Glass

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Glass

Source§

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

Auto Trait Implementations§

§

impl Freeze for Glass

§

impl RefUnwindSafe for Glass

§

impl Send for Glass

§

impl Sync for Glass

§

impl Unpin for Glass

§

impl UnsafeUnpin for Glass

§

impl UnwindSafe for Glass

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

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.