# Gera as imagens do XiangQi Wizard Light para a FredyGames: o tabuleiro e as pecas sao desenhos nossos em SVG # (pecas com as letras K A E H R C P), no lugar dos GIF/JPG do repositorio, que nao trazem origem declarada. # Uso: python3 -I gen-images.py (GPL-2.0-or-later, como o resto desta build) import sys out = sys.argv[1] RED, BLK = "#b3261e", "#1b1b1f" def w(name, s): open(f"{out}/{name}.svg", "w", encoding="utf-8", newline="\n").write(s) hdr = '' letters = {"k": "K", "a": "A", "b": "E", "n": "H", "r": "R", "c": "C", "p": "P"} for side, col in (("r", RED), ("b", BLK)): for key, ch in letters.items(): w(side + key, hdr + '' '' '' '%s\n' % (col, col, col, ch)) w(side + "km", hdr + '' 'K\n' % (col, col)) w("oo", hdr + '\n') w("oos", hdr + '\n') w("thinking", hdr + '' '' '\n') # tabuleiro 521x577: casas de 57 px, canto superior esquerdo da grade em (4, 3) L, T, S = 4, 3, 57 def cx(i): return L + S * i + S / 2 def cy(j): return T + S * j + S / 2 g = [] g.append('') g.append('') g.append('') g.append('') g.append('' % (cx(0)-6, cy(0)-6, cx(8)-cx(0)+12, cy(9)-cy(0)+12)) ln = [] for j in range(10): ln.append('M%g %gH%g' % (cx(0), cy(j), cx(8))) for i in range(9): if i in (0, 8): ln.append('M%g %gV%g' % (cx(i), cy(0), cy(9))) else: ln.append('M%g %gV%g' % (cx(i), cy(0), cy(4))) ln.append('M%g %gV%g' % (cx(i), cy(5), cy(9))) for (r0, r1) in ((0, 2), (7, 9)): ln.append('M%g %gL%g %g' % (cx(3), cy(r0), cx(5), cy(r1))) ln.append('M%g %gL%g %g' % (cx(5), cy(r0), cx(3), cy(r1))) g.append('' % ''.join(ln)) # marcas de canhoes e peoes marks = [] def mark(i, j): d = 5; a = 4; l = 10 for sx in (-1, 1): if (i == 0 and sx == -1) or (i == 8 and sx == 1): continue for sy in (-1, 1): x, y = cx(i), cy(j) marks.append('M%g %gh%gv%g' % (x + sx * (d + l), y + sy * d, -sx * l, sy * l)) for (i, j) in ((1, 2), (7, 2), (1, 7), (7, 7), (0, 3), (2, 3), (4, 3), (6, 3), (8, 3), (0, 6), (2, 6), (4, 6), (6, 6), (8, 6)): mark(i, j) g.append('' % ''.join(marks)) g.append('\n') w("board", ''.join(g))