Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ fn parse_args() -> Args {
"frappe" => args.style = Some(Style::catppuccin_frappe()),
"macchiato" => args.style = Some(Style::catppuccin_macchiato()),
"mocha" => args.style = Some(Style::catppuccin_mocha()),
"dracula" => args.style = Some(Style::dracula()),
"alucard" => args.style = Some(Style::alucard()),
"catppuccin-latte" => args.style = Some(Style::catppuccin_latte()),
"catppuccin-frappe" => args.style = Some(Style::catppuccin_frappe()),
"catppuccin-macchiato" => args.style = Some(Style::catppuccin_macchiato()),
Expand Down
17 changes: 17 additions & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Style definitions for lines, fills, markers, and themes.
mod catppuccin;
pub(crate) mod defaults;
mod dracula;
pub mod series;
pub mod theme;

Expand Down Expand Up @@ -74,6 +75,22 @@ impl Style {
}
}

/// Create a Dracula theme and palette
pub const fn dracula() -> Self {
Style {
theme: Theme::Dracula,
palette: Palette::Dracula,
}
}

/// Create an Alucard theme and palette
pub const fn alucard() -> Self {
Style {
theme: Theme::Alucard,
palette: Palette::Alucard,
}
}

/// Create a Catppuccin Mocha theme and palette
pub const fn catppuccin_mocha() -> Self {
Style {
Expand Down
84 changes: 84 additions & 0 deletions src/style/dracula.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use plotive_base::Rgba8;

use crate::style;

/// Dracula theme
#[derive(Debug, Clone, Copy)]
pub struct Dracula;

/// Alucard theme
#[derive(Debug, Clone, Copy)]
pub struct Alucard;

pub trait Colors {
const BACKGROUND: Rgba8;
const _CURRENT_LINE: Rgba8;
const SELECTION: Rgba8;
const FOREGROUND: Rgba8;
const _COMMENT: Rgba8;
const CYAN: Rgba8;
const GREEN: Rgba8;
const ORANGE: Rgba8;
const PINK: Rgba8;
const PURPLE: Rgba8;
const RED: Rgba8;
const YELLOW: Rgba8;
}

pub const fn theme_palette<C>() -> style::theme::ThemePalette
where
C: Colors,
{
style::theme::ThemePalette {
background: C::BACKGROUND,
foreground: C::FOREGROUND,
grid: C::FOREGROUND,
legend_fill: C::SELECTION,
legend_border: C::FOREGROUND,
}
}

pub const fn series_colors<F>() -> &'static [Rgba8]
where
F: Colors,
{
&[
F::CYAN,
F::RED,
F::YELLOW,
F::PINK,
F::PURPLE,
F::GREEN,
F::ORANGE,
]
}

impl Colors for Dracula {
const BACKGROUND: Rgba8 = Rgba8::from_hex(b"#282a36");
const _CURRENT_LINE: Rgba8 = Rgba8::from_hex(b"#44475a");
const SELECTION: Rgba8 = Rgba8::from_hex(b"#44475a");
const FOREGROUND: Rgba8 = Rgba8::from_hex(b"#f8f8f2");
const _COMMENT: Rgba8 = Rgba8::from_hex(b"#6272a4");
const CYAN: Rgba8 = Rgba8::from_hex(b"#8be9fd");
const GREEN: Rgba8 = Rgba8::from_hex(b"#50fa7b");
const ORANGE: Rgba8 = Rgba8::from_hex(b"#ffb86c");
const PINK: Rgba8 = Rgba8::from_hex(b"#ff79c6");
const PURPLE: Rgba8 = Rgba8::from_hex(b"#bd93f9");
const RED: Rgba8 = Rgba8::from_hex(b"#ff5555");
const YELLOW: Rgba8 = Rgba8::from_hex(b"#f1fa8c");
}

impl Colors for Alucard {
const BACKGROUND: Rgba8 = Rgba8::from_hex(b"#fffbeb");
const _CURRENT_LINE: Rgba8 = Rgba8::from_hex(b"#6c664b");
const SELECTION: Rgba8 = Rgba8::from_hex(b"#cfcfde");
const FOREGROUND: Rgba8 = Rgba8::from_hex(b"#1f1f1f");
const _COMMENT: Rgba8 = Rgba8::from_hex(b"#6c664b");
const CYAN: Rgba8 = Rgba8::from_hex(b"#036a96");
const GREEN: Rgba8 = Rgba8::from_hex(b"#14710a");
const ORANGE: Rgba8 = Rgba8::from_hex(b"#a34d14");
const PINK: Rgba8 = Rgba8::from_hex(b"#a3144d");
const PURPLE: Rgba8 = Rgba8::from_hex(b"#644ac9");
const RED: Rgba8 = Rgba8::from_hex(b"#cb3a2a");
const YELLOW: Rgba8 = Rgba8::from_hex(b"#846e15");
}
8 changes: 7 additions & 1 deletion src/style/series.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* This module deals with colors and style of data series.
*/
use crate::style::{self, catppuccin, defaults};
use crate::style::{self, catppuccin, defaults, dracula};
use crate::{ResolveColor, Rgba8};

/// A palette for data series.
Expand All @@ -21,6 +21,10 @@ pub enum Palette {
TolBright,
/// Okabe & Ito colorblind-safe palette
OkabeIto,
/// Dracula palette
Dracula,
/// Alucard palette
Alucard,
/// Catppuccin Mocha palette
CatppuccinMocha,
/// Catppuccin Macchiato palette
Expand All @@ -42,6 +46,8 @@ impl Palette {
Palette::Pastel => palettes::PASTEL,
Palette::TolBright => palettes::TOL_BRIGHT,
Palette::OkabeIto => palettes::OKABE_ITO,
Palette::Dracula => dracula::series_colors::<dracula::Dracula>(),
Palette::Alucard => dracula::series_colors::<dracula::Alucard>(),
Palette::CatppuccinMocha => catppuccin::series_colors::<catppuccin::Mocha>(),
Palette::CatppuccinMacchiato => catppuccin::series_colors::<catppuccin::Macchiato>(),
Palette::CatppuccinFrappe => catppuccin::series_colors::<catppuccin::Frappe>(),
Expand Down
14 changes: 13 additions & 1 deletion src/style/theme.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Theme definitions and implementations

use crate::color::{self, Rgb8, Rgba8};
use crate::style::catppuccin;
use crate::style::{catppuccin, dracula};
use crate::{style, text};

/// A theme, for styling figures
Expand All @@ -12,6 +12,10 @@ pub enum Theme {
Light,
/// Dark theme
Dark,
/// Dracula theme
Dracula,
/// Alucard theme (Dracula light)
Alucard,
/// Catppuccin Mocha theme
CatppuccinMocha,
/// Catppuccin Macchiato theme
Expand Down Expand Up @@ -55,6 +59,8 @@ impl Theme {
match self {
Theme::Light => &ThemePalette::LIGHT,
Theme::Dark => &ThemePalette::DARK,
Theme::Dracula => &ThemePalette::DRACULA,
Theme::Alucard => &ThemePalette::ALUCARD,
Theme::CatppuccinLatte => &ThemePalette::CATPPUCCIN_LATTE,
Theme::CatppuccinFrappe => &ThemePalette::CATPPUCCIN_FRAPPE,
Theme::CatppuccinMacchiato => &ThemePalette::CATPPUCCIN_MACCHIATO,
Expand Down Expand Up @@ -104,6 +110,12 @@ impl ThemePalette {
legend_border: color::WHITE,
};

/// The Dracula built-in theme palette
pub const DRACULA: Self = dracula::theme_palette::<dracula::Dracula>();

/// The Alucard built-in theme palette
pub const ALUCARD: Self = dracula::theme_palette::<dracula::Alucard>();

/// The catppuccin mocha built-in theme palette
pub const CATPPUCCIN_MOCHA: Self = catppuccin::theme_palette::<catppuccin::Mocha>();

Expand Down
Loading