Commit | Line | Data |
---|---|---|
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 | ||
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="red" stroke="darkslategray"/>' | |
12 | white = '<circle cx="115" cy="115" r="100" fill="yellow" stroke="darkslategray"/>' | |
13 | ||
14 | digits = [ | |
15 | # 1 | |
16 | '<path d="M125,95 v40"', | |
17 | # 2 | |
18 | '<path d="M105,95 h20 v20 h-20 v20 h20"', | |
19 | # 3 | |
20 | '<path d="M105,95 h20 v20 h-20 M125,115 v20 h-20"', | |
21 | # 4 | |
22 | '<path d="M105,95 v20 h20 v20 M125,95 v20"', | |
23 | # 5 | |
24 | '<path d="M125,95 h-20 v20 h20 v20 h-20"' | |
25 | ] | |
26 | ||
27 | final = "</svg>" | |
28 | ||
29 | for 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") | |
37 | f.write(digits[number] + ' fill="none" stroke-width="4" ' + ('stroke="red"' if color == "white" else 'stroke="yellow"') + '/>') | |
38 | f.write("\n") | |
39 | f.write(final) | |
40 | f.close() |