diff options
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; |
