Fix Atarigo + Gomoku, prepare Emergo
[vchess.git] / client / public / images / pieces / Emergo / generateSVG_simple.py
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
11 black = '<circle cx="115" cy="115" r="100" fill="black" stroke="orange"/>'
12 white = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="orange"/>'
13
14 digits = [
15 # 1
16 '<path d="M125,95 v40" stroke="red" fill="none" stroke-width="2"/>',
17 # 2
18 '<path d="M105,95 h20 v20 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>',
19 # 3
20 '<path d="M105,95 h20 v20 h-20 M125,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>',
21 # 4
22 '<path d="M105,95 v20 h20 v20 M125,95 v20" stroke="red" fill="none" stroke-width="2"/>',
23 # 5
24 '<path d="M125,95 h-20 v20 h20 v20 h-20" stroke="red" fill="none" stroke-width="2"/>',
25 # 6
26 '<path d="M125,95 h-20 v40 h20 v-20 h-20" stroke="red" fill="none" stroke-width="2"/>',
27 # 7
28 '<path d="M105,95 h20 v40" stroke="red" fill="none" stroke-width="2"/>',
29 # 8
30 '<path d="M105,95 h20 v40 h-20 z M105,115 h20" stroke="red" fill="none" stroke-width="2"/>',
31 # 9
32 '<path d="M105,135 h20 v-40 h-20 v20 h20" stroke="red" fill="none" stroke-width="2"/>',
33 # 10
34 '<path d="M100,95 v40 M110,95 h20 v40 h-20 v-40" stroke="red" fill="none" stroke-width="2"/>',
35 # 11
36 '<path d="M100,95 v40 M130,95 v40" stroke="red" fill="none" stroke-width="2"/>',
37 # 12
38 '<path d="M100,95 v40 M110,95 h20 v20 h-20 M130,115 v20 h-20" stroke="red" fill="none" stroke-width="2"/>'
39 ]
40
41 final = "</svg>"
42
43 for color in ["white", "black"]:
44 chrShift = 0 if color == "white" else 32
45 for number in range(12):
46 filename = chr(65 + number + chrShift) + "_.svg"
47 f = open(filename, "w")
48 f.write(preamble)
49 f.write("\n");
50 f.write(white if color == "white" else black)
51 f.write("\n");
52 f.write(digits[number])
53 f.write("\n");
54 f.write(final)
55 f.close()