#!/bin/bash # Copies the logos every demo opens and closes with from their sources in media/ into each demo's own # art/ folder (a demo carries everything it uses, so it packs into a .game by itself): the Singe # dragon, turned to face left, and lettering for the opening card, the lettering turned near-white to # stand on black, and Kangaroo Punch's logo made for black, uncompressed, for the closing one. The # demos draw them from the SVG at the screen's resolution (kit.lua, K.vector). set -euo pipefail REPO=$(cd "$(dirname "$0")/.." && pwd) LETTERING="#f2f2f2" for GAMES_DAT in "$REPO"/demos/*/games.dat; do ART="$(dirname "$GAMES_DAT")/art" mkdir -p "$ART" # The dragon turned to face left, as on Singe's own logo: everything in the drawing mirrored about # the middle of its view box. python3 - "$REPO/media/Dragon.svg" "$ART/dragon.svg" <<'PY' import re, sys svg = open(sys.argv[1]).read() x, y, w, h = (float(v) for v in re.search(r'viewBox="([^"]+)"', svg).group(1).split()) opening = re.search(r']*>', svg) svg = svg[:opening.end()] + '' % (2 * x + w) + svg[opening.end():] svg = svg.replace('', '') open(sys.argv[2], "w").write(svg) PY sed "s/fill=\"#000\"/fill=\"$LETTERING\"/" "$REPO/media/SingeText.svg" > "$ART/singeText.svg" if ! grep -q "fill=\"$LETTERING\"" "$ART/singeText.svg"; then echo "SingeText.svg no longer has fill=\"#000\" to recolor" >&2 exit 1 fi zcat "$REPO/media/Kangaroo Punch Logo with Text on Black.svgz" > "$ART/kangarooPunch.svg" done