use macroquad::prelude::Color;
use macroquad::text::{load_ttf_font_from_bytes, Font};
pub const PAPER: Color = Color::new(0.957, 0.945, 0.902, 1.0);
pub const INK: Color = Color::new(0.098, 0.090, 0.078, 1.0);
pub const ACCENT: Color = Color::new(0.659, 0.224, 0.180, 1.0);
pub const BLUE: Color = Color::new(0.180, 0.290, 0.400, 1.0);
pub const FADED: Color = Color::new(0.541, 0.514, 0.459, 1.0);
pub const PAPER_SHADE: Color = Color::new(0.914, 0.898, 0.847, 1.0);
pub const MASTHEAD_LEFT: &str = "THE BROADSHEET";
pub const MASTHEAD_RIGHT: &str = "SPECIAL EDITION";
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Role {
Active,
Visited,
Skipped,
Found,
Stale,
Deleted,
Maybe,
Absent,
}
#[derive(Debug, Clone)]
pub struct Theme {
pub paper: Color,
pub ink: Color,
pub accent: Color,
pub blue: Color,
pub faded: Color,
pub paper_shade: Color,
pub masthead_left: String,
pub masthead_right: String,
pub roles: RoleColors,
}
#[derive(Debug, Clone, Copy)]
pub struct RoleColors {
pub active: Color,
pub visited: Color,
pub skipped: Color,
pub found: Color,
pub stale: Color,
pub deleted: Color,
pub maybe: Color,
pub absent: Color,
}
impl Theme {
pub fn broadsheet() -> Theme {
Theme {
paper: PAPER,
ink: INK,
accent: ACCENT,
blue: BLUE,
faded: FADED,
paper_shade: PAPER_SHADE,
masthead_left: MASTHEAD_LEFT.into(),
masthead_right: MASTHEAD_RIGHT.into(),
roles: RoleColors {
active: ACCENT,
visited: BLUE,
skipped: FADED,
found: Color::new(0.220, 0.420, 0.235, 1.0),
stale: Color::new(0.600, 0.460, 0.220, 1.0),
deleted: Color::new(0.420, 0.140, 0.110, 1.0),
maybe: Color::new(0.700, 0.520, 0.150, 1.0),
absent: PAPER_SHADE,
},
}
}
pub fn midnight() -> Theme {
Theme {
paper: Color::new(0.086, 0.094, 0.110, 1.0),
ink: Color::new(0.910, 0.902, 0.870, 1.0),
accent: Color::new(0.870, 0.380, 0.320, 1.0),
blue: Color::new(0.450, 0.620, 0.780, 1.0),
faded: Color::new(0.480, 0.500, 0.530, 1.0),
paper_shade: Color::new(0.140, 0.150, 0.170, 1.0),
masthead_left: "THE MIDNIGHT EDITION".into(),
masthead_right: "LATE PRESS".into(),
roles: RoleColors {
active: Color::new(0.870, 0.380, 0.320, 1.0),
visited: Color::new(0.450, 0.620, 0.780, 1.0),
skipped: Color::new(0.480, 0.500, 0.530, 1.0),
found: Color::new(0.420, 0.700, 0.450, 1.0),
stale: Color::new(0.720, 0.580, 0.320, 1.0),
deleted: Color::new(0.600, 0.250, 0.220, 1.0),
maybe: Color::new(0.830, 0.680, 0.300, 1.0),
absent: Color::new(0.140, 0.150, 0.170, 1.0),
},
}
}
pub fn plain() -> Theme {
Theme {
paper: Color::new(1.0, 1.0, 1.0, 1.0),
ink: Color::new(0.10, 0.10, 0.12, 1.0),
accent: Color::new(0.180, 0.400, 0.780, 1.0),
blue: Color::new(0.350, 0.350, 0.400, 1.0),
faded: Color::new(0.600, 0.600, 0.630, 1.0),
paper_shade: Color::new(0.945, 0.945, 0.955, 1.0),
masthead_left: "NOTES".into(),
masthead_right: "WORKING DRAFT".into(),
roles: RoleColors {
active: Color::new(0.180, 0.400, 0.780, 1.0),
visited: Color::new(0.400, 0.300, 0.650, 1.0),
skipped: Color::new(0.600, 0.600, 0.630, 1.0),
found: Color::new(0.150, 0.550, 0.300, 1.0),
stale: Color::new(0.700, 0.500, 0.150, 1.0),
deleted: Color::new(0.780, 0.220, 0.200, 1.0),
maybe: Color::new(0.850, 0.600, 0.100, 1.0),
absent: Color::new(0.945, 0.945, 0.955, 1.0),
},
}
}
pub fn role(&self, r: Role) -> Color {
match r {
Role::Active => self.roles.active,
Role::Visited => self.roles.visited,
Role::Skipped => self.roles.skipped,
Role::Found => self.roles.found,
Role::Stale => self.roles.stale,
Role::Deleted => self.roles.deleted,
Role::Maybe => self.roles.maybe,
Role::Absent => self.roles.absent,
}
}
}
impl Default for Theme {
fn default() -> Theme {
Theme::broadsheet()
}
}
pub struct Fonts {
pub serif: Option<Font>,
pub mono: Option<Font>,
pub mono_bold: Option<Font>,
}
impl Fonts {
pub fn load() -> Fonts {
Fonts {
serif: load_ttf_font_from_bytes(include_bytes!(
"../assets/fonts/PlayfairDisplay-Bold.ttf"
))
.ok(),
mono: load_ttf_font_from_bytes(include_bytes!(
"../assets/fonts/IBMPlexMono-Regular.ttf"
))
.ok(),
mono_bold: load_ttf_font_from_bytes(include_bytes!(
"../assets/fonts/IBMPlexMono-Bold.ttf"
))
.ok(),
}
}
}
pub fn with_opacity(c: Color, opacity: f32) -> Color {
Color::new(c.r, c.g, c.b, c.a * opacity)
}