diff options
| author | pml68 <contact@pml68.dev> | 2025-04-22 14:33:36 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-22 14:33:36 +0200 |
| commit | c3c05cef555de305729e53cef8b8e660e31eaf27 (patch) | |
| tree | a8f590846fe9b122361a12607e49e1be91d5bc72 /crates/material_theme/src/utils.rs | |
| parent | feat: use `pane_grid::Controls` for PaneGrid titlebar controls (diff) | |
| download | iced-builder-c3c05cef555de305729e53cef8b8e660e31eaf27.tar.gz | |
refactor: apply some clippy suggestions
Diffstat (limited to '')
| -rw-r--r-- | crates/material_theme/src/utils.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/material_theme/src/utils.rs b/crates/material_theme/src/utils.rs index f35396f..5ad137e 100644 --- a/crates/material_theme/src/utils.rs +++ b/crates/material_theme/src/utils.rs @@ -1,5 +1,7 @@ use iced_widget::core::{Color, Shadow, Vector}; +const COLOR_ERROR_MARGIN: f32 = 0.0001; + pub const HOVERED_LAYER_OPACITY: f32 = 0.08; pub const PRESSED_LAYER_OPACITY: f32 = 0.1; @@ -95,7 +97,9 @@ pub fn mix(color1: Color, color2: Color, p2: f32) -> Color { let p1 = 1.0 - p2; - if color1.a != 1.0 || color2.a != 1.0 { + if (color1.a - 1.0).abs() > COLOR_ERROR_MARGIN + || (color2.a - 1.0) > COLOR_ERROR_MARGIN + { let a = color1.a * p1 + color2.a * p2; if a > 0.0 { let c1 = color1.into_linear().map(|c| c * color1.a * p1); |
