-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmighty-wallet.py
121 lines (110 loc) · 4.86 KB
/
mighty-wallet.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from ast import Store
import svg
class MightyWallet:
small_corner = 3
start_x = 97
start_y = 2
stroke = 0.1
def render(self) -> svg.SVG:
canvas = svg.SVG(
width="400mm",
height="600mm",
viewBox=svg.ViewBoxSpec(0, 0, 400, 600),
elements=[
# Main outer shape
svg.Path(
d=[
svg.M(self.start_x, self.start_y),
svg.l(205, 0),
self._draw_corner(self.small_corner, self.small_corner, False),
self._draw_corner(90, 80),
self._draw_corner(-90, 80),
self._draw_corner(-self.small_corner, self.small_corner, False),
self._draw_corner(self.small_corner, self.small_corner, False),
self._draw_corner(90, 80),
self._draw_corner(-90, 80),
self._draw_corner(-self.small_corner, self.small_corner, False),
svg.l(0, 80),
svg.l(0, 80),
# self._draw_corner(self.small_corner, self.small_corner, False),
# svg.l(40, 0),
# self._draw_corner(self.small_corner, self.small_corner),
svg.l(0, 80),
self._draw_corner(-self.small_corner, self.small_corner),
# svg.l(-40, 0),
# svg.l(-self.small_corner, 0),
# svg.l(-205, 0),
svg.l(-205 + 2 * self.small_corner, 0),
# svg.l(-self.small_corner, 0),
# svg.l(-40, 0),
self._draw_corner(-self.small_corner, -self.small_corner),
svg.l(0, -80),
# self._draw_corner(self.small_corner, -self.small_corner),
# svg.l(40, 0),
# self._draw_corner(self.small_corner, -self.small_corner, False),
svg.l(0, -80),
svg.l(0, -80),
self._draw_corner(-self.small_corner, -self.small_corner, False),
self._draw_corner(-90, -80),
self._draw_corner(90, -80),
self._draw_corner(self.small_corner, -self.small_corner, False),
self._draw_corner(-self.small_corner, -self.small_corner, False),
self._draw_corner(-90, -80),
self._draw_corner(90, -80),
self._draw_corner(self.small_corner, -self.small_corner, False),
],
fill="black",
stroke="black",
stroke_width=self.stroke,
),
# Window to calibrate front image
svg.Path(
d=[
svg.M(self.start_x + 102.5, self.start_y + self.small_corner + 80 + 80 - 10 - self.small_corner),
self._draw_corner(-self.small_corner, self.small_corner),
svg.l(-102 + self.small_corner, 0),
svg.l(0, -80 + 10),
svg.l(102 - self.small_corner, 0),
self._draw_corner(self.small_corner, self.small_corner),
self._draw_corner(self.small_corner, -self.small_corner),
svg.l(102 - self.small_corner, 0),
svg.l(0, 80 - 10),
svg.l(-102 + self.small_corner, 0),
self._draw_corner(-self.small_corner, -self.small_corner),
],
fill="white",
stroke="black",
stroke_width=self.stroke,
),
# Inside cards window
svg.Path(
d=[
svg.M(self.start_x + 102.5, self.start_y + self.small_corner * 2 + 80 + 80 + 10),
svg.c(24,0, 20.7,0.2, 28,30),
svg.s(12,30, -28,30),
svg.s(-35,0, -28,-30),
svg.s(4,-30, 28,-30),
],
fill="white",
stroke="black",
stroke_width=self.stroke,
),
],
)
return canvas
def _draw_corner(self, dx: int, dy: int, sweep=True) -> svg.ArcRel:
return svg.ArcRel(
rx=abs(dx),
ry=abs(dy),
angle=0,
large_arc=False,
sweep=sweep,
dx=dx,
dy=dy,
)
def main():
wallet = MightyWallet()
with open("mighty-wallet.svg", "w") as f:
f.write(f"{wallet.render()}")
if __name__ == "__main__":
main()