Skip to content

Commit

Permalink
Update piece sets
Browse files Browse the repository at this point in the history
sync SVGs from lila
remove libra (lichess-org/lila#15938)
tweak sprite script to help apply updates in the future
  • Loading branch information
fitztrev committed Dec 12, 2024
1 parent eef46e2 commit 6fb1b5a
Show file tree
Hide file tree
Showing 502 changed files with 1,442 additions and 4,402 deletions.
65 changes: 31 additions & 34 deletions src/assets.rs

Large diffs are not rendered by default.

82 changes: 42 additions & 40 deletions theme/make-sprites.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

import os
import subprocess
import io
from PIL import Image, ImageDraw
Expand All @@ -18,45 +19,6 @@
"purple": ("#9f90b0", "#7d4a8d"),
}

PIECE_SETS = [
"alpha",
"anarcandy",
"caliente",
"california",
"cardinal",
"cburnett",
"celtic",
"chess7",
"chessnut",
"cooke",
"companion",
"disguised",
"dubrovny",
"fantasy",
"fresca",
"gioco",
"governor",
"horsey",
"icpieces",
"kiwen-suwi",
"kosal",
"leipzig",
"letter",
"libra",
"maestro",
"merida",
"monarchy",
"mpchess",
"pirouetti",
"pixel",
"reillycraig",
"riohacha",
"shapes",
"spatial",
"staunty",
"tatiana",
]

NONTHEME_COLORS = [
"#262421", # dark background
"#bababa", # text color
Expand Down Expand Up @@ -114,14 +76,54 @@ def make_sprite(light, dark, pieces, check_gradient):

def main():
check_gradient = resvg("check-gradient.svg")
piece_sets = {piece_set: resvg_pieces(piece_set) for piece_set in PIECE_SETS}

piece_dirs = [ os.path.basename(f.path) for f in os.scandir("piece") if f.is_dir() ]
piece_sets = {piece_set: resvg_pieces(piece_set) for piece_set in piece_dirs}

for board_theme, (light, dark) in BOARD_THEMES.items():
print(f"Generating sprites for {board_theme}...")
for piece_set, pieces in piece_sets.items():
image = make_sprite(light=light, dark=dark, pieces=pieces, check_gradient=check_gradient)
image.save(f"sprites/{board_theme}-{piece_set}.gif", optimize=True, interlace=False, transparency=image.getpixel((SQUARE_SIZE * 8 - 1, 0)))

rust_code_updates(piece_dirs)


def to_pascal_case(name: str) -> str:
return "".join(x.capitalize() for x in name.lower().split("-"))


def rust_code_updates(piece_dirs):
print("🦀 Update `src/assets.rs` with these:")
print("#" * 80)

rust_enum = "pub enum PieceSet {\n"
for piece_set in sorted(piece_dirs):
if piece_set == "cburnett":
rust_enum += f" #[default]\n"
elif "-" in piece_set:
rust_enum += f" #[serde(rename = \"{piece_set}\")]\n"
rust_enum += f" {to_pascal_case(piece_set)},\n"
rust_enum += "}"
print(rust_enum)

print("#" * 80)
inner_data = "inner: [\n"
for piece_set in sorted(piece_dirs):
inner_data += f" {to_pascal_case(piece_set)},\n"
inner_data += "]"
print(inner_data)

print("#" * 80)
colors = ["blue", "brown", "green", "ic", "pink", "purple"]
sprite_data = "match board {"
for color in colors:
sprite_data += f"\n BoardTheme::{color.capitalize()} => match pieces {{\n"
for piece_set in sorted(piece_dirs):
sprite_data += f" {to_pascal_case(piece_set)} => include_bytes!(\"../theme/sprites/{color}-{piece_set}.gif\"),\n"
sprite_data += " },\n"
sprite_data += "}"
print(sprite_data)

if __name__ == "__main__":
main()
6 changes: 1 addition & 5 deletions theme/piece/alpha/bB.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/bK.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/bN.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/bP.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/bQ.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/bR.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/wB.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion theme/piece/alpha/wK.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6fb1b5a

Please sign in to comment.