1use crate::palette::Srgb;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub struct Palette<T> {
11 pub black: T,
12 pub red: T,
13 pub green: T,
14 pub yellow: T,
15 pub blue: T,
16 pub purple: T,
17 pub cyan: T,
18 pub white: T,
19}
20
21impl<T> Palette<T> {
22 pub fn uniform(v: T) -> Self
24 where
25 T: Clone,
26 {
27 Self {
28 black: v.clone(),
29 red: v.clone(),
30 green: v.clone(),
31 yellow: v.clone(),
32 blue: v.clone(),
33 purple: v.clone(),
34 cyan: v.clone(),
35 white: v,
36 }
37 }
38
39 pub fn as_ref(&self) -> Palette<&T> {
41 Palette {
42 black: &self.black,
43 red: &self.red,
44 green: &self.green,
45 yellow: &self.yellow,
46 blue: &self.blue,
47 purple: &self.purple,
48 cyan: &self.cyan,
49 white: &self.white,
50 }
51 }
52
53 pub fn zip<U>(self, other: Palette<U>) -> Palette<(T, U)> {
55 Palette {
56 black: (self.black, other.black),
57 red: (self.red, other.red),
58 green: (self.green, other.green),
59 yellow: (self.yellow, other.yellow),
60 blue: (self.blue, other.blue),
61 purple: (self.purple, other.purple),
62 cyan: (self.cyan, other.cyan),
63 white: (self.white, other.white),
64 }
65 }
66
67 pub fn map<F, U>(self, mut f: F) -> Palette<U>
70 where
71 F: FnMut(T) -> U,
72 {
73 Palette {
74 black: f(self.black),
75 red: f(self.red),
76 green: f(self.green),
77 yellow: f(self.yellow),
78 blue: f(self.blue),
79 purple: f(self.purple),
80 cyan: f(self.cyan),
81 white: f(self.white),
82 }
83 }
84}
85
86#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
88pub struct Colors<Color = Srgb> {
89 pub palette: Palette<Color>,
90 pub accents: Vec<Color>,
91 pub foreground: Color,
92 pub background: Color,
93}
94
95#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
97pub struct Theme {
98 pub wallpaper: Option<PathBuf>,
99 pub colors: Colors,
100}