Skip to main content

Glass

Struct Glass 

Source
pub struct Glass {
Show 20 fields pub variant: GlassVariant, pub shape: LiquidShape, pub tint: Option<Color>, pub blur_radius: Option<f32>, pub saturation: Option<f32>, pub chromatic_aberration: f32, pub dispersion_axes: (f32, f32), pub displacement: f32, pub bezel_width: f32, pub highlight: f32, pub surface_profile: GlassSurfaceProfile, pub sheen: Option<f32>, pub lift: Option<f32>, pub shadow: bool, pub shadow_style: Option<GlassShadow>, pub clip: bool, pub foreground: Option<Color>, pub adaptive_frost: f32, pub content_recolor: Option<(Color, f32)>, pub edge_fold: 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).

§chromatic_aberration: f32

Chromatic aberration spread at the bezel.

§dispersion_axes: (f32, f32)

Principal-axis wavelength response for the X-Z and Y-Z profiles.

§displacement: f32

Lens strength: refraction displacement in px.

§bezel_width: f32

Bezel width in dp (the refractive rim zone).

§highlight: f32

Specular rim intensity.

§surface_profile: GlassSurfaceProfile

Physical X-Z/Y-Z cross-sections for the surface.

§sheen: Option<f32>

Broad Fresnel sheen across the bezel. None uses the variant default.

§lift: Option<f32>

Screen-lift override (brightening toward white; negative darkens). 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.

§content_recolor: Option<(Color, f32)>

Accent applied only to dark foreground detail sampled inside the glass.

§edge_fold: f32

Top-edge fold strength (0 = off): content just above the glass renders vertically mirrored inside the top band (the reference bar’s meniscus folds section headers upside-down into it).

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 chromatic_aberration(self, spread: f32) -> Self

Source

pub fn dispersion_axes(self, x: f32, y: f32) -> Self

Source

pub fn displacement(self, displacement_px: f32) -> Self

Source

pub fn bezel_width(self, width_dp: f32) -> Self

Source

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

Source

pub fn surface_profile(self, profile: GlassSurfaceProfile) -> Self

Source

pub fn sheen(self, sheen: 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 adaptive_frost(self, foreground: Color, strength: f32) -> Self

Source

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

Source

pub fn edge_fold(self, 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.