Attempt to clarify installation instructions a little
[vchess.git] / client / public / images / pieces / Emergo / generateSVG_composite.py
CommitLineData
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
7preamble = """<?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"/>
d77258a0 13 <rect x="0" y="115" width="230" height="115"/>
e0798172
BA
14 </mask>
15</defs>"""
16
d77258a0
BA
17black_top = '<circle cx="115" cy="115" r="100" fill="black" mask="url(#stripe)"/>'
18white_bottom = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown"/>'
19white_top = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown" mask="url(#stripe)"/>'
20black_bottom = '<circle cx="115" cy="115" r="100" fill="black"/>'
e0798172
BA
21
22digits = {
d77258a0 23 "top": [
0760d861 24 # 1 (unused here)
d77258a0 25 '<path d="M130,35 v60"',
e0798172 26 # 2
d77258a0 27 '<path d="M100,35 h30 v30 h-30 v30 h30"',
e0798172 28 # 3
d77258a0 29 '<path d="M100,35 h30 v30 h-30 M130,65 v30 h-30"',
e0798172 30 # 4
d77258a0 31 '<path d="M100,35 v30 h30 v30 M130,35 v30"',
e0798172 32 # 5
d77258a0 33 '<path d="M130,35 h-30 v30 h30 v30 h-30"',
e0798172 34 # 6
d77258a0 35 '<path d="M130,35 h-30 v60 h30 v-30 h-30"',
e0798172 36 # 7
d77258a0 37 '<path d="M100,35 h30 v60"',
e0798172 38 # 8
d77258a0 39 '<path d="M100,35 h30 v60 h-30 z M100,65 h30"',
e0798172 40 # 9
d77258a0 41 '<path d="M100,95 h30 v-60 h-30 v30 h30"',
e0798172 42 # 10
d77258a0 43 '<path d="M90,35 v60 M100,35 h30 v60 h-30 v-60"',
e0798172 44 # 11
d77258a0 45 '<path d="M90,35 v60 M130,35 v60"',
e0798172 46 # 12
d77258a0 47 '<path d="M90,35 v60 M100,35 h30 v30 h-30 v30 h30"'
e0798172 48 ],
d77258a0 49 "bottom": [
0760d861 50 # 1 (unused here)
d77258a0 51 '<path d="M130,135 v60"',
e0798172 52 # 2
d77258a0 53 '<path d="M100,135 h30 v30 h-30 v30 h30"',
e0798172 54 # 3
d77258a0 55 '<path d="M100,135 h30 v30 h-30 M130,165 v30 h-30"',
e0798172 56 # 4
d77258a0 57 '<path d="M100,135 v30 h30 v30 M130,135 v30"',
e0798172 58 # 5
d77258a0 59 '<path d="M130,135 h-30 v30 h30 v30 h-30"',
e0798172 60 # 6
d77258a0 61 '<path d="M130,135 h-30 v60 h30 v-30 h-30"',
e0798172 62 # 7
d77258a0 63 '<path d="M100,135 h30 v60"',
e0798172 64 # 8
d77258a0 65 '<path d="M100,135 h30 v60 h-30 z M100,165 h30"',
e0798172 66 # 9
d77258a0 67 '<path d="M100,195 h30 v-60 h-30 v30 h30"',
e0798172 68 # 10
d77258a0 69 '<path d="M90,135 v60 M100,135 h30 v60 h-30 v-60"',
e0798172 70 # 11
d77258a0 71 '<path d="M90,135 v60 M130,135 v60"',
e0798172 72 # 12
d77258a0 73 '<path d="M90,135 v60 M100,135 h30 v30 h-30 v30 h30"'
e0798172
BA
74 ]
75}
76
77final = "</svg>"
78
d77258a0
BA
79for colorTop in ["white", "black"]:
80 chrShift = 0 if colorTop == "white" else 32
81 for top in range(12):
82 for bottom in range(12):
83 filename = chr(65 + top + chrShift) + chr(65 + bottom + chrShift) + ".svg"
e0798172
BA
84 f = open(filename, "w")
85 f.write(preamble)
b27300c2 86 f.write("\n")
d77258a0 87 f.write(black_bottom if colorTop == "white" else white_bottom)
b27300c2 88 f.write("\n")
d77258a0 89 f.write(white_top if colorTop == "white" else black_top)
b27300c2 90 f.write("\n")
0760d861
BA
91 if top >= 1:
92 f.write(digits["top"][top] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "white" else 'stroke="orange"') + '/>')
93 f.write("\n")
94 if bottom >= 1:
95 f.write(digits["bottom"][bottom] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "black" else 'stroke="orange"') + '/>')
96 f.write("\n")
e0798172
BA
97 f.write(final)
98 f.close()