#!/bin/bash
# Analyzes the reference icons in svg_samples/ and (re)writes
# svg_samples/style_guide.json -- a small set of measured parameters
# (monochrome/flat/stroke-free fractions, padding inset, corner-rounding ->
# potrace alphamax) that scripts/lib/icon_remote.py's "trace" mode uses to
# make generated app icons match that visual language.
#
# Runs entirely on THIS host (not the VM) -- svg_samples/, rsvg-convert and
# ImageMagick all live here. Re-run whenever svg_samples/ changes; the
# resulting style_guide.json's hash is what invalidates cached silhouettes
# in generated_icons/ on the next 10-generate-app-icons.sh run.
#
# Usage: 09-build-icon-style-guide.sh
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"

for tool in rsvg-convert convert python3; do
    if ! command -v "$tool" >/dev/null 2>&1; then
        echo "Missing required tool: $tool" >&2
        exit 1
    fi
done

python3 ./lib/svg_style_guide.py
