Skip to content

Commit

Permalink
[WIP] add crazyhouse pocket gif in sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
ryg-git committed Feb 14, 2024
1 parent 08c9c96 commit 3dd8dde
Show file tree
Hide file tree
Showing 47 changed files with 56 additions and 66 deletions.
85 changes: 49 additions & 36 deletions theme/ch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def make_ch_sprite(piece_set_name: str):
"xmlns": "http://www.w3.org/2000/svg",
"version": "1.1",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"viewBox": f"0 0 {SQUARE_SIZE * 8} {SQUARE_SIZE * 9}",
"viewBox": f"0 0 {SQUARE_SIZE * 8} {SQUARE_SIZE * 8}",
},
)

Expand Down Expand Up @@ -76,7 +76,33 @@ def make_ch_sprite(piece_set_name: str):
},
)

for y in range(5, 9):
for x in range(8):
ET.SubElement(
svg,
"rect",
{
"x": str(SQUARE_SIZE * x),
"y": str(SQUARE_SIZE * 5),
"width": str(SQUARE_SIZE),
"height": str(SQUARE_SIZE),
"stroke": "none",
"fill": "#888888",
},
)

color = "w" if x >= 4 else "b"

ET.SubElement(
svg,
"use",
{
"xlink:href": f"#{color}{ms.PIECE_TYPES[0]}",
"transform": f"translate({SQUARE_SIZE * x}, {SQUARE_SIZE * 5})",
"opacity": "0.1",
},
)

for y in range(6, 8):
for x in range(8):
ET.SubElement(
svg,
Expand All @@ -91,40 +117,27 @@ def make_ch_sprite(piece_set_name: str):
},
)

color = "w" if y % 2 == 0 else "b"
color = "w" if y == 7 else "b"

if y < 7:
ET.SubElement(
svg,
"use",
{
"xlink:href": f"#{color}{ms.PIECE_TYPES[0]}",
"transform": f"translate({SQUARE_SIZE * x}, {SQUARE_SIZE * y})",
"opacity": "0.1",
},
)

else:
ET.SubElement(
svg,
"use",
{
"xlink:href": f"#{color}{ms.PIECE_TYPES[0]}",
"transform": f"translate({SQUARE_SIZE * x}, {SQUARE_SIZE * y})",
},
)

ET.SubElement(
svg,
"image",
{
"xlink:href": f"ch-numbers/ch{x + 1}.png",
"transform": f"translate({SQUARE_SIZE * (x + 0.60)}, {SQUARE_SIZE * (y + 0.60)})",
"width": "15",
"height": "15"
},
)
ET.SubElement(
svg,
"use",
{
"xlink:href": f"#{color}{ms.PIECE_TYPES[0]}",
"transform": f"translate({SQUARE_SIZE * x}, {SQUARE_SIZE * y})",
},
)

ET.SubElement(
svg,
"image",
{
"xlink:href": f"ch-numbers/ch{x + 1}.png",
"transform": f"translate({SQUARE_SIZE * (x + 0.60)}, {SQUARE_SIZE * (y + 0.60)})",
"width": "15",
"height": "15"
},
)

resvg = subprocess.run(
"resvg --resources-dir . --zoom 2 - -c",
Expand All @@ -136,8 +149,8 @@ def make_ch_sprite(piece_set_name: str):
image = Image.open(io.BytesIO(resvg.stdout), formats=[
"PNG"]).quantize(64, dither=0)

print(f"sprites-ch/{piece_set_name}-ch.gif")
print(f"sprites/crazyhouse-{piece_set_name}.gif")

image.save(
f"sprites-ch/{piece_set_name}-ch.gif", optimize=True, interlace=False
f"sprites/crazyhouse-{piece_set_name}.gif", optimize=True, interlace=False
)
37 changes: 7 additions & 30 deletions theme/make-sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def include_highlight_colors(theme: dict):
"ic": include_highlight_colors({"light": "#ececec", "dark": "#c1c18e"}),
"pink": include_highlight_colors({"light": "#f1f1c9", "dark": "#f07272"}),
"purple": include_highlight_colors({"light": "#9f90b0", "dark": "#7d4a8d"}),
"crazyhouse": include_highlight_colors({"light": "#888888", "dark": "#888888"}),
}


Expand Down Expand Up @@ -210,32 +211,6 @@ def make_sprite(theme_name: str, piece_set_name: str):
},
)

for x in range(8):
ET.SubElement(
svg,
"rect",
{
"x": str(SQUARE_SIZE * x),
"y": str(SQUARE_SIZE * 8),
"width": str(SQUARE_SIZE),
"height": str(SQUARE_SIZE),
"stroke": "none",
"fill": "#888888",
},
)

color = "w" if x >= 4 else "b"

ET.SubElement(
svg,
"use",
{
"xlink:href": f"#{color}{PIECE_TYPES[min(x, 6) - 1]}",
"transform": f"translate({SQUARE_SIZE * x}, {SQUARE_SIZE * 8})",
"opacity": "0.3",
},
)

resvg = subprocess.run(
"resvg --resources-dir . --zoom 2 - -c",
shell=True,
Expand All @@ -255,11 +230,13 @@ def make_crazyhouse_sprite(piece_set_name):
make_ch_sprite(piece_set_name)

def make_all_sprites():
for piece_set_name in get_piece_set_names():
for theme_name in THEMES.keys():
make_sprite(theme_name, piece_set_name)
for theme_name in THEMES.keys():
for piece_set_name in get_piece_set_names():
if theme_name == "crazyhouse":
make_crazyhouse_sprite(piece_set_name)
else:
make_sprite(theme_name, piece_set_name)

make_crazyhouse_sprite(piece_set_name)


if __name__ == "__main__":
Expand Down
Binary file removed theme/sprites-ch/dubrovny-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/fresca-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/gioco-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/governor-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/kosal-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/maestro-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/merida-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/reillycraig-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/riohacha-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/spatial-ch.gif
Binary file not shown.
Binary file removed theme/sprites-ch/tatiana-ch.gif
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/sprites/crazyhouse-dubrovny.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/sprites/crazyhouse-fresca.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/sprites/crazyhouse-gioco.gif
Binary file added theme/sprites/crazyhouse-governor.gif
Binary file added theme/sprites/crazyhouse-kosal.gif
Binary file added theme/sprites/crazyhouse-maestro.gif
Binary file added theme/sprites/crazyhouse-merida.gif
Binary file added theme/sprites/crazyhouse-reillycraig.gif
Binary file added theme/sprites/crazyhouse-riohacha.gif
Binary file added theme/sprites/crazyhouse-spatial.gif
Binary file added theme/sprites/crazyhouse-tatiana.gif

0 comments on commit 3dd8dde

Please sign in to comment.