use crate::{Canvas, Ctx, Size};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Category {
DeepCosmos,
SunPlanets,
EarthSky,
Voyages,
Physics,
Chemistry,
Biology,
PhysicalChemistry,
Biophysics,
Biochemistry,
LivingMatter,
}
impl Category {
pub const ALL: [Category; 11] = [
Category::DeepCosmos,
Category::SunPlanets,
Category::EarthSky,
Category::Voyages,
Category::Physics,
Category::Chemistry,
Category::Biology,
Category::PhysicalChemistry,
Category::Biophysics,
Category::Biochemistry,
Category::LivingMatter,
];
pub const fn id(self) -> &'static str {
match self {
Category::DeepCosmos => "deep-cosmos",
Category::SunPlanets => "sun-planets",
Category::EarthSky => "earth-sky",
Category::Voyages => "voyages",
Category::Physics => "forces-waves",
Category::Chemistry => "reactions",
Category::Biology => "living-systems",
Category::PhysicalChemistry => "states-of-matter",
Category::Biophysics => "physics-of-life",
Category::Biochemistry => "molecules-of-life",
Category::LivingMatter => "life-from-matter",
}
}
pub const fn label(self) -> &'static str {
match self {
Category::DeepCosmos => "Deep Cosmos",
Category::SunPlanets => "Sun & Planets",
Category::EarthSky => "Earth & Sky",
Category::Voyages => "Voyages",
Category::Physics => "Forces & Waves",
Category::Chemistry => "Reactions",
Category::Biology => "Living Systems",
Category::PhysicalChemistry => "States of Matter",
Category::Biophysics => "Physics of Life",
Category::Biochemistry => "Molecules of Life",
Category::LivingMatter => "Life from Matter",
}
}
}
#[derive(Debug)]
pub struct Meta {
pub name: &'static str,
pub category: Category,
pub description: &'static str,
pub title: &'static str,
pub captions: &'static [&'static str],
}
pub trait Generator: Send {
fn meta(&self) -> &'static Meta;
fn resize(&mut self, size: Size, ctx: &mut Ctx);
fn update(&mut self, dt: f64, ctx: &mut Ctx);
fn prepare(&mut self) {}
fn render(&self, canvas: &mut Canvas);
fn caption(&self) -> Option<&'static str> {
None
}
}