1use kurbo::Stroke;
5
6#[derive(Copy, Clone, PartialEq, Eq, Debug)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[repr(u8)]
10pub enum Fill {
11 NonZero = 0,
13 EvenOdd = 1,
15 }
17
18#[derive(Clone, Debug)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23pub enum Style {
24 Fill(Fill),
26 Stroke(Stroke),
28}
29
30impl From<Fill> for Style {
31 fn from(fill: Fill) -> Self {
32 Self::Fill(fill)
33 }
34}
35
36impl From<Stroke> for Style {
37 fn from(stroke: Stroke) -> Self {
38 Self::Stroke(stroke)
39 }
40}
41
42#[expect(
48 variant_size_differences,
49 reason = "We don't expect this enum to be operated on in bulk."
50)]
51#[derive(Debug, Copy, Clone)]
52pub enum StyleRef<'a> {
53 Fill(Fill),
55 Stroke(&'a Stroke),
57}
58
59impl StyleRef<'_> {
60 #[must_use]
62 pub fn to_owned(&self) -> Style {
63 match self {
64 Self::Fill(fill) => Style::Fill(*fill),
65 Self::Stroke(stroke) => Style::Stroke((*stroke).clone()),
66 }
67 }
68}
69
70impl From<Fill> for StyleRef<'_> {
71 fn from(fill: Fill) -> Self {
72 Self::Fill(fill)
73 }
74}
75
76impl<'a> From<&'a Stroke> for StyleRef<'a> {
77 fn from(stroke: &'a Stroke) -> Self {
78 Self::Stroke(stroke)
79 }
80}
81
82impl<'a> From<&'a Style> for StyleRef<'a> {
83 fn from(draw: &'a Style) -> Self {
84 match draw {
85 Style::Fill(fill) => Self::Fill(*fill),
86 Style::Stroke(stroke) => Self::Stroke(stroke),
87 }
88 }
89}