use glam::Vec4;
#[derive(Debug, Clone)]
pub struct ModernDarkTheme {
pub background_primary: Vec4,
pub background_secondary: Vec4,
pub background_tertiary: Vec4,
pub text_primary: Vec4,
pub text_secondary: Vec4,
pub text_accent: Vec4,
pub accent_primary: Vec4,
pub accent_secondary: Vec4,
pub accent_success: Vec4,
pub accent_warning: Vec4,
pub accent_error: Vec4,
pub plot_background: Vec4,
pub grid_major: Vec4,
pub grid_minor: Vec4,
pub axis_color: Vec4,
pub data_colors: Vec<Vec4>,
}
impl Default for ModernDarkTheme {
fn default() -> Self {
Self {
background_primary: Vec4::new(0.08, 0.09, 0.11, 1.0), background_secondary: Vec4::new(0.12, 0.14, 0.16, 1.0), background_tertiary: Vec4::new(0.16, 0.18, 0.21, 1.0),
text_primary: Vec4::new(0.95, 0.96, 0.97, 1.0), text_secondary: Vec4::new(0.75, 0.78, 0.82, 1.0), text_accent: Vec4::new(0.40, 0.85, 0.55, 1.0),
accent_primary: Vec4::new(0.35, 0.78, 0.48, 1.0), accent_secondary: Vec4::new(0.28, 0.65, 0.40, 1.0), accent_success: Vec4::new(0.42, 0.85, 0.55, 1.0), accent_warning: Vec4::new(0.95, 0.75, 0.25, 1.0), accent_error: Vec4::new(0.92, 0.35, 0.35, 1.0),
plot_background: Vec4::new(0.10, 0.11, 0.13, 1.0), grid_major: Vec4::new(0.25, 0.27, 0.30, 0.6), grid_minor: Vec4::new(0.20, 0.22, 0.25, 0.3), axis_color: Vec4::new(0.65, 0.68, 0.72, 1.0),
data_colors: vec![
Vec4::new(0.35, 0.78, 0.48, 1.0), Vec4::new(0.25, 0.65, 0.85, 1.0), Vec4::new(0.95, 0.55, 0.25, 1.0), Vec4::new(0.75, 0.35, 0.85, 1.0), Vec4::new(0.95, 0.75, 0.25, 1.0), Vec4::new(0.85, 0.35, 0.55, 1.0), Vec4::new(0.25, 0.85, 0.75, 1.0), Vec4::new(0.65, 0.75, 0.35, 1.0), ],
}
}
}
impl ModernDarkTheme {
pub fn get_data_color(&self, index: usize) -> Vec4 {
self.data_colors[index % self.data_colors.len()]
}
pub fn lighten_color(color: Vec4, factor: f32) -> Vec4 {
Vec4::new(
(color.x + factor).min(1.0),
(color.y + factor).min(1.0),
(color.z + factor).min(1.0),
color.w,
)
}
pub fn darken_color(color: Vec4, factor: f32) -> Vec4 {
Vec4::new(
(color.x - factor).max(0.0),
(color.y - factor).max(0.0),
(color.z - factor).max(0.0),
color.w,
)
}
#[cfg(any(feature = "gui", feature = "egui-overlay"))]
pub fn apply_to_egui(&self, ctx: &egui::Context) {
let mut visuals = egui::Visuals::dark();
visuals.window_fill = egui::Color32::from_rgba_unmultiplied(
(self.background_secondary.x * 255.0) as u8,
(self.background_secondary.y * 255.0) as u8,
(self.background_secondary.z * 255.0) as u8,
(self.background_secondary.w * 255.0) as u8,
);
visuals.panel_fill = egui::Color32::from_rgba_unmultiplied(
(self.background_tertiary.x * 255.0) as u8,
(self.background_tertiary.y * 255.0) as u8,
(self.background_tertiary.z * 255.0) as u8,
(self.background_tertiary.w * 255.0) as u8,
);
visuals.widgets.noninteractive.fg_stroke.color = egui::Color32::from_rgba_unmultiplied(
(self.text_primary.x * 255.0) as u8,
(self.text_primary.y * 255.0) as u8,
(self.text_primary.z * 255.0) as u8,
(self.text_primary.w * 255.0) as u8,
);
visuals.selection.bg_fill = egui::Color32::from_rgba_unmultiplied(
(self.accent_primary.x * 255.0) as u8,
(self.accent_primary.y * 255.0) as u8,
(self.accent_primary.z * 255.0) as u8,
64, );
ctx.set_visuals(visuals);
}
}
#[derive(Debug, Clone)]
pub struct Typography {
pub title_font_size: f32,
pub subtitle_font_size: f32,
pub axis_label_font_size: f32,
pub tick_label_font_size: f32,
pub legend_font_size: f32,
pub title_font_family: String,
pub body_font_family: String,
pub monospace_font_family: String,
}
impl Default for Typography {
fn default() -> Self {
Self {
title_font_size: 18.0,
subtitle_font_size: 14.0,
axis_label_font_size: 12.0,
tick_label_font_size: 10.0,
legend_font_size: 11.0,
title_font_family: "SF Pro Display".to_string(), body_font_family: "SF Pro Text".to_string(), monospace_font_family: "SF Mono".to_string(), }
}
}
#[derive(Debug, Clone)]
pub struct Layout {
pub plot_padding: f32,
pub title_margin: f32,
pub axis_margin: f32,
pub legend_margin: f32,
pub grid_line_width: f32,
pub axis_line_width: f32,
pub data_line_width: f32,
pub point_size: f32,
}
impl Default for Layout {
fn default() -> Self {
Self {
plot_padding: 20.0,
title_margin: 15.0,
axis_margin: 10.0,
legend_margin: 8.0,
grid_line_width: 0.5,
axis_line_width: 1.0,
data_line_width: 2.0,
point_size: 4.0,
}
}
}