DropShadowRecipe
struct · ferroui-base · v0.5.0
struct DropShadowRecipe
The values of the drop shadow of a theme shadow (WinUI's
DropShadowRecipe, GetDropShadowRecipe): an ambient and a directional
shadow of the elevation of an element.
Members
radius_xradius_yelevationambient_blur_radiusdirectional_blur_radiusambient_y_offsetdirectional_y_offsetambient_opacitydirectional_opacityambient_colordirectional_colorinsetsnewwith_corner_radiusis_visiblebox_shadows
radius_x
radius_x: f64
The corner radii of the rounded rectangle that casts the shadow.
radius_y
radius_y: f64
elevation
elevation: f32
The elevation: half the Z of the translation, at most 64.
ambient_blur_radius
ambient_blur_radius: f32
directional_blur_radius
directional_blur_radius: f32
ambient_y_offset
ambient_y_offset: f32
How far each shadow is moved down.
directional_y_offset
directional_y_offset: f32
ambient_opacity
ambient_opacity: f32
directional_opacity
directional_opacity: f32
ambient_color
ambient_color: crate::media::Color
Black with the opacity in the alpha (truncated, as WinUI converts it).
directional_color
directional_color: crate::media::Color
insets
insets: crate::Thickness
How far the shadow reaches around the element.
new
fn new(translation_z: f32, theme: ThemeShadowTheme) -> DropShadowRecipe
GetDropShadowRecipe(translationZ, theme): no shadow below an
elevation of 2; up to 16 a directional shadow only, of the opacity
min(elevation / 100 + 0.06, 0.14) in the light theme and 0.26 in the
dark one; above 16 also an ambient shadow, blurred by a third of the
elevation and moved down by 2, of the opacity 0.15 (light) or 0.37
(dark), the directional one 0.19 (light) or 0.37 (dark). The
directional shadow is blurred by the elevation and moved down by half
of it. The corner radii are zero; see
with_corner_radius.
A high contrast theme has no shadow: both opacities are zero.
with_corner_radius
fn with_corner_radius(self: Self, radius_x: f64, radius_y: f64) -> DropShadowRecipe
The recipe with the corner radii of the rounded rectangle that casts the shadow.
is_visible
fn is_visible(self: &Self) -> bool
Whether the recipe draws anything.
box_shadows
fn box_shadows(self: &Self) -> Vec<BoxShadow>
The two shadows as the box shadows of the rounded rectangle the shadow
is drawn around, the ambient first (CreateDropShadowVisual puts it
at the bottom). Each is blurred by one more than its radius, because
the rectangle is one pixel smaller on each side than the element
(CreateDropShadowVisual shrinks the dummy shape so that the
antialiased edge of the element lies over the shadow).
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafePropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherCloneCopyDebugStructuralPartialEqPartialEq
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.