Commit | Line | Data |
---|---|---|
e0798172 BA |
1 | #!/usr/bin/env python |
2 | ||
3 | # Compose each piece SVG with numbers | |
4 | # https://travishorn.com/removing-parts-of-shapes-in-svg-b539a89e5649 | |
5 | # https://developer.mozilla.org/fr/docs/Web/SVG/Tutoriel/Paths | |
6 | ||
7 | preamble = """<?xml version="1.0" encoding="UTF-8" ?> | |
8 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> | |
9 | <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="230" height="230"> | |
10 | <defs> | |
11 | <mask id="stripe"> | |
12 | <rect x="0" y="0" width="230" height="230" fill="white"/> | |
13 | <rect x="130" y="0" width="90" height="230"/> | |
14 | </mask> | |
15 | </defs>""" | |
16 | ||
17 | black_left = '<circle cx="115" cy="115" r="100" fill="black" stroke="orange" mask="url(#stripe)"/>' | |
18 | white_right = '<circle cx="115" cy="115" r="100" fill="whitesmoke"/>' | |
19 | white_left = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="orange" mask="url(#stripe)"/>' | |
20 | black_right = '<circle cx="115" cy="115" r="100" fill="black"/>' | |
21 | ||
22 | digits = { | |
23 | "left": [ | |
24 | # 1 | |
25 | '<path d="M90,95 v40" stroke="red" fill="none" stroke-width="2"/>', | |
26 | # 2 | |
27 | '<path d="M70,95 h20 v20 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>', | |
28 | # 3 | |
29 | '<path d="M70,95 h20 v20 h-20 M90,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
30 | # 4 | |
31 | '<path d="M70,95 v20 h20 v20 M90,95 v20" stroke="red" fill="none" stroke-width="2"/>', | |
32 | # 5 | |
33 | '<path d="M90,95 h-20 v20 h20 v20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
34 | # 6 | |
35 | '<path d="M90,95 h-20 v40 h20 v-20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
36 | # 7 | |
37 | '<path d="M70,95 h20 v40" stroke="red" fill="none" stroke-width="2"/>', | |
38 | # 8 | |
39 | '<path d="M70,95 h20 v40 h-20 z M70,115 h20" stroke="red" fill="none" stroke-width="2"/>', | |
40 | # 9 | |
41 | '<path d="M70,135 h20 v-40 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>', | |
42 | # 10 | |
43 | '<path d="M60,95 v40 M70,95 h20 v40 h-20 v-40" stroke="red" fill="none" stroke-width="2"/>', | |
44 | # 11 | |
45 | '<path d="M60,95 v40 M90,95 v40" stroke="red" fill="none" stroke-width="2"/>', | |
46 | # 12 | |
47 | '<path d="M60,95 v40 M70,95 h20 v20 h-20 M90,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>' | |
48 | ], | |
49 | "right": [ | |
50 | # 1 | |
51 | '<path d="M180,95 v40" stroke="red" fill="none" stroke-width="2"/>', | |
52 | # 2 | |
53 | '<path d="M160,95 h20 v20 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>', | |
54 | # 3 | |
55 | '<path d="M160,95 h20 v20 h-20 M180,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
56 | # 4 | |
57 | '<path d="M160,95 v20 h20 v20 M180,95 v20" stroke="red" fill="none" stroke-width="2"/>', | |
58 | # 5 | |
59 | '<path d="M180,95 h-20 v20 h20 v20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
60 | # 6 | |
61 | '<path d="M180,95 h-20 v40 h20 v-20 h-20" stroke="red" fill="none" stroke-width="2"/>', | |
62 | # 7 | |
63 | '<path d="M160,95 h20 v40" stroke="red" fill="none" stroke-width="2"/>', | |
64 | # 8 | |
65 | '<path d="M160,95 h20 v40 h-20 z M160,115 h20" stroke="red" fill="none" stroke-width="2"/>', | |
66 | # 9 | |
67 | '<path d="M160,135 h20 v-40 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>', | |
68 | # 10 | |
69 | '<path d="M150,95 v40 M160,95 h20 v40 h-20 v-40" stroke="red" fill="none" stroke-width="2"/>', | |
70 | # 11 | |
71 | '<path d="M150,95 v40 M180,95 v40" stroke="red" fill="none" stroke-width="2"/>', | |
72 | # 12 | |
73 | '<path d="M150,95 v40 M160,95 h20 v20 h-20 M180,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>' | |
74 | ] | |
75 | } | |
76 | ||
77 | final = "</svg>" | |
78 | ||
79 | for colorLeft in ["white", "black"]: | |
80 | chrShift = 0 if colorLeft == "white" else 32 | |
81 | for left in range(12): | |
82 | for right in range(12): | |
83 | filename = chr(65 + left + chrShift) + chr(65 + right + chrShift) + ".svg" | |
84 | f = open(filename, "w") | |
85 | f.write(preamble) | |
86 | f.write("\n"); | |
87 | f.write(black_right if colorLeft == "white" else white_right) | |
88 | f.write("\n"); | |
89 | f.write(white_left if colorLeft == "white" else black_left) | |
90 | f.write("\n"); | |
91 | f.write(digits["left"][left]) | |
92 | f.write("\n"); | |
93 | f.write(digits["right"][right]) | |
94 | f.write("\n"); | |
95 | f.write(final) | |
96 | f.close() |