Attempt to clarify installation instructions a little
[vchess.git] / client / public / images / pieces / Avalam / generateSVG.py
CommitLineData
b27300c2
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
2afc4e19
BA
11black = '<circle cx="115" cy="115" r="100" fill="crimson" stroke="darkslategray"/>'
12white = '<circle cx="115" cy="115" r="100" fill="gold" stroke="darkslategray"/>'
b27300c2
BA
13
14digits = [
0760d861 15 # 1 (unused here)
2afc4e19 16 '<path d="M130,85 v60"',
b27300c2 17 # 2
2afc4e19 18 '<path d="M100,85 h30 v30 h-30 v30 h30"',
b27300c2 19 # 3
2afc4e19 20 '<path d="M100,85 h30 v30 h-30 M130,115 v30 h-30"',
b27300c2 21 # 4
2afc4e19 22 '<path d="M100,85 v30 h30 v30 M130,85 v30"',
b27300c2 23 # 5
2afc4e19 24 '<path d="M130,85 h-30 v30 h30 v30 h-30"'
b27300c2
BA
25]
26
27final = "</svg>"
28
29for color in ["white", "black"]:
30 for number in range(5):
31 filename = ('w' if color == "white" else 'b') + chr(97 + number + 1) + ".svg"
32 f = open(filename, "w")
33 f.write(preamble)
34 f.write("\n")
35 f.write(white if color == "white" else black)
36 f.write("\n")
0760d861
BA
37 if number >= 1:
38 f.write(digits[number] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if color == "white" else 'stroke="yellow"') + '/>')
39 f.write("\n")
b27300c2
BA
40 f.write(final)
41 f.close()