#[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
impl GpuGlassPrimitive
Sourcepub fn circle(center_x: f32, center_y: f32, radius: f32) -> Self
pub fn circle(center_x: f32, center_y: f32, radius: f32) -> Self
Create a glass circle (uses rounded rect with max radius)
Sourcepub fn with_corner_radius(self, radius: f32) -> Self
pub fn with_corner_radius(self, radius: f32) -> Self
Set uniform corner radius
Sourcepub fn with_corner_radius_per_corner(
self,
tl: f32,
tr: f32,
br: f32,
bl: f32,
) -> Self
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)
Sourcepub fn with_saturation(self, saturation: f32) -> Self
pub fn with_saturation(self, saturation: f32) -> Self
Set saturation (1.0 = normal, 0.0 = grayscale, >1.0 = oversaturated)
Sourcepub fn with_brightness(self, brightness: f32) -> Self
pub fn with_brightness(self, brightness: f32) -> Self
Set brightness multiplier
Sourcepub fn with_noise(self, amount: f32) -> Self
pub fn with_noise(self, amount: f32) -> Self
Set noise amount for frosted texture
Sourcepub fn with_glass_type(self, glass_type: GlassType) -> Self
pub fn with_glass_type(self, glass_type: GlassType) -> Self
Set glass type/style
Sourcepub fn ultra_thin(self) -> Self
pub fn ultra_thin(self) -> Self
Ultra-thin glass preset (very subtle blur)
Sourcepub fn with_border_thickness(self, thickness: f32) -> Self
pub fn with_border_thickness(self, thickness: f32) -> Self
Set border/edge highlight thickness in pixels
Sourcepub fn with_light_angle(self, angle_radians: f32) -> Self
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)
Sourcepub fn with_light_angle_degrees(self, angle_degrees: f32) -> Self
pub fn with_light_angle_degrees(self, angle_degrees: f32) -> Self
Set light angle in degrees (convenience method)
Sourcepub fn with_shadow(self, blur: f32, opacity: f32) -> Self
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)
Sourcepub fn with_shadow_offset(
self,
blur: f32,
opacity: f32,
offset_x: f32,
offset_y: f32,
) -> Self
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
Sourcepub fn with_refraction(self, strength: f32) -> Self
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
Sourcepub fn with_clip_rect(self, x: f32, y: f32, width: f32, height: f32) -> Self
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.
Sourcepub fn with_clip_rounded_rect(
self,
x: f32,
y: f32,
width: f32,
height: f32,
radius: f32,
) -> Self
pub fn with_clip_rounded_rect( self, x: f32, y: f32, width: f32, height: f32, radius: f32, ) -> Self
Set rounded rectangular clip region
Sourcepub 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
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
Sourcepub fn with_no_clip(self) -> Self
pub fn with_no_clip(self) -> Self
Clear clip region (no clipping)
Trait Implementations§
Source§impl Clone for GpuGlassPrimitive
impl Clone for GpuGlassPrimitive
Source§fn clone(&self) -> GpuGlassPrimitive
fn clone(&self) -> GpuGlassPrimitive
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GpuGlassPrimitive
impl Debug for GpuGlassPrimitive
Source§impl Default for GpuGlassPrimitive
impl Default for GpuGlassPrimitive
impl Copy for GpuGlassPrimitive
impl Pod for GpuGlassPrimitive
Auto Trait Implementations§
impl Freeze for GpuGlassPrimitive
impl RefUnwindSafe for GpuGlassPrimitive
impl Send for GpuGlassPrimitive
impl Sync for GpuGlassPrimitive
impl Unpin for GpuGlassPrimitive
impl UnsafeUnpin for GpuGlassPrimitive
impl UnwindSafe for GpuGlassPrimitive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
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
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.