Skip to main content

GlassMorph

Struct GlassMorph 

Source
pub struct GlassMorph {
    pub node_size: (f32, f32),
    pub primary: (f32, f32, f32, f32, f32),
    pub shapes: Vec<(f32, f32, f32, f32, f32)>,
    pub glue: f32,
    pub wobble_amplitude: f32,
    pub wobble_phase: f32,
    pub bulge_amplitude: f32,
    pub bulge_direction: f32,
    pub ellipse_blend: f32,
    pub deformation: Option<GlassDeformation>,
}
Expand description

A liquid shapeshift frame: the primary shape plus any number of nearby glass shapes, ALL smooth-unioned into one field — liquid glass glues to whatever glass it passes near (a growing menu necks with a neighboring button, the drag lens merges with the search circle). Up to GlassMorph::MAX_SHAPES extra shapes; an angular wobble makes the mid-flight field bubble like a droplet. All geometry is node-local dp: (center_x, center_y, width, height, corner_radius); radius sentinel -1 means capsule; -2 means SUBTRACT capsule — the shape carves a smooth hole in the field (the growing menu leaves its anchor button crisp on top until it swallows it).

Fields§

§node_size: (f32, f32)

The glass node’s own size in dp. The shader receives all morph geometry in dp and derives px-per-dp from the renderer-injected node pixel rect divided by this — geometry then lands correctly at ANY render scale (live window density, robot captures at 1.0, fractional desktop scales). The authoring widget always knows its node size.

§primary: (f32, f32, f32, f32, f32)§shapes: Vec<(f32, f32, f32, f32, f32)>

Nearby glass shapes participating in the field.

§glue: f32

Smooth-union glue radius (dp): shapes within it neck together.

§wobble_amplitude: f32

Wobble amplitude (dp) and phase (radians).

§wobble_phase: f32§bulge_amplitude: f32

Viscous leading-edge bulge: while the shape travels or inflates, its side facing bulge_direction (radians, math convention) swells like a pulled droplet. Amplitude in dp, usually driven by morph velocity.

§bulge_direction: f32§ellipse_blend: f32

Blends the primary rounded-rectangle field toward an ellipse. This is used by expanding droplets whose broad phase has continuous curvature rather than the straight sides of a capsule.

§deformation: Option<GlassDeformation>

Area-preserving affine strain applied to the primary shape. Extra scene shapes remain fixed so nearby glass can join the travelling droplet without being dragged through its local deformation.

Implementations§

Source§

impl GlassMorph

Source

pub const MAX_SHAPES: usize = 8

Shader budget for extra scene shapes.

Trait Implementations§

Source§

impl Clone for GlassMorph

Source§

fn clone(&self) -> GlassMorph

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 GlassMorph

Source§

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

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

impl Default for GlassMorph

Source§

fn default() -> GlassMorph

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

impl PartialEq for GlassMorph

Source§

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

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