astrology/svg_draw/
houses.rs

1extern crate strum;
2use crate::svg_draw::svg_draw::{
3    WorkingStorageDrawPolyMorphNatal, WorkingStorageDrawPolyMorphTransit,
4};
5use libswe_sys::sweconst::Theme;
6use svg::node::element::path::{Data, Number};
7use svg::node::element::{Group, Path};
8use svg::Document;
9
10pub const HOUSE_SIZE: Number = 50.0;
11
12impl WorkingStorageDrawPolyMorphNatal {
13    pub fn houses_draw(&self, house: i16) -> Document {
14        draw_house(house, self.ws.theme)
15    }
16}
17
18impl WorkingStorageDrawPolyMorphTransit {
19    pub fn houses_draw(&self, house: i16) -> Document {
20        draw_house(house, self.ws.theme)
21    }
22}
23
24fn draw_house(house: i16, _theme: Theme) -> Document {
25    let size: (Number, Number) = (HOUSE_SIZE, HOUSE_SIZE);
26    let document: Document;
27    match house {
28        1 => {
29            let data = Data::new()
30                .move_to((22.9, 14.3)) // M
31                .line_to((22.9, 14.3)) // L
32                .line_by((-4.4, 2.4)) // l
33                .line_to((17.8, 14.0)) // L
34                .line_by((5.5, -2.9)) // l
35                .horizontal_line_by(2.9) // h
36                .vertical_line_by(25.1) // v
37                .horizontal_line_by(-3.3) // h
38                .vertical_line_to(14.3) // V
39                .close(); // z
40            let path = Path::new()
41                .set("fill", "black")
42                .set("stroke", "black")
43                .set("stroke-width", 0)
44                .set("d", data);
45            document = Document::new()
46                .set("viewBox", (0, 0, size.0, size.1))
47                .add(path);
48        },
49        2 => {
50            let data = Data::new()
51                .move_to((15.5, 36.2)) // M
52                .vertical_line_by(-2.1) // v
53                .line_by((2.7, -2.6)) // l
54                .cubic_curve_by((6.4, -6.1, 9.3, -9.3, 9.3, -13.1)) // c
55                .cubic_curve_by((0.0, -2.5, -1.2, -4.9, -5.0, -4.9)) // c
56                .cubic_curve_by((-2.3, 0.0, -4.2, 1.2, -5.3, 2.1)) // c
57                .line_by((-1.1, -2.4)) // l
58                .cubic_curve_by((1.7, -1.5, 4.2, -2.6, 7.1, -2.6)) // c
59                .cubic_curve_by((5.4, 0.0, 7.7, 3.7, 7.7, 7.3)) // c
60                .cubic_curve_by((0.0, 4.6, -3.4, 8.4, -8.7, 13.5)) // c
61                .line_by((-2.0, 1.9)) // l
62                .vertical_line_by(0.1) // v
63                .horizontal_line_by(11.3) // h
64                .vertical_line_by(2.8) // v
65                .horizontal_line_to(15.5) // H
66                .close(); // z
67            let path = Path::new()
68                .set("fill", "black")
69                .set("stroke", "black")
70                .set("stroke-width", 0)
71                .set("d", data);
72            document = Document::new()
73                .set("viewBox", (0, 0, size.0, size.1))
74                .add(path);
75        },
76        3 => {
77            let data = Data::new()
78                .move_to((16.3, 32.3)) // M
79                .cubic_curve_by((1.0, 0.6, 3.2, 1.6, 5.6, 1.6)) // c
80                .cubic_curve_by((4.4, 0.0, 5.7, -2.8, 5.7, -4.9)) // c
81                .cubic_curve_by((0.0, -3.5, -3.2, -5.0, -6.5, -5.0)) // c
82                .horizontal_line_by(-1.9) // h
83                .vertical_line_by(-2.5) // v
84                .horizontal_line_by(1.9) // h
85                .cubic_curve_by((2.5, 0.0, 5.6, -1.3, 5.6, -4.2)) // c
86                .cubic_curve_by((0.0, -2.0, -1.3, -3.8, -4.4, -3.8)) // c
87                .cubic_curve_by((-2.0, 0.0, -3.9, 0.9, -5.0, 1.7)) // c
88                .line_by((-0.9, -2.5)) // l
89                .cubic_curve_by((1.3, -1.0, 3.9, -1.9, 6.6, -1.9)) // c
90                .cubic_curve_by((4.9, 0.0, 7.2, 2.9, 7.2, 6.0)) // c
91                .cubic_curve_by((0.0, 2.6, -1.5, 4.8, -4.6, 5.9)) // c
92                .vertical_line_by(0.1) // v
93                .cubic_curve_by((3.1, 0.6, 5.6, 2.9, 5.6, 6.5)) // c
94                .cubic_curve_by((0.0, 4.0, -3.1, 7.5, -9.2, 7.5)) // c
95                .cubic_curve_by((-2.8, 0.0, -5.3, -0.9, -6.5, -1.7)) // c
96                .line_to((16.3, 32.3)) // L
97                .close(); // z
98            let path = Path::new()
99                .set("fill", "black")
100                .set("stroke", "black")
101                .set("stroke-width", 0)
102                .set("d", data);
103            document = Document::new()
104                .set("viewBox", (0, 0, size.0, size.1))
105                .add(path);
106        },
107        4 => {
108            let data = Data::new()
109                .move_to((26.0, 36.2)) // M
110                .vertical_line_by(-6.8) // v
111                .horizontal_line_to(14.4) // H
112                .vertical_line_by(-2.2) // v
113                .line_by((11.2, -16.0)) // l
114                .horizontal_line_by(3.7) // h
115                .vertical_line_by(15.6) // v
116                .horizontal_line_by(3.5) // h
117                .vertical_line_by(2.7) // v
118                .horizontal_line_by(-3.5) // h
119                .vertical_line_by(6.8) // v
120                .horizontal_line_to(26.0) // H
121                .close() // z
122                .move_to((26.0, 26.7)) // M
123                .vertical_line_by(-8.4) // v
124                .cubic_curve_by((0.0, -1.3, 0.0, -2.6, 0.1, -3.9)) // c
125                .horizontal_line_to(26.0) // H
126                .cubic_curve_by((-0.8, 1.5, -1.4, 2.6, -2.1, 3.7)) // c
127                .line_by((-6.1, 8.5)) // l
128                .vertical_line_by(0.1) // v
129                .horizontal_line_to(26.0) // H
130                .close(); // z
131            let path = Path::new()
132                .set("fill", "black")
133                .set("stroke", "black")
134                .set("stroke-width", 0)
135                .set("d", data);
136            document = Document::new()
137                .set("viewBox", (0, 0, size.0, size.1))
138                .add(path);
139        },
140        5 => {
141            let data = Data::new()
142                .move_to((30.5, 13.9)) // M
143                .horizontal_line_by(-9.6) // h
144                .line_by((-1.0, 6.5)) // l
145                .cubic_curve_by((0.6, -0.1, 1.1, -0.2, 2.0, -0.2)) // c
146                .cubic_curve_by((1.9, 0.0, 3.9, 0.4, 5.4, 1.4)) // c
147                .cubic_curve_by((2.0, 1.1, 3.6, 3.3, 3.6, 6.5)) // c
148                .cubic_curve_by((0.0, 4.9, -3.9, 8.6, -9.3, 8.6)) // c
149                .cubic_curve_by((-2.7, 0.0, -5.1, -0.8, -6.3, -1.5)) // c
150                .line_by((0.9, -2.6)) // l
151                .cubic_curve_by((1.0, 0.6, 3.1, 1.4, 5.4, 1.4)) // c
152                .cubic_curve_by((3.2, 0.0, 6.0, -2.1, 6.0, -5.4)) // c
153                .cubic_curve_by((0.0, -3.2, -2.2, -5.6, -7.2, -5.6)) // c
154                .cubic_curve_by((-1.4, 0.0, -2.5, 0.2, -3.5, 0.3)) // c
155                .line_by((1.6, -12.1)) // l
156                .horizontal_line_by(12.0) // h
157                .vertical_line_to(13.9) // V
158                .close(); // z
159            let path = Path::new()
160                .set("fill", "black")
161                .set("stroke", "black")
162                .set("stroke-width", 0)
163                .set("d", data);
164            document = Document::new()
165                .set("viewBox", (0, 0, size.0, size.1))
166                .add(path);
167        },
168        6 => {
169            let data = Data::new()
170                .move_to((29.8, 13.5)) // M
171                .cubic_curve_by((-0.7, 0.0, -1.6, 0.0, -2.5, 0.2)) // c
172                .cubic_curve_by((-5.3, 0.9, -8.2, 4.8, -8.7, 8.9)) // c
173                .horizontal_line_by(0.1) // h
174                .cubic_curve_by((1.2, -1.6, 3.3, -2.9, 6.1, -2.9)) // c
175                .cubic_curve_by((4.4, 0.0, 7.6, 3.2, 7.6, 8.1)) // c
176                .cubic_curve_by((0.0, 4.6, -3.1, 8.8, -8.3, 8.8)) // c
177                .cubic_curve_by((-5.4, 0.0, -8.9, -4.2, -8.9, -10.7)) // c
178                .cubic_curve_by((0.0, -4.9, 1.8, -8.8, 4.2, -11.3)) // c
179                .cubic_curve_by((2.1, -2.0, 4.9, -3.3, 8.0, -3.7)) // c
180                .cubic_curve_by((1.0, -0.2, 1.9, -0.2, 2.5, -0.2)) // c
181                .vertical_line_to(13.5) // V
182                .close() // z
183                .move_to((28.9, 28.0)) // M
184                .cubic_curve_by((0.0, -3.6, -2.0, -5.8, -5.2, -5.8)) // c
185                .cubic_curve_by((-2.0, 0.0, -3.9, 1.3, -4.9, 3.1)) // c
186                .cubic_curve_by((-0.2, 0.4, -0.4, 0.9, -0.4, 1.5)) // c
187                .cubic_curve_by((0.1, 4.1, 2.0, 7.2, 5.5, 7.2)) // c
188                .cubic_curve_to((26.9, 34.0, 28.9, 31.6, 28.9, 28.0)) // C
189                .close(); // z
190            let path = Path::new()
191                .set("fill", "black")
192                .set("stroke", "black")
193                .set("stroke-width", 0)
194                .set("d", data);
195            document = Document::new()
196                .set("viewBox", (0, 0, size.0, size.1))
197                .add(path);
198        },
199        7 => {
200            let data = Data::new()
201                .move_to((31.8, 11.1)) // M
202                .vertical_line_by(2.2) // v
203                .line_to((20.9, 36.2)) // L
204                .horizontal_line_by(-3.5) // h
205                .line_to((28.3, 14.0)) // L
206                .vertical_line_by(-0.1) // v
207                .horizontal_line_to(16.0) // H
208                .vertical_line_by(-2.8) // v
209                .horizontal_line_to(31.8) // H
210                .close(); // z
211            let path = Path::new()
212                .set("fill", "black")
213                .set("stroke", "black")
214                .set("stroke-width", 0)
215                .set("d", data);
216            document = Document::new()
217                .set("viewBox", (0, 0, size.0, size.1))
218                .add(path);
219        },
220        8 => {
221            let data = Data::new()
222                .move_to((15.2, 29.8)) // M
223                .cubic_curve_by((0.0, -3.2, 1.9, -5.4, 5.0, -6.7)) // c
224                .line_by((0.0, -0.1)) // l
225                .cubic_curve_by((-2.8, -1.3, -4.0, -3.5, -4.0, -5.6)) // c
226                .cubic_curve_by((0.0, -4.0, 3.4, -6.7, 7.8, -6.7)) // c
227                .cubic_curve_by((4.9, 0.0, 7.3, 3.1, 7.3, 6.2)) // c
228                .cubic_curve_by((0.0, 2.1, -1.0, 4.4, -4.1, 5.9)) // c
229                .vertical_line_by(0.1) // c
230                .cubic_curve_by((3.1, 1.2, 5.1, 3.4, 5.1, 6.5)) // c
231                .cubic_curve_by((0.0, 4.4, -3.7, 7.3, -8.5, 7.3)) // c
232                .cubic_curve_to((18.4, 36.6, 15.2, 33.5, 15.2, 29.8)) // C
233                .close() // z
234                .move_to((28.7, 29.7)) // M
235                .cubic_curve_by((0.0, -3.1, -2.1, -4.5, -5.5, -5.5)) // c
236                .cubic_curve_by((-2.9, 0.8, -4.5, 2.8, -4.5, 5.2)) // c
237                .cubic_curve_by((-0.1, 2.6, 1.8, 4.8, 5.0, 4.8)) // c
238                .cubic_curve_to((26.8, 34.1, 28.7, 32.3, 28.7, 29.7)) // C
239                .close() // z
240                .move_to((19.4, 17.1)) // M
241                .cubic_curve_by((0.0, 2.5, 1.9, 3.9, 4.8, 4.6)) // c
242                .cubic_curve_by((2.2, -0.7, 3.8, -2.3, 3.8, -4.6)) // c
243                .cubic_curve_by((0.0, -2.0, -1.2, -4.1, -4.2, -4.1)) // c
244                .cubic_curve_to((20.9, 13.1, 19.4, 14.9, 19.4, 17.1)) // C
245                .close(); // z
246            let path = Path::new()
247                .set("fill", "black")
248                .set("stroke", "black")
249                .set("stroke-width", 0)
250                .set("d", data);
251            document = Document::new()
252                .set("viewBox", (0, 0, size.0, size.1))
253                .add(path);
254        },
255        9 => {
256            let data = Data::new()
257                .move_to((17.5, 33.8)) // M
258                .cubic_curve_by((0.7, 0.1, 1.6, 0.0, 2.7, -0.1)) // c
259                .cubic_curve_by((2.0, -0.3, 3.8, -1.1, 5.3, -2.4)) // c
260                .cubic_curve_by((1.7, -1.5, 2.9, -3.7, 3.3, -6.7)) // c
261                .horizontal_line_by(-0.1) // h
262                .cubic_curve_by((-1.4, 1.7, -3.4, 2.7, -5.9, 2.7)) // c
263                .cubic_curve_by((-4.5, 0.0, -7.4, -3.4, -7.4, -7.7)) // c
264                .cubic_curve_by((0.0, -4.8, 3.4, -8.9, 8.6, -8.9)) // c
265                .smooth_cubic_curve_by((8.3, 4.2, 8.3, 10.6)) // s
266                .cubic_curve_by((0.0, 5.5, -1.9, 9.4, -4.3, 11.8)) // c
267                .cubic_curve_by((-1.9, 1.9, -4.6, 3.1, -7.3, 3.4)) // c
268                .cubic_curve_by((-1.2, 0.2, -2.3, 0.2, -3.1, 0.2)) // c
269                .vertical_line_to(33.8) // V
270                .close() // z
271                .move_to((18.7, 19.4)) // M
272                .cubic_curve_by((0.0, 3.1, 1.9, 5.3, 4.8, 5.3)) // c
273                .cubic_curve_by((2.3, 0.0, 4.1, -1.1, 4.9, -2.6)) // c
274                .cubic_curve_by((0.2, -0.3, 0.3, -0.7, 0.3, -1.2)) // c
275                .cubic_curve_by((0.0, -4.3, -1.6, -7.6, -5.1, -7.6)) // c
276                .cubic_curve_to((20.8, 13.2, 18.7, 15.8, 18.7, 19.4)) // C
277                .close(); // z
278            let path = Path::new()
279                .set("fill", "black")
280                .set("stroke", "black")
281                .set("stroke-width", 0)
282                .set("d", data);
283            document = Document::new()
284                .set("viewBox", (0, 0, size.0, size.1))
285                .add(path);
286        },
287        10 => {
288            let data1 = Data::new()
289                .move_to((13.0, 14.3)) // M
290                .line_to((13.0, 14.3)) // L
291                .line_by((-4.4, 2.4)) // l
292                .line_to((7.9, 14.0)) // L
293                .line_by((5.5, -2.9)) // l
294                .horizontal_line_by(2.9) // h
295                .vertical_line_by(25.1) // v
296                .horizontal_line_to(13.0) // H
297                .vertical_line_to(14.3) // V
298                .close(); // z
299            let data2 = Data::new()
300                .move_to((42.1, 23.4)) // M
301                .cubic_curve_by((0.0, 8.5, -3.2, 13.3, -8.7, 13.3)) // c
302                .cubic_curve_by((-4.9, 0.0, -8.2, -4.6, -8.3, -12.9)) // c
303                .cubic_curve_by((0.0, -8.4, 3.6, -13.1, 8.7, -13.1)) // c
304                .cubic_curve_to((39.1, 10.7, 42.1, 15.4, 42.1, 23.4)) // C
305                .close() // z
306                .move_to((28.5, 23.8)) // M
307                .cubic_curve_by((0.0, 6.5, 2.0, 10.2, 5.1, 10.2)) // c
308                .cubic_curve_by((3.5, 0.0, 5.1, -4.1, 5.1, -10.5)) // c
309                .cubic_curve_by((0.0, -6.2, -1.6, -10.2, -5.1, -10.2)) // c
310                .cubic_curve_to((30.6, 13.3, 28.5, 16.9, 28.5, 23.8)) // C
311                .close(); // z
312            let path1 = Path::new()
313                .set("fill", "black")
314                .set("stroke", "black")
315                .set("stroke-width", 0)
316                .set("d", data1);
317            let path2 = Path::new()
318                .set("fill", "black")
319                .set("stroke", "black")
320                .set("stroke-width", 0)
321                .set("d", data2);
322            let group = Group::new().add(path1).add(path2);
323            document = Document::new()
324                .set("viewBox", (0, 0, size.0, size.1))
325                .add(group);
326        },
327        11 => {
328            let data1 = Data::new()
329                .move_to((13.0, 14.3)) // M
330                .line_to((13.0, 14.3)) // L
331                .line_by((-4.4, 2.4)) // l
332                .line_to((7.9, 14.0)) // L
333                .line_by((5.5, -2.9)) // l
334                .horizontal_line_by(2.9) // h
335                .vertical_line_by(25.1) // v
336                .horizontal_line_to(13.0) // H
337                .vertical_line_to(14.3) // V
338                .close(); // z
339            let data2 = Data::new()
340                .move_to((32.8, 14.3)) // M
341                .line_to((32.8, 14.3)) // L
342                .line_by((-4.4, 2.4)) // l
343                .line_to((27.7, 14.0)) // L
344                .line_by((5.5, -2.9)) // l
345                .horizontal_line_by(2.9) // h
346                .vertical_line_by(25.1) // v
347                .horizontal_line_by(-3.3) // h
348                .vertical_line_to(14.3) // V
349                .close(); // z
350            let path1 = Path::new()
351                .set("fill", "black")
352                .set("stroke", "black")
353                .set("stroke-width", 0)
354                .set("d", data1);
355            let path2 = Path::new()
356                .set("fill", "black")
357                .set("stroke", "black")
358                .set("stroke-width", 0)
359                .set("d", data2);
360            let group = Group::new().add(path1).add(path2);
361            document = Document::new()
362                .set("viewBox", (0, 0, size.0, size.1))
363                .add(group);
364        },
365        12 => {
366            let data1 = Data::new()
367                .move_to((13.0, 14.3)) // M
368                .line_to((13.0, 14.3)) // L
369                .line_by((-4.4, 2.4)) // l
370                .line_to((7.9, 14.0)) // L
371                .line_by((5.5, -2.9)) // l
372                .horizontal_line_by(2.9) // h
373                .vertical_line_by(25.1) // v
374                .horizontal_line_to(13.0) // H
375                .vertical_line_to(14.3) // V
376                .close(); // z
377            let data2 = Data::new()
378                .move_to((25.4, 36.2)) // M
379                .vertical_line_by(-2.1) // v
380                .line_by((2.7, -2.6)) // l
381                .cubic_curve_by((6.4, -6.1, 9.3, -9.3, 9.3, -13.1)) // c
382                .cubic_curve_by((0.0, -2.5, -1.2, -4.9, -5.0, -4.9)) // c
383                .cubic_curve_by((-2.3, 0.0, -4.2, 1.2, -5.3, 2.1)) // c
384                .line_to((26.0, 13.2)) // L
385                .cubic_curve_by((1.7, -1.5, 4.2, -2.6, 7.1, -2.6)) // c
386                .cubic_curve_by((5.4, 0.0, 7.7, 3.7, 7.7, 7.3)) // c
387                .cubic_curve_by((0.0, 4.6, -3.4, 8.4, -8.7, 13.5)) // c
388                .line_by((-2.0, 1.9)) // l
389                .vertical_line_by(0.1) // v
390                .horizontal_line_by(11.3) // h
391                .vertical_line_by(2.8) // v
392                .horizontal_line_to(25.4) // H
393                .close(); // z
394            let path1 = Path::new()
395                .set("fill", "black")
396                .set("stroke", "black")
397                .set("stroke-width", 0)
398                .set("d", data1);
399            let path2 = Path::new()
400                .set("fill", "black")
401                .set("stroke", "black")
402                .set("stroke-width", 0)
403                .set("d", data2);
404            let group = Group::new().add(path1).add(path2);
405            document = Document::new()
406                .set("viewBox", (0, 0, size.0, size.1))
407                .add(group);
408        },
409        _ => document = Document::new(),
410    }
411    document
412}