leptos_leaflet/components/
path_options.rs1use std::fmt::{Display, Formatter};
2
3#[derive(Debug, Copy, Clone)]
5pub enum LineJoin {
6 Arcs,
7 Bevel,
8 Miter,
9 MiterClip,
10 Round,
11}
12
13impl Default for LineJoin {
14 fn default() -> Self {
15 Self::Round
16 }
17}
18
19impl Display for LineJoin {
20 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
21 match self {
22 LineJoin::Arcs => write!(f, "arcs"),
23 LineJoin::Bevel => write!(f, "bevel"),
24 LineJoin::Miter => write!(f, "miter"),
25 LineJoin::MiterClip => write!(f, "miter-clip"),
26 LineJoin::Round => write!(f, "round"),
27 }
28 }
29}
30
31impl AsRef<str> for LineJoin {
32 fn as_ref(&self) -> &str {
33 match self {
34 LineJoin::Arcs => "arcs",
35 LineJoin::Bevel => "bevel",
36 LineJoin::Miter => "miter",
37 LineJoin::MiterClip => "miter-clip",
38 LineJoin::Round => "round",
39 }
40 }
41}
42
43#[derive(Debug, Copy, Clone)]
45pub enum LineCap {
46 Butt,
47 Round,
48 Square,
49}
50
51impl Default for LineCap {
52 fn default() -> Self {
53 Self::Round
54 }
55}
56
57impl Display for LineCap {
58 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
59 match self {
60 LineCap::Butt => write!(f, "butt"),
61 LineCap::Round => write!(f, "round"),
62 LineCap::Square => write!(f, "square"),
63 }
64 }
65}
66
67impl AsRef<str> for LineCap {
68 fn as_ref(&self) -> &str {
69 match self {
70 LineCap::Butt => "butt",
71 LineCap::Round => "round",
72 LineCap::Square => "square",
73 }
74 }
75}
76
77#[derive(Debug, Copy, Clone)]
79pub enum FillRule {
80 NonZero,
81 EvenOdd,
82}
83
84impl Default for FillRule {
85 fn default() -> Self {
86 Self::EvenOdd
87 }
88}
89
90impl Display for FillRule {
91 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
92 match self {
93 FillRule::NonZero => write!(f, "nonzero"),
94 FillRule::EvenOdd => write!(f, "evenodd"),
95 }
96 }
97}
98
99impl AsRef<str> for FillRule {
100 fn as_ref(&self) -> &str {
101 match self {
102 FillRule::NonZero => "nonzero",
103 FillRule::EvenOdd => "evenodd",
104 }
105 }
106}
107
108impl From<LineJoin> for String {
109 fn from(value: LineJoin) -> Self {
110 format!("{}", value)
111 }
112}
113
114impl From<LineCap> for String {
115 fn from(value: LineCap) -> Self {
116 format!("{}", value)
117 }
118}
119
120impl From<FillRule> for String {
121 fn from(value: FillRule) -> Self {
122 format!("{}", value)
123 }
124}