Files
xscapes/clipshots_test.go
donlucasandClaude Opus 5 8001ac4173 The legend is the companion alone, floating on the page; the cast is four
His ask of 2026-09-15: "the companion by itself (instead of within the
scene), so it reads cleaner and more focused on what we are showing.
Every 'state' should be toggable like right now, but should only
showcase the companion, and its states. Same for 'a layer, not a
screen', where it should feature all companions we have drafted thus
far (crab, cat, owl, frog)" -- and on the first build, "no background
whatsoever. The companion can be a tad smaller and 'float' on the site".

- portraitFrames renders one animal on a ground the page writes as
  TRANSPARENT (HTMLPalette.Transparent, a sentinel no scene paints):
  no sea, no sand, no litter, no window box. The five legend states are
  still folded from the session, so the pose is the reducer's; the cast
  holds Working. The drawn box is centred at every rung, and the
  balloon's pointer is moved over the head (portraitBubble) instead of
  the beach's shoulder pointer, which clamped 16 cells off a centred
  crab in a 48-cell frame. 17 rows so the biggest rung's legs are not
  cut, which on a transparent ground reads as amputation, not a crop.
- The cast: crab, cat, owl (scenes.DrawOwlPicked) and frog
  (scenes.DrawCandidate), each 18x9, working, blinking once a loop, a
  name and one line under each. Replaces the crab/cat switcher.
- gifFrames' session stepping is sessionRun now, shared with the
  portraits; all ten existing clips fingerprinted byte-identical across
  the refactor.
- The page: portrait stages cap the cell at 13px and snap it to whole
  pixels (fractional cells showed hairline seams through flat colour);
  drawBox no longer draws a right label it had decided did not fit; the
  cast grid's columns are minmax(0,1fr) so a max-content frame cannot
  widen them off the page.

Nine portraits cost 5 KB gzipped; the page is 435 KB.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 15:38:29 -07:00

72 lines
2.6 KiB
Go

package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"
"github.com/donlucasx/xscapes/internal/canvas"
)
// TestClipShots writes every embedded clip as a frame page, so a REAL look at
// what the page will play is one command away:
//
// XSCAPES_CLIPSHOTS=<dir> go test -run TestClipShots .
// for f in <dir>/*.html; do "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
// --headless=new --disable-gpu --use-mock-keychain --hide-scrollbars \
// --window-size=1600,1400 --screenshot="${f%.html}.png" "file://$f"; done
//
// Eight frames of each clip, evenly spaced, in the page's own palette. It is
// the same instrument notes/vistashots is for the vista: every visual defect
// in session 32 was seen in a screenshot and none in a text dump. Skipped
// unless the directory is named, so the suite never writes anywhere.
func TestClipShots(t *testing.T) {
dir := os.Getenv("XSCAPES_CLIPSHOTS")
if dir == "" {
t.Skip("set XSCAPES_CLIPSHOTS=<dir> to write the frame pages")
}
only := map[string]bool{}
for _, k := range strings.Fields(os.Getenv("XSCAPES_CLIPSHOTS_ONLY")) {
only[k] = true
}
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
pal := &canvas.HTMLPalette{Transparent: &portraitGround}
type page struct{ key, body string }
var pages []page
for _, cl := range allFX(pal) {
if len(only) > 0 && !only[cl.key] {
continue
}
frames, cols, rows, fps, err := framesOf(7, cl)
if err != nil {
t.Fatal(err)
}
var b strings.Builder
fmt.Fprintf(&b, `<h2>%s -- %dx%d, %d frames at %d fps: %s</h2>`, cl.key, cols, rows, len(frames), fps, cl.note)
n := 8
if len(frames) < n {
n = len(frames)
}
for i := 0; i < n; i++ {
k := i * len(frames) / n
fmt.Fprintf(&b, `<div class="row"><div class="lab">frame %d</div><div class="fx">%s</div></div>`, k, frames[k])
}
pages = append(pages, page{cl.key, b.String()})
}
// The palette is complete only after the last frame.
style := `<meta charset="utf-8"><style>html,body{margin:0;padding:12px;background:#000;color:#ccc;font:13px Menlo,monospace}` +
`.fx pre{margin:0;font-family:Menlo,"SF Mono",monospace;line-height:1;letter-spacing:0;white-space:pre;display:block;font-size:11px}` +
`.row{display:flex;gap:10px;align-items:flex-start;margin-bottom:8px}.lab{width:90px;padding-top:6px}` +
`h2{font:bold 13px Menlo,monospace;color:#eee;margin:10px 0 8px}` + pal.CSS() + `</style>`
for _, p := range pages {
if err := os.WriteFile(filepath.Join(dir, p.key+".html"), []byte(style+p.body), 0o644); err != nil {
t.Fatal(err)
}
}
t.Logf("%d pages in %s", len(pages), dir)
}