update
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 13 May 2026 12:49:35 +0000 (14:49 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 13 May 2026 12:49:35 +0000 (14:49 +0200)
initialize.sh
pieces/Emergo/generateSVG_composite.py [new file with mode: 0755]
pieces/Emergo/generateSVG_simple.py [new file with mode: 0755]

index 9e187d0..a7fd40d 100755 (executable)
@@ -5,4 +5,4 @@ wget https://xogo.casa/extras.zip && unzip extras.zip
 cp js/parameters.js.dist js/parameters.js
 npm i
 cd pieces/Avalam && python generateSVG.py && cd ../..
-#cd pieces/Emergo && python generateSVG.py && cd ../..
+cd pieces/Emergo && python generateSVG.py && cd ../..
diff --git a/pieces/Emergo/generateSVG_composite.py b/pieces/Emergo/generateSVG_composite.py
new file mode 100755 (executable)
index 0000000..85726d5
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+# Compose each piece SVG with numbers
+# https://travishorn.com/removing-parts-of-shapes-in-svg-b539a89e5649
+# https://developer.mozilla.org/fr/docs/Web/SVG/Tutoriel/Paths
+
+preamble = """<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="230" height="230">
+<defs>
+  <mask id="stripe">
+    <rect x="0" y="0" width="230" height="230" fill="white"/>
+    <rect x="0" y="115" width="230" height="115"/>
+  </mask>
+</defs>"""
+
+black_top = '<circle cx="115" cy="115" r="100" fill="black" mask="url(#stripe)"/>'
+white_bottom = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown"/>'
+white_top = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown" mask="url(#stripe)"/>'
+black_bottom = '<circle cx="115" cy="115" r="100" fill="black"/>'
+
+digits = {
+    "top": [
+        # 1 (unused here)
+        '<path d="M130,35 v60"',
+        # 2
+        '<path d="M100,35 h30 v30 h-30 v30 h30"',
+        # 3
+        '<path d="M100,35 h30 v30 h-30 M130,65 v30 h-30"',
+        # 4
+        '<path d="M100,35 v30 h30 v30 M130,35 v30"',
+        # 5
+        '<path d="M130,35 h-30 v30 h30 v30 h-30"',
+        # 6
+        '<path d="M130,35 h-30 v60 h30 v-30 h-30"',
+        # 7
+        '<path d="M100,35 h30 v60"',
+        # 8
+        '<path d="M100,35 h30 v60 h-30 z M100,65 h30"',
+        # 9
+        '<path d="M100,95 h30 v-60 h-30 v30 h30"',
+        # 10
+        '<path d="M90,35 v60 M100,35 h30 v60 h-30 v-60"',
+        # 11
+        '<path d="M90,35 v60 M130,35 v60"',
+        # 12
+        '<path d="M90,35 v60 M100,35 h30 v30 h-30 v30 h30"'
+    ],
+    "bottom": [
+        # 1 (unused here)
+        '<path d="M130,135 v60"',
+        # 2
+        '<path d="M100,135 h30 v30 h-30 v30 h30"',
+        # 3
+        '<path d="M100,135 h30 v30 h-30 M130,165 v30 h-30"',
+        # 4
+        '<path d="M100,135 v30 h30 v30 M130,135 v30"',
+        # 5
+        '<path d="M130,135 h-30 v30 h30 v30 h-30"',
+        # 6
+        '<path d="M130,135 h-30 v60 h30 v-30 h-30"',
+        # 7
+        '<path d="M100,135 h30 v60"',
+        # 8
+        '<path d="M100,135 h30 v60 h-30 z M100,165 h30"',
+        # 9
+        '<path d="M100,195 h30 v-60 h-30 v30 h30"',
+        # 10
+        '<path d="M90,135 v60 M100,135 h30 v60 h-30 v-60"',
+        # 11
+        '<path d="M90,135 v60 M130,135 v60"',
+        # 12
+        '<path d="M90,135 v60 M100,135 h30 v30 h-30 v30 h30"'
+    ]
+}
+
+final = "</svg>"
+
+for colorTop in ["white", "black"]:
+    chrShift = 0 if colorTop == "white" else 32
+    for top in range(12):
+        for bottom in range(12):
+            filename = chr(65 + top + chrShift) + chr(65 + bottom + chrShift) + ".svg"
+            f = open(filename, "w")
+            f.write(preamble)
+            f.write("\n")
+            f.write(black_bottom if colorTop == "white" else white_bottom)
+            f.write("\n")
+            f.write(white_top if colorTop == "white" else black_top)
+            f.write("\n")
+            if top >= 1:
+                f.write(digits["top"][top] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "white" else 'stroke="orange"') + '/>')
+                f.write("\n")
+            if bottom >= 1:
+                f.write(digits["bottom"][bottom] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "black" else 'stroke="orange"') + '/>')
+                f.write("\n")
+            f.write(final)
+            f.close()
diff --git a/pieces/Emergo/generateSVG_simple.py b/pieces/Emergo/generateSVG_simple.py
new file mode 100755 (executable)
index 0000000..51f734e
--- /dev/null
@@ -0,0 +1,150 @@
+#!/usr/bin/env python
+
+# Compose each piece SVG with numbers
+# https://travishorn.com/removing-parts-of-shapes-in-svg-b539a89e5649
+# https://developer.mozilla.org/fr/docs/Web/SVG/Tutoriel/Paths
+
+preamble = """<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="230" height="230">"""
+
+black = '<circle cx="115" cy="115" r="100" fill="black"/>'
+white = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown"/>'
+
+digits = [
+    # 1 (unused)
+    '<path d="M130,85 v60"',
+    # 2
+    '<path d="M100,85 h30 v30 h-30 v30 h30"',
+    # 3
+    '<path d="M100,85 h30 v30 h-30 M130,115 v30 h-30"',
+    # 4
+    '<path d="M100,85 v30 h30 v30 M130,85 v30"',
+    # 5
+    '<path d="M130,85 h-30 v30 h30 v30 h-30"',
+    # 6
+    '<path d="M130,85 h-30 v60 h30 v-30 h-30"',
+    # 7
+    '<path d="M100,85 h30 v60"',
+    # 8
+    '<path d="M100,85 h30 v60 h-30 z M100,115 h30"',
+    # 9
+    '<path d="M100,135 h30 v-60 h-30 v30 h30"',
+    # 10
+    '<path d="M95,85 v60 M105,85 h30 v60 h-30 v-60"',
+    # 11
+    '<path d="M95,85 v60 M135,85 v60"',
+    # 12
+    '<path d="M95,85 v60 M105,85 h30 v30 h-30 v30 h30"'
+]
+
+final = "</svg>"
+
+for color in ["white", "black"]:
+    chrShift = 0 if color == "white" else 32
+    for number in range(12):
+        filename = chr(65 + number + chrShift) + "@.svg"
+        f = open(filename, "w")
+        f.write(preamble)
+        f.write("\n")
+        f.write(white if color == "white" else black)
+        f.write("\n")
+        if number >= 1:
+            f.write(digits[number] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if color == "white" else 'stroke="orange"') + '/>')
+            f.write("\n")
+        f.write(final)
+        f.close()
+
+
+preamble = """<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="230" height="230">
+<defs>
+  <mask id="stripe">
+    <rect x="0" y="0" width="230" height="230" fill="white"/>
+    <rect x="0" y="115" width="230" height="115"/>
+  </mask>
+</defs>"""
+
+black_top = '<circle cx="115" cy="115" r="100" fill="black" mask="url(#stripe)"/>'
+white_bottom = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown"/>'
+white_top = '<circle cx="115" cy="115" r="100" fill="whitesmoke" stroke="saddlebrown" mask="url(#stripe)"/>'
+black_bottom = '<circle cx="115" cy="115" r="100" fill="black"/>'
+
+digits = {
+    "top": [
+        # 1 (unused here)
+        '<path d="M130,35 v60"',
+        # 2
+        '<path d="M100,35 h30 v30 h-30 v30 h30"',
+        # 3
+        '<path d="M100,35 h30 v30 h-30 M130,65 v30 h-30"',
+        # 4
+        '<path d="M100,35 v30 h30 v30 M130,35 v30"',
+        # 5
+        '<path d="M130,35 h-30 v30 h30 v30 h-30"',
+        # 6
+        '<path d="M130,35 h-30 v60 h30 v-30 h-30"',
+        # 7
+        '<path d="M100,35 h30 v60"',
+        # 8
+        '<path d="M100,35 h30 v60 h-30 z M100,65 h30"',
+        # 9
+        '<path d="M100,95 h30 v-60 h-30 v30 h30"',
+        # 10
+        '<path d="M90,35 v60 M100,35 h30 v60 h-30 v-60"',
+        # 11
+        '<path d="M90,35 v60 M130,35 v60"',
+        # 12
+        '<path d="M90,35 v60 M100,35 h30 v30 h-30 v30 h30"'
+    ],
+    "bottom": [
+        # 1 (unused here)
+        '<path d="M130,135 v60"',
+        # 2
+        '<path d="M100,135 h30 v30 h-30 v30 h30"',
+        # 3
+        '<path d="M100,135 h30 v30 h-30 M130,165 v30 h-30"',
+        # 4
+        '<path d="M100,135 v30 h30 v30 M130,135 v30"',
+        # 5
+        '<path d="M130,135 h-30 v30 h30 v30 h-30"',
+        # 6
+        '<path d="M130,135 h-30 v60 h30 v-30 h-30"',
+        # 7
+        '<path d="M100,135 h30 v60"',
+        # 8
+        '<path d="M100,135 h30 v60 h-30 z M100,165 h30"',
+        # 9
+        '<path d="M100,195 h30 v-60 h-30 v30 h30"',
+        # 10
+        '<path d="M90,135 v60 M100,135 h30 v60 h-30 v-60"',
+        # 11
+        '<path d="M90,135 v60 M130,135 v60"',
+        # 12
+        '<path d="M90,135 v60 M100,135 h30 v30 h-30 v30 h30"'
+    ]
+}
+
+final = "</svg>"
+
+for colorTop in ["white", "black"]:
+    chrShift = 0 if colorTop == "white" else 32
+    for top in range(12):
+        for bottom in range(12):
+            filename = chr(65 + top + chrShift) + chr(65 + bottom + chrShift) + ".svg"
+            f = open(filename, "w")
+            f.write(preamble)
+            f.write("\n")
+            f.write(black_bottom if colorTop == "white" else white_bottom)
+            f.write("\n")
+            f.write(white_top if colorTop == "white" else black_top)
+            f.write("\n")
+            if top >= 1:
+                f.write(digits["top"][top] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "white" else 'stroke="orange"') + '/>')
+                f.write("\n")
+            if bottom >= 1:
+                f.write(digits["bottom"][bottom] + ' fill="none" stroke-width="5" ' + ('stroke="red"' if colorTop == "black" else 'stroke="orange"') + '/>')
+                f.write("\n")
+            f.write(final)
+            f.close()