调整M2 Scheme中Surface颜色的生成。
This commit is contained in:
@@ -45,18 +45,8 @@ impl M2BaselineColors {
|
||||
None,
|
||||
)?,
|
||||
error: M2ColorSet::from_swatch(&error_swatch, &neutral_swatch, dark_baseline, None)?,
|
||||
background: M2ColorSet::from_swatch(
|
||||
&neutral_swatch,
|
||||
&neutral_swatch,
|
||||
dark_baseline,
|
||||
None,
|
||||
)?,
|
||||
surface: M2ColorSet::from_swatch(
|
||||
&neutral_swatch,
|
||||
&neutral_swatch,
|
||||
dark_baseline,
|
||||
None,
|
||||
)?,
|
||||
background: M2ColorSet::surface(&neutral_swatch, dark_baseline)?,
|
||||
surface: M2ColorSet::surface(&neutral_swatch, dark_baseline)?,
|
||||
shadow: map_hsl_to_srgb_hex(&neutral_swatch.tone(SwatchIndex::SI900)),
|
||||
custom_colors: HashMap::new(),
|
||||
neutral_swatch,
|
||||
|
@@ -48,6 +48,27 @@ impl M2ColorSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn surface(neutral: &M2Swatch, dark: bool) -> Result<Self, errors::ColorError> {
|
||||
let root_color_index = if dark {
|
||||
super::swatch::SwatchIndex::SI900
|
||||
} else {
|
||||
super::swatch::SwatchIndex::SI50
|
||||
};
|
||||
if dark {
|
||||
Ok(Self {
|
||||
root: map_hsl_to_srgb_hex(&neutral.desaturated_tone(root_color_index)),
|
||||
variant: map_hsl_to_srgb_hex(&neutral.desaturated_tone(root_color_index + 2)),
|
||||
on: map_hsl_to_srgb_hex(&neutral.tone(super::swatch::SwatchIndex::SI50)),
|
||||
})
|
||||
} else {
|
||||
Ok(Self {
|
||||
root: map_hsl_to_srgb_hex(&neutral.tone(root_color_index)),
|
||||
variant: map_hsl_to_srgb_hex(&neutral.tone(root_color_index - 2)),
|
||||
on: map_hsl_to_srgb_hex(&neutral.tone(super::swatch::SwatchIndex::SI900)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_css_variable(&self, prefix: &str, name: &str) -> Vec<String> {
|
||||
let mut variable_lines = Vec::new();
|
||||
|
||||
|
Reference in New Issue
Block a user