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 | |
2afc4e19 | 25 | '<path d="M95,85 v60"', |
e0798172 | 26 | # 2 |
2afc4e19 | 27 | '<path d="M65,85 h30 v30 h-30 v30 h30"', |
e0798172 | 28 | # 3 |
2afc4e19 | 29 | '<path d="M65,85 h30 v30 h-30 M95,115 v30 h-30"', |
e0798172 | 30 | # 4 |
2afc4e19 | 31 | '<path d="M65,85 v30 h30 v30 M95,95 v30"', |
e0798172 | 32 | # 5 |
2afc4e19 | 33 | '<path d="M95,85 h-30 v30 h30 v30 h-30"', |
e0798172 | 34 | # 6 |
2afc4e19 | 35 | '<path d="M95,85 h-30 v60 h30 v-30 h-30"', |
e0798172 | 36 | # 7 |
2afc4e19 | 37 | '<path d="M65,85 h30 v60"', |
e0798172 | 38 | # 8 |
2afc4e19 | 39 | '<path d="M65,85 h30 v60 h-30 z M65,115 h30"', |
e0798172 | 40 | # 9 |
2afc4e19 | 41 | '<path d="M65,145 h30 v-60 h-30 v30 h30"', |
e0798172 | 42 | # 10 |
2afc4e19 | 43 | '<path d="M55,85 v60 M65,85 h30 v60 h-30 v-60"', |
e0798172 | 44 | # 11 |
2afc4e19 | 45 | '<path d="M55,85 v60 M95,85 v60"', |
e0798172 | 46 | # 12 |
2afc4e19 | 47 | '<path d="M55,85 v60 M65,85 h30 v30 h-30 v30 h30"' |
e0798172 BA |
48 | ], |
49 | "right": [ | |
50 | # 1 | |
2afc4e19 | 51 | '<path d="M185,85 v60"', |
e0798172 | 52 | # 2 |
2afc4e19 | 53 | '<path d="M155,85 h30 v30 h-30 v30 h30"', |
e0798172 | 54 | # 3 |
2afc4e19 | 55 | '<path d="M155,85 h30 v30 h-30 M185,115 v30 h-30"', |
e0798172 | 56 | # 4 |
2afc4e19 | 57 | '<path d="M155,85 v30 h30 v30 M185,85 v30"', |
e0798172 | 58 | # 5 |
2afc4e19 | 59 | '<path d="M185,85 h-30 v30 h30 v30 h-30"', |
e0798172 | 60 | # 6 |
2afc4e19 | 61 | '<path d="M185,85 h-30 v60 h30 v-30 h-30"', |
e0798172 | 62 | # 7 |
2afc4e19 | 63 | '<path d="M155,85 h30 v60"', |
e0798172 | 64 | # 8 |
2afc4e19 | 65 | '<path d="M155,85 h30 v60 h-30 z M155,115 h30"', |
e0798172 | 66 | # 9 |
2afc4e19 | 67 | '<path d="M155,145 h30 v-60 h-30 v30 h30"', |
e0798172 | 68 | # 10 |
2afc4e19 | 69 | '<path d="M145,85 v60 M155,85 h30 v60 h-30 v-60"', |
e0798172 | 70 | # 11 |
2afc4e19 | 71 | '<path d="M145,85 v60 M185,85 v60"', |
e0798172 | 72 | # 12 |
2afc4e19 | 73 | '<path d="M145,85 v60 M155,85 h30 v30 h-30 v30 h30"' |
e0798172 BA |
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) | |
b27300c2 | 86 | f.write("\n") |
e0798172 | 87 | f.write(black_right if colorLeft == "white" else white_right) |
b27300c2 | 88 | f.write("\n") |
e0798172 | 89 | f.write(white_left if colorLeft == "white" else black_left) |
b27300c2 | 90 | f.write("\n") |
2afc4e19 | 91 | f.write(digits["left"][left] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorLeft == "white" else 'stroke="orange"') + '/>') |
b27300c2 | 92 | f.write("\n") |
2afc4e19 | 93 | f.write(digits["right"][right] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorLeft == "black" else 'stroke="orange"') + '/>') |
b27300c2 | 94 | f.write("\n") |
e0798172 BA |
95 | f.write(final) |
96 | f.close() |