#!/bin/bash
# harmony_preview.sh -- harmony visual-regression harness.
# Renders swatch sheets (one per sample dye, every strategy) straight from the
# real engine + real DB2 colours, so you can eyeball whether the harmonies look
# right after engine changes. Run from anywhere:  bash tests/harmony_preview.sh
# Output: PNGs in /tmp/harmony_preview/  (open them, or Read them in a session).
set -e
HERE="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$HERE/.." && pwd)"

CSV=/tmp/dyecolor.csv
if [ ! -f "$CSV" ]; then
    echo "fetching DyeColor CSV from wago.tools ..."
    curl -s 'https://wago.tools/db2/DyeColor/csv' -o "$CSV"
fi

cd "$ROOT"
lua tests/harmony_preview_export.lua

VENV="$ROOT/../vss-tools/.venv/bin/python3"
if [ -x "$VENV" ]; then
    "$VENV" tests/harmony_preview_render.py
else
    echo "WARN: vss-tools venv python (with Pillow) not found at $VENV"
    echo "      run: python3 tests/harmony_preview_render.py   (needs Pillow)"
    python3 tests/harmony_preview_render.py
fi
