1use serde::{Serialize, Deserialize};
2
3use super::{Color, Material};
4
5#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase", rename_all_fields = "camelCase")]
8pub enum Style {
9 Color { color: Color },
10 Hierarchical { level: usize },
11 Material { material: Material },
12}
13
14impl Style {
15 pub const PRIMARY: Self = Self::hierarchical(0);
16 pub const SECONDARY: Self = Self::hierarchical(1);
17 pub const TERTIARY: Self = Self::hierarchical(2);
18 pub const QUATERNARY: Self = Self::hierarchical(3);
19 pub const QUINARY: Self = Self::hierarchical(4);
20
21 pub const fn color(color: Color) -> Self {
22 Self::Color { color }
23 }
24
25 pub const fn hierarchical(level: usize) -> Self {
26 Self::Hierarchical { level }
27 }
28
29 pub const fn material(material: Material) -> Self {
30 Self::Material { material }
31 }
32}
33
34impl From<Color> for Style {
35 fn from(color: Color) -> Self {
36 Self::Color { color }
37 }
38}
39
40impl From<Material> for Style {
41 fn from(material: Material) -> Self {
42 Self::Material { material }
43 }
44}