diff options
| author | pml68 <contact@pml68.dev> | 2025-04-28 10:56:49 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-28 10:56:49 +0200 |
| commit | dac7e82e0bff128097653fe05829b2d576fcdb2f (patch) | |
| tree | 6f36736e79eecd6904933c6876af1df58e6b605b /crates/material_theme/src/utils.rs | |
| parent | feat(material_theme): implement `image::Catalog` (under feature flag) (diff) | |
| download | iced-builder-dac7e82e0bff128097653fe05829b2d576fcdb2f.tar.gz | |
refactor(material_theme)!: make `Theme` an enum with `Custom` variant
Diffstat (limited to '')
| -rw-r--r-- | crates/material_theme/src/utils.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/material_theme/src/utils.rs b/crates/material_theme/src/utils.rs index 5ad137e..963c9fc 100644 --- a/crates/material_theme/src/utils.rs +++ b/crates/material_theme/src/utils.rs @@ -30,6 +30,20 @@ pub fn shadow_from_elevation(elevation: f32, color: Color) -> Shadow { } } +pub fn disabled_text(color: Color) -> Color { + Color { + a: DISABLED_TEXT_OPACITY, + ..color + } +} + +pub fn disabled_container(color: Color) -> Color { + Color { + a: DISABLED_CONTAINER_OPACITY, + ..color + } +} + pub fn parse_argb(s: &str) -> Option<Color> { let hex = s.strip_prefix('#').unwrap_or(s); @@ -88,6 +102,10 @@ pub fn color_to_argb(color: Color) -> String { hex } +pub const fn lightness(color: Color) -> f32 { + color.r * 0.299 + color.g * 0.587 + color.b * 0.114 +} + pub fn mix(color1: Color, color2: Color, p2: f32) -> Color { if p2 <= 0.0 { return color1; |
