Improve Spartan, Avalam + Emergo pieces
[vchess.git] / client / public / images / pieces / Emergo / generateSVG_simple.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
d77258a0
BA
11black = '<circle cx="115" cy="115" r="100" fill="black"/>'
12white = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown"/>'
e0798172
BA
13
14digits = [
0760d861 15 # 1 (unused)
2afc4e19 16 '<path d="M130,85 v60"',
e0798172 17 # 2
2afc4e19 18 '<path d="M100,85 h30 v30 h-30 v30 h30"',
e0798172 19 # 3
2afc4e19 20 '<path d="M100,85 h30 v30 h-30 M130,115 v30 h-30"',
e0798172 21 # 4
2afc4e19 22 '<path d="M100,85 v30 h30 v30 M130,85 v30"',
e0798172 23 # 5
2afc4e19 24 '<path d="M130,85 h-30 v30 h30 v30 h-30"',
e0798172 25 # 6
2afc4e19 26 '<path d="M130,85 h-30 v60 h30 v-30 h-30"',
e0798172 27 # 7
2afc4e19 28 '<path d="M100,85 h30 v60"',
e0798172 29 # 8
2afc4e19 30 '<path d="M100,85 h30 v60 h-30 z M100,115 h30"',
e0798172 31 # 9
2afc4e19 32 '<path d="M100,135 h30 v-60 h-30 v30 h30"',
e0798172 33 # 10
2afc4e19 34 '<path d="M95,85 v60 M105,85 h30 v60 h-30 v-60"',
e0798172 35 # 11
2afc4e19 36 '<path d="M95,85 v60 M135,85 v60"',
e0798172 37 # 12
2afc4e19 38 '<path d="M95,85 v60 M105,85 h30 v30 h-30 v30 h30"'
e0798172
BA
39]
40
41final = "</svg>"
42
43for color in ["white", "black"]:
44 chrShift = 0 if color == "white" else 32
45 for number in range(12):
d982fffc 46 filename = chr(65 + number + chrShift) + "@.svg"
e0798172
BA
47 f = open(filename, "w")
48 f.write(preamble)
b27300c2 49 f.write("\n")
e0798172 50 f.write(white if color == "white" else black)
b27300c2 51 f.write("\n")
0760d861
BA
52 if number >= 1:
53 f.write(digits[number] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if color == "white" else 'stroke="orange"') + '/>')
54 f.write("\n")
e0798172
BA
55 f.write(final)
56 f.close()