53 lines
2.4 KiB
Bash
53 lines
2.4 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Inspiration randomizer: generate N plates from random seeds, each named by its
|
||
|
|
# seed, plus an HTML contact sheet to browse them. Because every parameter is
|
||
|
|
# derived from the seed, picking a favourite just means noting its seed and
|
||
|
|
# running: tools/render.sh <SEED>
|
||
|
|
#
|
||
|
|
# Usage: tools/inspire.sh [count] [thumb_px]
|
||
|
|
# tools/inspire.sh 32 600
|
||
|
|
set -e
|
||
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||
|
|
COUNT="${1:-24}"
|
||
|
|
SIZE="${2:-600}"
|
||
|
|
OUT="$ROOT/output/inspiration"
|
||
|
|
mkdir -p "$OUT"
|
||
|
|
|
||
|
|
WORDS=(MUON KAON PION LAMBDA SIGMA XI OMEGA TAU GLUON QUARK HADRON BARYON LEPTON \
|
||
|
|
NEUTRINO BOSON STRANGE CHARM HYPERON ANTIPROTON POSITRON MESON FERMION NUCLEON \
|
||
|
|
ISOSPIN CASCADE RESONANCE PARITY GLUEBALL PENTAQUARK PHOTON)
|
||
|
|
|
||
|
|
SEEDS_FILE="$OUT/seeds.txt"
|
||
|
|
: > "$SEEDS_FILE"
|
||
|
|
|
||
|
|
echo "Generating $COUNT inspiration plates (${SIZE}px) → output/inspiration/"
|
||
|
|
for ((i = 1; i <= COUNT; i++)); do
|
||
|
|
W=${WORDS[$RANDOM % ${#WORDS[@]}]}
|
||
|
|
N=$((RANDOM % 9000 + 1000))
|
||
|
|
SEED="$W-$N"
|
||
|
|
"$ROOT/tools/shoot.sh" "$OUT/$SEED.png" "fromseed=1&seed=$SEED&size_px=$SIZE" >/dev/null
|
||
|
|
echo "$SEED" >> "$SEEDS_FILE"
|
||
|
|
printf " [%2d/%2d] %s\n" "$i" "$COUNT" "$SEED"
|
||
|
|
done
|
||
|
|
|
||
|
|
# Build the contact sheet
|
||
|
|
SHEET="$OUT/index.html"
|
||
|
|
{
|
||
|
|
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Bubble Chamber — inspiration</title>'
|
||
|
|
echo '<style>body{margin:0;background:#111;color:#bbb;font:12px/1.4 ui-monospace,Menlo,monospace;padding:24px}'
|
||
|
|
echo 'h1{font-weight:400;letter-spacing:.2em;text-transform:uppercase;font-size:13px;color:#d4a574}'
|
||
|
|
echo '.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:18px;margin-top:18px}'
|
||
|
|
echo 'figure{margin:0;background:#000;border:1px solid #2a2a2a}img{width:100%;display:block}'
|
||
|
|
echo 'figcaption{padding:6px 8px;display:flex;justify-content:space-between;align-items:center}'
|
||
|
|
echo '.s{color:#e8e4d8;letter-spacing:.05em}.c{color:#555;user-select:all}</style></head><body>'
|
||
|
|
echo "<h1>Bubble Chamber · inspiration · $(date +%Y-%m-%d)</h1>"
|
||
|
|
echo '<p>Click a seed to select it, then run <span class="c">tools/render.sh <SEED></span> for the print master.</p>'
|
||
|
|
echo '<div class="grid">'
|
||
|
|
while IFS= read -r S; do
|
||
|
|
echo "<figure><img src=\"$S.png\" loading=\"lazy\"><figcaption><span class=\"s\">$S</span><span class=\"c\">render.sh $S</span></figcaption></figure>"
|
||
|
|
done < "$SEEDS_FILE"
|
||
|
|
echo '</div></body></html>'
|
||
|
|
} > "$SHEET"
|
||
|
|
|
||
|
|
echo "done. open: output/inspiration/index.html"
|