1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#[macro_export]
macro_rules! impl_pos {
    ($t:ty) => {
        impl $t {
            pub const fn with_pos(mut self, pos: crate::position::Rect) -> Self {
                self.pos = pos;
                self
            }

            pub const fn at(mut self, pos: ::algebr::Vec2) -> Self {
                self.pos = self.pos.at(pos);
                self
            }

            pub const fn with_anchor(mut self, anchor: ::algebr::Vec2) -> Self {
                self.pos = self.pos.with_anchor(anchor);
                self
            }

            pub const fn with_size(mut self, size: ::algebr::Vec2) -> Self {
                self.pos = self.pos.with_size(size);
                self
            }
        }
    };
}

#[macro_export]
macro_rules! impl_style {
    ($t:ty) => {
        impl $t {
            pub const fn with_style(mut self, style: crate::style::Style) -> Self {
                self.style = Some(style);
                self
            }

            pub fn with_stroke(mut self, stroke: crate::style::Stroke) -> Self {
                self.style = {
                    let mut style = self.style.unwrap_or_default();
                    style.stroke = Some(stroke);
                    Some(style)
                };
                self
            }

            pub fn with_fill(mut self, fill: crate::style::Fill) -> Self {
                self.style = {
                    let mut style = self.style.unwrap_or_default();
                    style.fill = Some(fill);
                    Some(style)
                };
                self
            }
        }
    };
}