use esoc_color::{Color, ColorScale, Palette};
#[derive(Clone, Debug)]
pub struct NewTheme {
pub background: Color,
pub foreground: Color,
pub muted_foreground: Color,
pub palette: Palette,
pub grid_color: Color,
pub grid_width: f32,
pub show_grid: bool,
pub base_font_size: f32,
pub title_font_size: f32,
pub subtitle_font_size: f32,
pub label_font_size: f32,
pub tick_font_size: f32,
pub legend_font_size: f32,
pub font_family: String,
pub axis_width: f32,
pub line_width: f32,
pub point_size: f32,
pub color_scale: Option<ColorScale>,
}
impl NewTheme {
pub fn light() -> Self {
let base = 13.0_f32;
Self {
background: Color::WHITE,
foreground: Color::from_srgb8(0x33, 0x33, 0x33), muted_foreground: Color::from_srgb8(0x73, 0x73, 0x73), palette: Palette::tab10(),
grid_color: Color::from_srgb8(0xE0, 0xE0, 0xE0), grid_width: 0.5,
show_grid: true,
base_font_size: base,
title_font_size: (base * 1.2).max(8.0),
subtitle_font_size: (base * 1.1).max(8.0),
label_font_size: (base * 1.0).max(8.0),
tick_font_size: (base * 0.9).max(8.0),
legend_font_size: (base * 0.9).max(8.0),
font_family: "sans-serif".to_string(),
axis_width: 1.0,
line_width: 2.0,
point_size: 30.0, color_scale: None,
}
}
pub fn dark() -> Self {
let base = 13.0_f32;
Self {
background: Color::from_srgb8(0x1e, 0x1e, 0x2e),
foreground: Color::from_srgb8(0xcd, 0xd6, 0xf4),
muted_foreground: Color::new(0.55, 0.55, 0.65, 1.0), palette: Palette::tab10(),
grid_color: Color::from_srgb8(0x3a, 0x3a, 0x4a), grid_width: 0.5,
show_grid: true,
base_font_size: base,
title_font_size: (base * 1.2).max(8.0),
subtitle_font_size: (base * 1.1).max(8.0),
label_font_size: (base * 1.0).max(8.0),
tick_font_size: (base * 0.9).max(8.0),
legend_font_size: (base * 0.9).max(8.0),
font_family: "sans-serif".to_string(),
axis_width: 1.0,
line_width: 2.0,
point_size: 30.0,
color_scale: None,
}
}
pub fn publication() -> Self {
let base = 10.0_f32;
Self {
background: Color::WHITE,
foreground: Color::BLACK,
muted_foreground: Color::new(0.25, 0.25, 0.25, 1.0),
palette: Palette::tab10(),
grid_color: Color::TRANSPARENT,
grid_width: 0.0,
show_grid: false,
base_font_size: base,
title_font_size: (base * 1.2).max(8.0),
subtitle_font_size: (base * 1.1).max(8.0),
label_font_size: (base * 1.0).max(8.0),
tick_font_size: (base * 0.9).max(8.0),
legend_font_size: (base * 0.9).max(8.0),
font_family: "serif".to_string(),
axis_width: 1.0,
line_width: 1.5,
point_size: 25.0, color_scale: None,
}
}
}
impl Default for NewTheme {
fn default() -> Self {
Self::light()
}
}
pub type Theme = NewTheme;