diff options
| author | pml68 <contact@pml68.dev> | 2025-04-08 18:12:10 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-15 23:49:01 +0200 |
| commit | 00d296b230e41dbfaf33d1ba374beadf9d113948 (patch) | |
| tree | 321c1f3c40f8de8e665b830c67cf116ff29017e3 /material_theme/src/utils.rs | |
| parent | feat(material_theme): implement Catalog for iced_dialog (`dialog` feature) (diff) | |
| download | iced-builder-00d296b230e41dbfaf33d1ba374beadf9d113948.tar.gz | |
feat(material_theme): impl `scrollable::Catalog`
Diffstat (limited to '')
| -rw-r--r-- | material_theme/src/utils.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/material_theme/src/utils.rs b/material_theme/src/utils.rs index c9eb78e..7efec9b 100644 --- a/material_theme/src/utils.rs +++ b/material_theme/src/utils.rs @@ -1,4 +1,10 @@ -use iced_widget::core::Color; +use iced_widget::core::{Color, Shadow, Vector}; + +pub const HOVERED_LAYER_OPACITY: f32 = 0.08; +pub const PRESSED_LAYER_OPACITY: f32 = 0.1; + +pub const DISABLED_TEXT_OPACITY: f32 = 0.38; +pub const DISABLED_CONTAINER_OPACITY: f32 = 0.12; pub fn elevation(elevation_level: u8) -> f32 { (match elevation_level { @@ -11,6 +17,17 @@ pub fn elevation(elevation_level: u8) -> f32 { } as f32) } +pub fn shadow_from_elevation(elevation: f32, color: Color) -> Shadow { + Shadow { + color, + offset: Vector { + x: 0.0, + y: elevation, + }, + blur_radius: (elevation) * (1.0 + 0.4_f32.powf(elevation)), + } +} + pub fn mix(color1: Color, color2: Color, p2: f32) -> Color { if p2 <= 0.0 { return color1; |
