diff --git a/material-color-utilities-rs/src/palettes/core.rs b/material-color-utilities-rs/src/palettes/core.rs index 65d9008..dc9d296 100644 --- a/material-color-utilities-rs/src/palettes/core.rs +++ b/material-color-utilities-rs/src/palettes/core.rs @@ -34,7 +34,7 @@ impl CorePalette { a1: TonalPalette::from_hue_and_chroma(hue, chroma), a2: TonalPalette::from_hue_and_chroma(hue, chroma / 3.), a3: TonalPalette::from_hue_and_chroma(hue + 60., chroma / 2.), - n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(4.0)), + n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(6.0)), n2: TonalPalette::from_hue_and_chroma(hue, (chroma / 6.).min(8.0)), error, }, @@ -44,7 +44,7 @@ impl CorePalette { a1: TonalPalette::from_hue_and_chroma(hue, chroma), a2: TonalPalette::from_hue_and_chroma(hue + angle, chroma / 3.), a3: TonalPalette::from_hue_and_chroma(hue - angle, chroma / 2.), - n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(4.0)), + n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(6.0)), n2: TonalPalette::from_hue_and_chroma(hue, (chroma / 6.).min(8.0)), error, } @@ -55,7 +55,7 @@ impl CorePalette { a1: TonalPalette::from_hue_and_chroma(hue, chroma), a2: TonalPalette::from_hue_and_chroma(hue + angle, chroma / 3.), a3: TonalPalette::from_hue_and_chroma(hue - angle, chroma / 2.), - n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(4.0)), + n1: TonalPalette::from_hue_and_chroma(hue, (chroma / 12.).min(6.0)), n2: TonalPalette::from_hue_and_chroma(hue, (chroma / 6.).min(8.0)), error, } @@ -66,7 +66,7 @@ impl CorePalette { a1: TonalPalette::from_hue_and_chroma(hue, 48.0f64.max(chroma)), a2: TonalPalette::from_hue_and_chroma(hue, 16.), a3: TonalPalette::from_hue_and_chroma(hue + 60., 24.), - n1: TonalPalette::from_hue_and_chroma(hue, 4.), + n1: TonalPalette::from_hue_and_chroma(hue, 6.), n2: TonalPalette::from_hue_and_chroma(hue, 8.), error, } diff --git a/material-color-utilities-rs/src/scheme/scheme.rs b/material-color-utilities-rs/src/scheme/scheme.rs index 29895d9..b816e32 100644 --- a/material-color-utilities-rs/src/scheme/scheme.rs +++ b/material-color-utilities-rs/src/scheme/scheme.rs @@ -8,26 +8,35 @@ use serde::{ser::SerializeStruct, Serialize}; #[derive(Debug, Default, PartialEq, Eq, Clone, Copy)] pub struct Scheme { pub primary: [u8; 4], + pub primary_fixed: [u8; 4], + pub primary_fixed_dim: [u8; 4], pub on_primary: [u8; 4], + pub on_primary_fixed: [u8; 4], + pub on_primary_fixed_variant: [u8; 4], pub primary_container: [u8; 4], pub on_primary_container: [u8; 4], pub secondary: [u8; 4], + pub secondary_fixed: [u8; 4], + pub secondary_fixed_dim: [u8; 4], pub on_secondary: [u8; 4], + pub on_secondary_fixed: [u8; 4], + pub on_secondary_fixed_variant: [u8; 4], pub secondary_container: [u8; 4], pub on_secondary_container: [u8; 4], pub tertiary: [u8; 4], + pub tertiary_fixed: [u8; 4], + pub tertiary_fixed_dim: [u8; 4], pub on_tertiary: [u8; 4], + pub on_tertiary_fixed: [u8; 4], + pub on_tertiary_fixed_variant: [u8; 4], pub tertiary_container: [u8; 4], pub on_tertiary_container: [u8; 4], pub error: [u8; 4], pub on_error: [u8; 4], pub error_container: [u8; 4], pub on_error_container: [u8; 4], - pub background: [u8; 4], - pub on_background: [u8; 4], pub surface: [u8; 4], pub on_surface: [u8; 4], - pub surface_variant: [u8; 4], pub on_surface_variant: [u8; 4], pub outline: [u8; 4], pub outline_variant: [u8; 4], @@ -36,6 +45,13 @@ pub struct Scheme { pub inverse_surface: [u8; 4], pub inverse_on_surface: [u8; 4], pub inverse_primary: [u8; 4], + pub surface_dim: [u8; 4], + pub surface_bright: [u8; 4], + pub surface_container_lowest: [u8; 4], + pub surface_container_low: [u8; 4], + pub surface_container: [u8; 4], + pub surface_container_high: [u8; 4], + pub surface_container_highest: [u8; 4], } #[cfg(feature = "serde")] @@ -55,26 +71,35 @@ impl Serialize for Scheme { } ser!(primary); + ser!(primary_fixed); + ser!(primary_fixed_dim); ser!(on_primary); + ser!(on_primary_fixed); + ser!(on_primary_fixed_variant); ser!(primary_container); ser!(on_primary_container); ser!(secondary); + ser!(secondary_fixed); + ser!(secondary_fixed_dim); ser!(on_secondary); + ser!(on_secondary_fixed); + ser!(on_secondary_fixed_variant); ser!(secondary_container); ser!(on_secondary_container); ser!(tertiary); + ser!(tertiary_fixed); + ser!(tertiary_fixed_dim); ser!(on_tertiary); + ser!(on_tertiary_fixed); + ser!(on_tertiary_fixed_variant); ser!(tertiary_container); ser!(on_tertiary_container); ser!(error); ser!(on_error); ser!(error_container); ser!(on_error_container); - ser!(background); - ser!(on_background); ser!(surface); ser!(on_surface); - ser!(surface_variant); ser!(on_surface_variant); ser!(outline); ser!(outline_variant); @@ -83,6 +108,13 @@ impl Serialize for Scheme { ser!(inverse_surface); ser!(inverse_on_surface); ser!(inverse_primary); + ser!(surface_dim); + ser!(surface_bright); + ser!(surface_container_lowest); + ser!(surface_container_low); + ser!(surface_container); + ser!(surface_container_high); + ser!(surface_container_highest); state.end() } @@ -92,26 +124,35 @@ impl Scheme { pub fn light_from_core_palette(core: &mut CorePalette) -> Scheme { Scheme { primary: core.a1.tone(40), + primary_fixed: core.a1.tone(90), + primary_fixed_dim: core.a1.tone(80), on_primary: core.a1.tone(100), + on_primary_fixed: core.a1.tone(10), + on_primary_fixed_variant: core.a1.tone(30), primary_container: core.a1.tone(90), on_primary_container: core.a1.tone(10), secondary: core.a2.tone(40), + secondary_fixed: core.a2.tone(90), + secondary_fixed_dim: core.a2.tone(80), on_secondary: core.a2.tone(100), + on_secondary_fixed: core.a2.tone(10), + on_secondary_fixed_variant: core.a2.tone(30), secondary_container: core.a2.tone(90), on_secondary_container: core.a2.tone(10), tertiary: core.a3.tone(40), + tertiary_fixed: core.a3.tone(90), + tertiary_fixed_dim: core.a3.tone(80), on_tertiary: core.a3.tone(100), + on_tertiary_fixed: core.a3.tone(10), + on_tertiary_fixed_variant: core.a3.tone(30), tertiary_container: core.a3.tone(90), on_tertiary_container: core.a3.tone(10), error: core.error.tone(40), on_error: core.error.tone(100), error_container: core.error.tone(90), on_error_container: core.error.tone(10), - background: core.n1.tone(99), - on_background: core.n1.tone(10), - surface: core.n1.tone(99), + surface: core.n1.tone(98), on_surface: core.n1.tone(10), - surface_variant: core.n2.tone(90), on_surface_variant: core.n2.tone(30), outline: core.n2.tone(50), outline_variant: core.n2.tone(80), @@ -120,32 +161,48 @@ impl Scheme { inverse_surface: core.n1.tone(20), inverse_on_surface: core.n1.tone(95), inverse_primary: core.a1.tone(80), + surface_dim: core.n1.tone(87), + surface_bright: core.n1.tone(98), + surface_container_lowest: core.n1.tone(100), + surface_container_low: core.n1.tone(96), + surface_container: core.n1.tone(94), + surface_container_high: core.n1.tone(92), + surface_container_highest: core.n1.tone(90), } } pub fn dark_from_core_palette(core: &mut CorePalette) -> Scheme { Scheme { primary: core.a1.tone(80), + primary_fixed: core.a1.tone(90), + primary_fixed_dim: core.a1.tone(80), on_primary: core.a1.tone(20), + on_primary_fixed: core.a1.tone(10), + on_primary_fixed_variant: core.a1.tone(30), primary_container: core.a1.tone(30), on_primary_container: core.a1.tone(90), secondary: core.a2.tone(80), + secondary_fixed: core.a2.tone(90), + secondary_fixed_dim: core.a2.tone(80), on_secondary: core.a2.tone(20), + on_secondary_fixed: core.a2.tone(10), + on_secondary_fixed_variant: core.a2.tone(30), secondary_container: core.a2.tone(30), on_secondary_container: core.a2.tone(90), tertiary: core.a3.tone(80), + tertiary_fixed: core.a3.tone(90), + tertiary_fixed_dim: core.a3.tone(80), on_tertiary: core.a3.tone(20), + on_tertiary_fixed: core.a3.tone(10), + on_tertiary_fixed_variant: core.a3.tone(30), tertiary_container: core.a3.tone(30), on_tertiary_container: core.a3.tone(90), error: core.error.tone(80), on_error: core.error.tone(20), error_container: core.error.tone(30), on_error_container: core.error.tone(80), - background: core.n1.tone(10), - on_background: core.n1.tone(90), - surface: core.n1.tone(10), + surface: core.n1.tone(6), on_surface: core.n1.tone(90), - surface_variant: core.n2.tone(30), on_surface_variant: core.n2.tone(80), outline: core.n2.tone(60), outline_variant: core.n2.tone(30), @@ -154,32 +211,48 @@ impl Scheme { inverse_surface: core.n1.tone(90), inverse_on_surface: core.n1.tone(20), inverse_primary: core.a1.tone(40), + surface_dim: core.n1.tone(6), + surface_bright: core.n1.tone(24), + surface_container_lowest: core.n1.tone(4), + surface_container_low: core.n1.tone(10), + surface_container: core.n1.tone(12), + surface_container_high: core.n1.tone(17), + surface_container_highest: core.n1.tone(22), } } pub fn pure_dark_from_core_palette(core: &mut CorePalette) -> Scheme { Scheme { primary: core.a1.tone(80), + primary_fixed: core.a1.tone(90), + primary_fixed_dim: core.a1.tone(80), on_primary: core.a1.tone(20), + on_primary_fixed: core.a1.tone(10), + on_primary_fixed_variant: core.a1.tone(30), primary_container: core.a1.tone(30), on_primary_container: core.a1.tone(90), secondary: core.a2.tone(80), + secondary_fixed: core.a2.tone(90), + secondary_fixed_dim: core.a2.tone(80), on_secondary: core.a2.tone(20), + on_secondary_fixed: core.a2.tone(10), + on_secondary_fixed_variant: core.a2.tone(30), secondary_container: core.a2.tone(30), on_secondary_container: core.a2.tone(90), tertiary: core.a3.tone(80), + tertiary_fixed: core.a3.tone(90), + tertiary_fixed_dim: core.a3.tone(80), on_tertiary: core.a3.tone(20), + on_tertiary_fixed: core.a3.tone(10), + on_tertiary_fixed_variant: core.a3.tone(30), tertiary_container: core.a3.tone(30), on_tertiary_container: core.a3.tone(90), error: core.error.tone(80), on_error: core.error.tone(20), error_container: core.error.tone(30), on_error_container: core.error.tone(80), - background: core.n1.tone(0), - on_background: core.n1.tone(90), surface: core.n1.tone(0), on_surface: core.n1.tone(90), - surface_variant: core.n2.tone(5), on_surface_variant: core.n2.tone(80), outline: core.n2.tone(60), outline_variant: core.n2.tone(30), @@ -188,6 +261,13 @@ impl Scheme { inverse_surface: core.n1.tone(90), inverse_on_surface: core.n1.tone(20), inverse_primary: core.a1.tone(40), + surface_dim: core.n1.tone(87), + surface_bright: core.n1.tone(98), + surface_container_lowest: core.n1.tone(100), + surface_container_low: core.n1.tone(96), + surface_container: core.n1.tone(94), + surface_container_high: core.n1.tone(92), + surface_container_highest: core.n1.tone(90), } } } diff --git a/src/util/color.rs b/src/util/color.rs index 45b5366..92e8a67 100644 --- a/src/util/color.rs +++ b/src/util/color.rs @@ -14,29 +14,38 @@ use serde_json::json; use std::collections::HashMap; use std::str::FromStr; -pub const COLORS: [&str; 30] = [ +pub const COLORS: [&str; 46] = [ "source_color", "primary", + "primary_fixed", + "primary_fixed_dim", "on_primary", + "on_primary_fixed", + "on_primary_fixed_variant", "primary_container", "on_primary_container", "secondary", + "secondary_fixed", + "secondary_fixed_dim", "on_secondary", + "on_secondary_fixed", + "on_secondary_fixed_variant", "secondary_container", "on_secondary_container", "tertiary", + "tertiary_fixed", + "tertiary_fixed_dim", "on_tertiary", + "on_tertiary_fixed", + "on_tertiary_fixed_variant", "tertiary_container", "on_tertiary_container", "error", "on_error", "error_container", "on_error_container", - "background", - "on_background", "surface", "on_surface", - "surface_variant", "on_surface_variant", "outline", "outline_variant", @@ -45,6 +54,13 @@ pub const COLORS: [&str; 30] = [ "inverse_surface", "inverse_on_surface", "inverse_primary", + "surface_dim", + "surface_bright", + "surface_container_lowest", + "surface_container_low", + "surface_container", + "surface_container_high", + "surface_container_highest", ]; pub const COLORS_ANDROID: [&str; 26] = [ @@ -84,26 +100,35 @@ impl SchemeExt for Scheme { fn get_value<'a>(&'a self, field: &str, source_color: &'a [u8; 4]) -> &[u8; 4] { match field { "primary" => &self.primary, + "primary_fixed" => &self.primary_fixed, + "primary_fixed_dim" => &self.primary_fixed_dim, "on_primary" => &self.on_primary, + "on_primary_fixed" => &self.on_primary_fixed, + "on_primary_fixed_variant" => &self.on_primary_fixed_variant, "primary_container" => &self.primary_container, "on_primary_container" => &self.on_primary_container, "secondary" => &self.secondary, + "secondary_fixed" => &self.secondary_fixed, + "secondary_fixed_dim" => &self.secondary_fixed_dim, "on_secondary" => &self.on_secondary, + "on_secondary_fixed" => &self.on_secondary_fixed, + "on_secondary_fixed_variant" => &self.on_secondary_fixed_variant, "secondary_container" => &self.secondary_container, "on_secondary_container" => &self.on_secondary_container, "tertiary" => &self.tertiary, + "tertiary_fixed" => &self.tertiary_fixed, + "tertiary_fixed_dim" => &self.tertiary_fixed_dim, "on_tertiary" => &self.on_tertiary, + "on_tertiary_fixed" => &self.on_tertiary_fixed, + "on_tertiary_fixed_variant" => &self.on_tertiary_fixed_variant, "tertiary_container" => &self.tertiary_container, "on_tertiary_container" => &self.on_tertiary_container, "error" => &self.error, "on_error" => &self.on_error, "error_container" => &self.error_container, "on_error_container" => &self.on_error_container, - "background" => &self.background, - "on_background" => &self.on_background, "surface" => &self.surface, "on_surface" => &self.on_surface, - "surface_variant" => &self.surface_variant, "on_surface_variant" => &self.on_surface_variant, "outline" => &self.outline, "outline_variant" => &self.outline_variant, @@ -112,6 +137,13 @@ impl SchemeExt for Scheme { "inverse_surface" => &self.inverse_surface, "inverse_on_surface" => &self.inverse_on_surface, "inverse_primary" => &self.inverse_primary, + "surface_dim" => &self.surface_dim, + "surface_bright" => &self.surface_bright, + "surface_container_lowest" => &self.surface_container_lowest, + "surface_container_low" => &self.surface_container_low, + "surface_container" => &self.surface_container, + "surface_container_high" => &self.surface_container_high, + "surface_container_highest" => &self.surface_container_highest, "source_color" => source_color, _ => panic!(), }