charming_fork_zephyr/element/
line_style.rs

1use serde::Serialize;
2
3use super::color::Color;
4
5#[derive(Serialize)]
6#[serde(rename_all = "snake_case")]
7pub enum LineStyleType {
8    Solid,
9    Dashed,
10    Dotted,
11}
12
13#[derive(Serialize)]
14#[serde(rename_all = "camelCase")]
15pub struct LineStyle {
16    #[serde(skip_serializing_if = "Option::is_none")]
17    color: Option<Color>,
18
19    #[serde(skip_serializing_if = "Option::is_none")]
20    width: Option<i64>,
21
22    #[serde(skip_serializing_if = "Option::is_none")]
23    #[serde(rename = "type")]
24    type_: Option<LineStyleType>,
25
26    #[serde(skip_serializing_if = "Option::is_none")]
27    opacity: Option<i64>,
28
29    #[serde(skip_serializing_if = "Option::is_none")]
30    curveness: Option<i64>,
31}
32
33impl LineStyle {
34    pub fn new() -> Self {
35        Self {
36            color: None,
37            width: None,
38            type_: None,
39            opacity: None,
40            curveness: None,
41        }
42    }
43
44    pub fn color<C: Into<Color>>(mut self, color: C) -> Self {
45        self.color = Some(color.into());
46        self
47    }
48
49    pub fn width<F: Into<i64>>(mut self, width: F) -> Self {
50        self.width = Some(width.into());
51        self
52    }
53
54    pub fn type_<L: Into<LineStyleType>>(mut self, type_: L) -> Self {
55        self.type_ = Some(type_.into());
56        self
57    }
58
59    pub fn opacity<F: Into<i64>>(mut self, opacity: F) -> Self {
60        self.opacity = Some(opacity.into());
61        self
62    }
63
64    pub fn curveness<F: Into<i64>>(mut self, curveness: F) -> Self {
65        self.curveness = Some(curveness.into());
66        self
67    }
68}