#!/bin/bash
# shots.sh: all state shots + contact sheets (needs agent-browser on bob.html, viewport 1280x900)
cd "$(dirname "$0")"
agent-browser set viewport 1280 900 >/dev/null
agent-browser open "file://$PWD/bob.html" >/dev/null; sleep 1
S() { ./shoot.sh "$@"; }
S 01-idle "bob.go('idle'); bob.step(1.5)"
for i in 0 1 2 3; do S 02-walk-$i "bob.R.cx=0.3; bob.go('walk'); bob.step(1.2+$i*0.11875)"; done
S 03a-cross "bob.go('cross'); bob.step(1.2)"
S 03b-think-mid "bob.go('think'); bob.step(0.75)"
S 03c-think "bob.go('think'); bob.step(1.8)"
S 04-happy "bob.go('happy'); bob.step(1.0)"
S 05-sad "bob.go('sad'); bob.step(1.2)"
S 06-squat "bob.go('squat'); bob.step(1.2)"
S 07-reach "bob.go('reach'); bob.step(1.2)"
S 07b-walk-turnaround "bob.R.cx=0.8; bob.R.dir=1; bob.go('walk'); bob.step(0.6); while(!bob.R.turning) bob.step(1/60); bob.step(0.14)"
for x in 1:0.85 2:1.1 3:1.6 4:3; do S 08-pickup-${x%:*} "bob.go('idle'); bob.step(1); bob.go('pickup'); bob.step(${x#*:})" 330; done
for x in 1:0.1 2:0.25 3:0.45 4:1.2; do S 09-stop-${x%:*} "bob.R.cx=0.3; bob.go('idle'); bob.step(0.5); bob.go('walk'); bob.step(1.3); bob.go('idle'); while(bob.R.pending) bob.step(1/60); bob.step(${x#*:})" 330; done
/cache/tmp/venv-anim/bin/python - <<'PY'
from PIL import Image; import glob
fs = sorted(glob.glob('shots/crop/*.png'))
for n in range(0, len(fs), 7):
    ims = [Image.open(f) for f in fs[n:n + 7]]; h = ims[0].height
    s = Image.new('RGB', (sum(im.width for im in ims), h), 'white'); x = 0
    for im in ims: s.paste(im, (x, 0)); x += im.width
    s.save(f'shots/contact-{n // 7 + 1}.png')
print(len(fs), 'shots')
PY
