Étend generate-icons.sh pour produire play-store-icon.png depuis icon-square.svg (Play Store exige une icône 512x512 sans transparence).
53 lines
2.2 KiB
Bash
Executable File
53 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Génère les icônes launcher (Android, iOS, desktop) depuis les SVG de docs/branding/.
|
|
# Prérequis : rsvg-convert, magick, python3. Idempotent.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
BRANDING="$ROOT/docs/branding"
|
|
RES="$ROOT/androidApp/src/main/res"
|
|
IOS_APPSET="$ROOT/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset"
|
|
|
|
for tool in rsvg-convert magick python3; do
|
|
command -v "$tool" >/dev/null 2>&1 || { echo "Erreur : '$tool' requis" >&2; exit 1; }
|
|
done
|
|
|
|
# --- Android : legacy (carte arrondie du master) ---
|
|
for pair in mdpi:48 hdpi:72 xhdpi:96 xxhdpi:144 xxxhdpi:192; do
|
|
dpi="${pair%%:*}"; size="${pair##*:}"
|
|
rsvg-convert -w "$size" -h "$size" "$BRANDING/logo.svg" -o "$RES/mipmap-$dpi/ic_launcher.png"
|
|
done
|
|
|
|
# --- Android : couches adaptive (108 dp) ---
|
|
for pair in mdpi:108 hdpi:162 xhdpi:216 xxhdpi:324 xxxhdpi:432; do
|
|
dpi="${pair%%:*}"; size="${pair##*:}"
|
|
magick -size "${size}x${size}" xc:'#1D3557' "$RES/mipmap-$dpi/ic_launcher_background.png"
|
|
rsvg-convert -w "$size" -h "$size" "$BRANDING/icon-foreground.svg" -o "$RES/mipmap-$dpi/ic_launcher_foreground.png"
|
|
rsvg-convert -w "$size" -h "$size" "$BRANDING/icon-monochrome.svg" -o "$RES/mipmap-$dpi/ic_launcher_monochrome.png"
|
|
done
|
|
|
|
# --- iOS : tailles lues dans Contents.json ---
|
|
python3 - "$BRANDING/icon-square.svg" "$IOS_APPSET" <<'PY'
|
|
import json, pathlib, re, subprocess, sys
|
|
|
|
svg, appset = sys.argv[1], pathlib.Path(sys.argv[2])
|
|
# Le Contents.json d'Xcode tolère les virgules traînantes, json.loads non :
|
|
text = re.sub(r",(\s*[}\]])", r"\1", (appset / "Contents.json").read_text())
|
|
for img in json.loads(text)["images"]:
|
|
w, _ = (float(v) for v in img["size"].split("x"))
|
|
px = round(w * float(img["scale"].rstrip("x")))
|
|
subprocess.run(
|
|
["rsvg-convert", "-w", str(px), "-h", str(px), svg, "-o", str(appset / img["filename"])],
|
|
check=True,
|
|
)
|
|
PY
|
|
|
|
# --- Desktop ---
|
|
mkdir -p "$ROOT/desktopApp/src/main/resources/icons"
|
|
rsvg-convert -w 512 -h 512 "$BRANDING/logo.svg" -o "$ROOT/desktopApp/src/main/resources/icons/icon.png"
|
|
|
|
# --- Play Store : icône 512x512 plein cadre (sans transparence) ---
|
|
rsvg-convert -w 512 -h 512 "$BRANDING/icon-square.svg" -o "$BRANDING/play-store-icon.png"
|
|
|
|
echo "Icônes générées ✓"
|