1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/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.
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.
"""
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "design", "motion"))
import motion
W = motion.W
# The stage (design/README.md, "5. The frame"; theme.layout.split): the lens band across the
# top as two panels, its drawing over the program column and its view over the state column;
# the program column (source over disassembly) and the state column (registers over stack).
# A panel of n rows is 32 + 24 n. The clock is over the caption.
def ph(rows):
return 32 + 24 * rows
def split(drawing, view, source, disasm, slots, backtrace=0):
out = {}
if drawing:
out["drawing"] = (64, 48, 880, drawing)
out["view"] = (976, 48, 880, view)
left = 48 + (drawing + 12 if drawing else 0)
right = 48 + (view + 12 if view else 0)
out["source"] = (64, left, 880, ph(source))
out["disasm"] = (64, left + ph(source) + 12, 880, ph(disasm))
out["registers"] = (976, right, 880, ph(17))
out["stack"] = (976, right + ph(17) + 12, 880, ph(slots))
if backtrace:
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.
words = {"head": (0, 888, W, 46), "caption": (0, 934, W, 146)}
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},
"sort": {**subject, **words},
"syscalls": {**subject, **words},
"list": {**subject, **words},
# The band's drawing is the backtrace, then the kernel's side.
"sqlite": {**subject, **words},
"zoom": {**none, **words},
"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])
if __name__ == "__main__":
motion.main() if hasattr(motion, "main") else sys.exit("design/motion/motion.py has no main()")
|