diff options
| author | 2024-09-25 14:48:00 +0200 | |
|---|---|---|
| committer | 2025-01-06 20:31:20 +0100 | |
| commit | 3bc836827a808d17e7575923059904b7d2dbcc10 (patch) | |
| tree | c0b8607a1f1e82da28560122fdc5194c79c7b3fc /core | |
| parent | 39f2cdd9466d35201e1e4c7e4b2209a7fdeb74de (diff) | |
| download | iced-3bc836827a808d17e7575923059904b7d2dbcc10.tar.gz iced-3bc836827a808d17e7575923059904b7d2dbcc10.tar.bz2 iced-3bc836827a808d17e7575923059904b7d2dbcc10.zip | |
Added color for warning for TERRA, and added warning field to Extended with the needed struct and generate
Diffstat (limited to '')
| -rw-r--r-- | core/src/theme/palette.rs | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs index 83803c9a..d4ec84f2 100644 --- a/core/src/theme/palette.rs +++ b/core/src/theme/palette.rs @@ -317,6 +317,7 @@ impl Palette {          primary: color!(0xd1d1e0),          success: color!(0xb1b695),          danger: color!(0xe06b75), +        warning: color!(0xf5d76e), // Honey      };  } @@ -333,6 +334,8 @@ pub struct Extended {      pub success: Success,      /// The set of danger colors.      pub danger: Danger, +    /// The set of warning colors. +    pub warning: Warning,      /// Whether the palette is dark or not.      pub is_dark: bool,  } @@ -446,6 +449,11 @@ impl Extended {                  palette.background,                  palette.text,              ), +            warning: Warning::generate( +                palette.warning, +                palette.background, +                palette.text, +            ),              is_dark: is_dark(palette.background),          }      } @@ -601,6 +609,31 @@ impl Danger {      }  } +/// A set of warning colors. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Warning { +    /// The base warning color. +    pub base: Pair, +    /// A weaker version of the base warning color. +    pub weak: Pair, +    /// A stronger version of the base warning color. +    pub strong: Pair, +} + +impl Warning { +    /// Generates a set of [`Warning`] colors from the base, background, and text colors. +    pub fn generate(base: Color, background: Color, text: Color) -> Self { +        let weak = mix(base, background, 0.4); +        let strong = deviate(base, 0.1); + +        Self { +            base: Pair::new(base, text), +            weak: Pair::new(weak, text), +            strong: Pair::new(strong, text), +        } +    } +} +  fn darken(color: Color, amount: f32) -> Color {      let mut hsl = to_hsl(color); | 
