summaryrefslogtreecommitdiff
path: root/anim/tools
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 02:11:12 -0300
committerGabriel Schneider <[email protected]>2026-11-11 04:20:25 -0300
commit5922ee911b9a6604f60dc83be36ba9e6c9abac98 (patch)
tree310b983f5205709e5db173f9f1bc8e8d499d24fe /anim/tools
parent64e64c74be6a3e46abeae8a30dd42efff91aaf91 (diff)
downloadcomputeranim-5922ee911b9a6604f60dc83be36ba9e6c9abac98.tar.gz
computeranim-5922ee911b9a6604f60dc83be36ba9e6c9abac98.zip
canim: what the second review found, fixed
A system call stepped over plays in order: the registers set, the crossing from the call row with the kernel's window under it, the stores after rax. A strike covers the bytes that changed. The band's view changes with the argument framing. In the descent a callee sits under its caller's return row, and rows fade before others glide. The heap scene follows the storyboard's nine captions: pushes at a run without marks, each free and the malloc that takes the head back walked, the tcache's loupe over the stack and closed with each advance, a chunk in neither list drawn, the freed node travelling to malloc's row. In the dive the map falls into the corner and becomes the minimap; on the map boxes are as long as their rows. A narrow read is shown at its width. The chart checks captions and one-frame changes. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/tools')
-rw-r--r--anim/tools/chart.py73
1 files changed, 63 insertions, 10 deletions
diff --git a/anim/tools/chart.py b/anim/tools/chart.py
index 998e704..720e356 100644
--- a/anim/tools/chart.py
+++ b/anim/tools/chart.py
@@ -1,13 +1,19 @@
#!/usr/bin/env python3
"""The designer's motion instrument (design/motion/motion.py: timing chart,
-five rule checks, contact sheets), told where canim's panels are now.
+rule checks, contact sheets), told where canim's panels are now and what
+each scene's captions say.
chart.py chart|auto|sheet|onion|track VIDEO ... as motion.py takes them
-The video's file name (fib-1080.mp4 -> fib) picks its regions.
+The video's file name (fib-1080.mp4 -> fib) picks its regions, and its
+captions: the strings `scenes/NAME.zig` says (`says.line`), in order. The
+CAPTION check (motion.py's) gets one more line here: a caption up for less
+than its reading time, 90 f and 3.6 f a character as shown.
"""
-import os, sys
-sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "design", "motion"))
+import os, re, sys
+HERE = os.path.dirname(os.path.abspath(__file__))
+sys.path.insert(0, os.path.join(HERE, "..", "..", "design", "motion"))
+import numpy as np
import motion
W = motion.W
@@ -33,11 +39,11 @@ def split(drawing, view, source, disasm, slots, backtrace=0):
out["backtrace"] = (976, right + ph(17) + 12 + ph(slots) + 12, 880, ph(backtrace))
return out
-# The clock is under the name the instrument gives to words that are not panels ("head"):
-# its progress line moves with every step and must not count as a panel starting. The
-# minimap (1664 to 1856 by 912 to 1020) is in no region: it mirrors the panels' changes,
-# and the instrument has no name for a secondary region.
-words = {"head": (0, 888, 1656, 46), "caption": (0, 934, 1656, 146)}
+# The words that are not panels (motion.WORDS): the clock (its count, ranged right at 1648,
+# changes in a frame by design), the caption (its 1400 from the margin), and the minimap at
+# the caption band's right end, secondary action. The caption's box starts under the clock's count
+# and the run's step counter (912 to 934).
+words = {"clock": (0, 888, 1656, 46), "caption": (0, 940, 1464, 140), "minimap": (1664, 912, 192, 108)}
none, beside, subject = split(0, 0, 14, 17, 8, 4), split(152, 152, 8, 17, 8), split(296, 200, 10, 9, 6)
motion.REGIONS.update({
"fib": {**subject, **words},
@@ -52,7 +58,54 @@ motion.REGIONS.update({
"gallery": {**beside, **words},
})
_regions_for = motion.regions_for
-motion.regions_for = lambda video, name: _regions_for(video, name or os.path.basename(video).split("-")[0].split(".")[0])
+scene = lambda video: os.path.basename(video).split("-")[0].split(".")[0]
+motion.regions_for = lambda video, name: _regions_for(video, name or scene(video))
+
+STRING = r'"((?:[^"\\]|\\.)*)"'
+
+def captions(name):
+ """The scene's captions in the order it says them: each `says.line(s, "...")`, and each
+ string of an array a `for` loop says."""
+ path = os.path.join(HERE, "..", "scenes", name + ".zig")
+ if not os.path.exists(path):
+ return None
+ src = open(path).read()
+ arrays = {m.group(1): re.findall(STRING, m.group(2), re.S) for m in re.finditer(r"const (\w+) = \[_\]\[\]const u8\{(.*?)\};", src, re.S)}
+ out = []
+ for m in re.finditer(r"says\.line\(s, " + STRING + r"\)|for \((\w+)\)", src):
+ if m.group(1) is not None:
+ out.append(m.group(1))
+ elif m.group(2) in arrays:
+ out.extend(arrays[m.group(2)])
+ return out
+
+def shown(text):
+ """Characters as the caption shows them: no backticks, no line break, an escape one."""
+ text = re.sub(r"\\(.)", r"\1", text.replace("\\n", ""))
+ return len(text.replace("`", ""))
+
+_lint = motion.lint
+def lint(names, counts, soft, sizes, fps, ev):
+ out = [line for line in _lint(names, counts, soft, sizes, fps, ev) if line != " none"]
+ said = captions(lint.scene) if lint.scene else None
+ cap = names.index("caption") if "caption" in names else None
+ if said is not None and cap is not None:
+ on = motion.busy(counts, soft)
+ changes = [(a, b) for a, b in motion.runs(on[:, cap]) if b - a >= 3]
+ ends = [c[0] for c in changes[1:]] + [len(on)]
+ # An arrival is a change after which the caption is up longer than the gap between leaving and arriving.
+ arrivals = [(b, nxt - b - 1) for (a, b), nxt in zip(changes, ends) if nxt - b - 1 > 6]
+ if len(arrivals) != len(said):
+ out.append(f" CAPTION ? {len(arrivals)} captions arrive in the video, the scene says {len(said)}: reading times not checked")
+ else:
+ short = [f"{b / fps:.2f} ({up} f of {90 + 3.6 * shown(t):.0f})" for (b, up), t in zip(arrivals, said) if up < 90 + 3.6 * shown(t)]
+ if short:
+ out.append(f" CAPTION {len(short):3d} up under its reading time, 90 f + 3.6 f a character: " + ", ".join(short[:4]) + (" ..." if len(short) > 4 else ""))
+ return out or [" none"]
+motion.lint = lint
+lint.scene = None
if __name__ == "__main__":
+ video = next((a for a in sys.argv[2:] if a.endswith(".mp4")), None)
+ lint.scene = scene(video) if video else None
motion.main() if hasattr(motion, "main") else sys.exit("design/motion/motion.py has no main()")