Skip to main content

GpuGlassPrimitive

Struct GpuGlassPrimitive 

Source
#[repr(C)]
pub struct GpuGlassPrimitive { pub bounds: [f32; 4], pub corner_radius: [f32; 4], pub tint_color: [f32; 4], pub params: [f32; 4], pub params2: [f32; 4], pub type_info: [u32; 4], pub clip_bounds: [f32; 4], pub clip_radius: [f32; 4], pub border_color: [f32; 4], }
Expand description

A GPU glass primitive for vibrancy/blur effects (matches shader GlassPrimitive struct)

Memory layout:

  • bounds: vec4<f32> (16 bytes)
  • corner_radius: vec4<f32> (16 bytes)
  • tint_color: vec4<f32> (16 bytes)
  • params: vec4<f32> (16 bytes)
  • params2: vec4<f32> (16 bytes)
  • type_info: vec4<u32> (16 bytes)
  • clip_bounds: vec4<f32> (16 bytes)
  • clip_radius: vec4<f32> (16 bytes)
  • border_color: vec4<f32> (16 bytes) Total: 144 bytes

Fields§

§bounds: [f32; 4]

Bounds (x, y, width, height)

§corner_radius: [f32; 4]

Corner radii (top-left, top-right, bottom-right, bottom-left)

§tint_color: [f32; 4]

Tint color (RGBA)

§params: [f32; 4]

Glass parameters (blur_radius, saturation, brightness, noise_amount)

§params2: [f32; 4]

Glass parameters 2 (border_thickness, light_angle, shadow_blur, shadow_opacity)

  • border_thickness: thickness of edge highlight in pixels (default 0.8)
  • light_angle: angle of simulated light source in radians (default -PI/4 = top-left)
  • shadow_blur: blur radius for drop shadow (default 0 = no shadow)
  • shadow_opacity: opacity of the drop shadow (default 0 = no shadow)
§type_info: [u32; 4]

Type info (glass_type, shadow_offset_x_bits, shadow_offset_y_bits, clip_type)

§clip_bounds: [f32; 4]

Clip bounds (x, y, width, height) for clipping blur samples

§clip_radius: [f32; 4]

Clip corner radii (for rounded rect clips)

§border_color: [f32; 4]

Border color (RGBA) - when alpha > 0, renders a solid border instead of light-based highlights

Implementations§

Source§

impl GpuGlassPrimitive

Source

pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self

Create a new glass rectangle

Source

pub fn circle(center_x: f32, center_y: f32, radius: f32) -> Self

Create a glass circle (uses rounded rect with max radius)

Source

pub fn with_corner_radius(self, radius: f32) -> Self

Set uniform corner radius

Source

pub fn with_corner_radius_per_corner( self, tl: f32, tr: f32, br: f32, bl: f32, ) -> Self

Set per-corner radius (top-left, top-right, bottom-right, bottom-left)

Source

pub fn with_tint(self, r: f32, g: f32, b: f32, a: f32) -> Self

Set tint color

Source

pub fn with_blur(self, radius: f32) -> Self

Set blur radius

Source

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

Set saturation (1.0 = normal, 0.0 = grayscale, >1.0 = oversaturated)

Source

pub fn with_brightness(self, brightness: f32) -> Self

Set brightness multiplier

Source

pub fn with_noise(self, amount: f32) -> Self

Set noise amount for frosted texture

Source

pub fn with_glass_type(self, glass_type: GlassType) -> Self

Set glass type/style

Source

pub fn ultra_thin(self) -> Self

Ultra-thin glass preset (very subtle blur)

Source

pub fn thin(self) -> Self

Thin glass preset

Source

pub fn regular(self) -> Self

Regular glass preset (default)

Source

pub fn thick(self) -> Self

Thick glass preset (stronger effect)

Source

pub fn chrome(self) -> Self

Chrome/metallic glass preset

Source

pub fn with_border_thickness(self, thickness: f32) -> Self

Set border/edge highlight thickness in pixels

Source

pub fn with_light_angle(self, angle_radians: f32) -> Self

Set light angle for edge reflection effect in radians 0 = light from right, PI/2 = from bottom, PI = from left, -PI/2 = from top Default is -PI/4 (-45 degrees, top-left)

Source

pub fn with_light_angle_degrees(self, angle_degrees: f32) -> Self

Set light angle in degrees (convenience method)

Source

pub fn with_shadow(self, blur: f32, opacity: f32) -> Self

Set drop shadow for the glass panel

  • blur: blur radius in pixels (0 = no shadow)
  • opacity: shadow opacity (0.0 - 1.0)
Source

pub fn with_shadow_offset( self, blur: f32, opacity: f32, offset_x: f32, offset_y: f32, ) -> Self

Set drop shadow with offset and color For more advanced shadow control, use the full shadow parameters Note: Offset is stored in type_info[1] and type_info[2] as bits

Source

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

Set refraction strength multiplier (0.0 = no refraction/flat, 1.0 = full refraction) Use this to create flat blurred backgrounds without the edge bending effect

Source

pub fn flat(self) -> Self

Disable refraction for a flat blurred background (no edge bending)

Source

pub fn with_clip_rect(self, x: f32, y: f32, width: f32, height: f32) -> Self

Set rectangular clip region for blur sampling

Blur samples outside this region will be clamped to the edge, preventing blur from bleeding outside scroll containers.

Source

pub fn with_clip_rounded_rect( self, x: f32, y: f32, width: f32, height: f32, radius: f32, ) -> Self

Set rounded rectangular clip region

Source

pub fn with_clip_rounded_rect_per_corner( self, x: f32, y: f32, width: f32, height: f32, tl: f32, tr: f32, br: f32, bl: f32, ) -> Self

Set rounded rectangular clip region with per-corner radii

Source

pub fn with_no_clip(self) -> Self

Clear clip region (no clipping)

Source

pub fn with_border_color(self, r: f32, g: f32, b: f32, a: f32) -> Self

Set border color (RGBA). When alpha > 0, a solid border is rendered using this color instead of the default light-based edge highlights.

Trait Implementations§

Source§

impl Clone for GpuGlassPrimitive

Source§

fn clone(&self) -> GpuGlassPrimitive

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GpuGlassPrimitive

Source§

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

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

impl Default for GpuGlassPrimitive

Source§

fn default() -> Self

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

impl Zeroable for GpuGlassPrimitive

Source§

fn zeroed() -> Self

Source§

impl Copy for GpuGlassPrimitive

Source§

impl Pod for GpuGlassPrimitive

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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<T> for T

Source§

fn downcast(&self) -> &T

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

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

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,