summaryrefslogtreecommitdiff
path: root/design/mock/map.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 12:49:15 -0300
committerGabriel Schneider <[email protected]>2026-11-11 13:22:07 -0300
commit576a78b4de02c4c6566c327d85c465554d293975 (patch)
treeea9df8139a511768480696712495d62533e048b3 /design/mock/map.py
parent4c7dcadeddaa50fb52fd44a2cc71df1f570e092a (diff)
downloadcomputeranim-576a78b4de02c4c6566c327d85c465554d293975.tar.gz
computeranim-576a78b4de02c4c6566c327d85c465554d293975.zip
design: the overflow as bytes; a minimap in each pane
From the user. In the pair a frame is a dump of eight bytes a row read by its own fields, so each turn of the loop is one more letter and the letters are seen to cross from buf into the saved rbp and the return address, which reads as code until they reach it. Each pane with more than it shows carries its own minimap, a strip of its column of the map at four units a row with the pane's window outlined and what happens off the window marked there; the corner minimap is gone, and in the dive each column of the map folds into its pane's strip. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'design/mock/map.py')
-rw-r--r--design/mock/map.py180
1 files changed, 134 insertions, 46 deletions
diff --git a/design/mock/map.py b/design/mock/map.py
index 1b4287b..65b6c88 100644
--- a/design/mock/map.py
+++ b/design/mock/map.py
@@ -18,8 +18,6 @@ import context as C
from context import (PAGE, RAISED, RULE, VELLUM, BRIGHT, DIM, FAINT, GOLD, VERM, READ, HEAP, STACK, A, S, ROW, TAG,
PAD, MONO, b, ph, tw, mix, Svg, H_)
-MINI = (1664, 912, 192, 108) # the minimap's place in the working frame: x, y, w, h
-K = 1 / 20 # map units to the minimap's
RSP, UNDER = D.RSP, 16 # the map's stack starts 16 words above rsp
ROLES = {0: "saved rbp", 3: "saved rbx", 4: "saved rbp", 26: "saved rbp", 38: "saved rbp", 42: "argc",
43: "argv[0]", 44: "argv end", 45: "envp end", 46: "auxv"}
@@ -87,6 +85,9 @@ def pins(step):
return {0x10040b0: ["rcx"], 0x1004090: ["rax"] + ([] if step else ["rdi"]), 0x1004070: ["rdi"] if step else []}
+COLS = {} # a pane's column on the map: (its parts, its window's first row, rows)
+
+
def draw_map(g, step, loupe, subject=False):
"""The map at one moment. Returns the outlines of the working frame's windows, in map units."""
stage(True)
@@ -100,6 +101,7 @@ def draw_map(g, step, loupe, subject=False):
win["drawing"] = (col[0], 96, D.CW, 296)
ys = C.source(g, 404, 42, D.SRC, 1, 21, [], "list.c", 42)
first = 18 if subject else 19
+ COLS["source"] = ([(col[0], 404 + TAG + PAD, 42)], first - 1, sp["src"])
win["source"] = (col[0], 404 + TAG + PAD + (first - 1) * ROW, D.CW, sp["src"] * ROW)
D.put(col[0])
C.backtrace(g, 1456, ph(5), D.BT, x=col[0], note="newest at the bottom")
@@ -111,12 +113,14 @@ def draw_map(g, step, loupe, subject=False):
D.thread_across(g, ys, [(at[0x1001926], at[0x1001926] + ROW)])
wn = [r[0] for r in D.window(sp["dis"], step)]
win["disasm"] = (col[1], at[wn[0]], D.CW, sp["dis"] * ROW)
+ COLS["disasm"] = ([(col[1], 96 + TAG + PAD, 69)], [r[0] for r in rows].index(wn[0]), sp["dis"])
# C: memory, the registers, a loupe, the stack continued
D.put(col[2])
mem = C.fields(g, 96, ph(14), "the heap, round what the step reads", 0x1004000, 512,
D.heap_fields(0x1004000, 512, 0x1004098), D.MEM, HEAP, D.region, marks=(9,) if step else (),
title="memory", touched={0x1004098} if step else ())
win["view"] = (col[2], mem[0x1004050 if subject else 0x1004070], D.CW, (7 if subject else 5) * ROW)
+ COLS["view"] = ([(col[2], 96 + TAG + PAD, 14)], (win["view"][1] - 96 - TAG - PAD) // ROW, 7 if subject else 5)
C.registers(g, 476, D.regs(step), D.FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"},
"rdi": {0: "strike" if step else "tick"}})
win["registers"] = (col[2], 476, D.CW, ph(17))
@@ -131,6 +135,7 @@ def draw_map(g, step, loupe, subject=False):
D.put(col[3])
C.stack(g, 96, slot_rows(0, 69), frames_from(0, 69), note="from rsp-80", rsp=RSP, roles=roles_from(0, 69))
win["stack"] = (col[3], 96 + TAG + PAD + UNDER * ROW, D.CW, sp["words"] * ROW)
+ COLS["stack"] = ([(col[3], 96 + TAG + PAD, 69), (col[2], y + TAG + PAD, n_c)], UNDER, sp["words"])
D.put(col[2])
C.stack(g, y, slot_rows(69, n_c - 1), frames_from(69, n_c - 1), note="continued", rsp=RSP,
roles=roles_from(69, n_c - 1))
@@ -159,39 +164,58 @@ def key(g, x, y, step):
g.t(xx + 136, b(yy), name, 18, DIM, "sans")
-# ---- the minimap -------------------------------------------------------------------------------------------
-INKED = {GOLD, C.SOFT, VERM, C.WASH, RAISED, D.LIFT, D.LIFT_TAG, READ}
+# ---- a pane's minimap ------------------------------------------------------------------------------------
+MW, MGAP, MR = 40, 8, 4 # its strip: 40 wide, 8 from the content; 4 units a row
+KX = (MW - 4) / D.CW # a row's 880 to the strip's 36: a character two thirds of a unit
-def minimap(g, log, windows, x0, y0, k=K, focus="drawing"):
- """The map at k: every run of text a stroke 1 high in its ink at 45% toward the page; tags, paper and the
- lift as blocks; the marks over them; the working frame's windows outlined, the one in focus 2."""
- W, H = 3840 * k, 2160 * k
- g.rect(x0, y0, W, H, PAGE)
- marks = []
- for e in log:
- if e[0] == "r":
- _, x, y, w, h, fill, stroke = e
- if fill in (GOLD, C.SOFT, VERM) or stroke in (READ, VERM, BRIGHT):
- marks.append(e)
- elif fill in INKED and w * k >= 1:
- g.rect(x0 + x * k, y0 + y * k, max(w * k, 1), max(h * k, 1), mix(fill, PAGE, 0.7 if fill == RAISED else 0.6))
- elif stroke in (RULE, DIM) and w > 200:
- g.frame(x0 + x * k, y0 + y * k, w * k, h * k, mix(RULE, PAGE, 0.8), 1)
- elif e[2] < 2100 and e[5] not in (None, "none"):
- _, x, y, w, size, fill = e
- g.rect(x0 + x * k, y0 + (y - size * 0.62) * k, max(w * k, 0.8), max(size * 0.05, 0.9), mix(fill, PAGE, 0.55))
- for _, x, y, w, h, fill, stroke in marks: # the marks: gold, a strike, a read; at least a pixel and a half
- ink = fill if fill in (GOLD, C.SOFT, VERM) else stroke
- if ink == C.SOFT:
- ink = VERM
- if ink == BRIGHT:
- continue
- g.rect(x0 + x * k, y0 + y * k, max(w * k, 1.5), max(h * k, 1.5), ink)
- for name, (x, y, w, h) in windows.items():
- g.frame(x0 + (x - 4) * k, y0 + (y - 4) * k, (w + 8) * k, (h + 8) * k, BRIGHT if name == focus else VELLUM,
- 1.5 if name == focus else 1)
- g.frame(x0, y0, W, H, RULE, 1)
+def column(log, parts):
+ """A pane's column, from the map's log: for each row, its runs of text as (x from the panel's left, width,
+ ink), and its marks (current, struck, read)."""
+ rows, marks, n0 = {}, {}, 0
+ for x0, y0, n in parts:
+ for e in log:
+ if e[0] == "t":
+ _, x, y, w, size, fill = e
+ r = int((y - 19.2 - y0 + 1) // ROW)
+ if x0 <= x < x0 + D.CW and 0 <= r < n and fill not in (None, "none", PAGE):
+ rows.setdefault(n0 + r, []).append((x - x0, w, fill))
+ else:
+ _, x, y, w, h, fill, stroke = e
+ r = int((y + h / 2 - y0) // ROW)
+ if not (x0 <= x < x0 + D.CW and 0 <= r < n):
+ continue
+ kind = ("current" if fill in (GOLD, C.WASH) and w >= 20 and h >= 20 else
+ "struck" if fill in (C.SOFT, VERM) else "read" if stroke == READ else None)
+ if kind:
+ marks.setdefault(n0 + r, set()).add(kind)
+ n0 += n
+ return rows, marks, n0
+
+
+def pane_minimap(g, log, name, x, y, h):
+ """A pane's minimap: its whole column of the map, a row 4 units, in the strip at the pane's right (x, y, 40 by
+ h). Each run of text a stroke 3 high in its ink 65% of the way from the page; the marks at the row's left: the current
+ row gold, a strike vermilion, a read in read's colour; the pane's window framed 2 in `dim`. A column longer
+ than the strip shows the rows round the window, and three dots at the end where it goes on."""
+ parts, w0, wn = COLS[name]
+ rows, marks, total = column(log, parts)
+ g.rect(x, y, MW, h, C.WELL)
+ cap = int((h - 6) // MR)
+ first = 0 if total <= cap else min(max(w0 + wn // 2 - cap // 2, 0), total - cap)
+ top = y + 3
+ for r in range(first, min(first + cap, total)):
+ ry = top + (r - first) * MR
+ for rx, rw, ink in rows.get(r, []):
+ g.rect(x + 2 + rx * KX, ry, max(rw * KX, 1), 3, mix(ink, PAGE, 0.65))
+ for k, kind in enumerate(sorted(marks.get(r, ()), key=["current", "struck", "read"].index)):
+ g.rect(x + 2 + 5 * k, ry - 0.5, 4, 4, {"current": GOLD, "struck": VERM, "read": READ}[kind])
+ g.frame(x, top + (w0 - first) * MR - 3, MW, wn * MR + 5, VELLUM, 2) # the pane's window
+ for end, more in (("top", first > 0), ("foot", first + cap < total)):
+ if more:
+ yy = y + 1 if end == "top" else y + h - 3
+ for d in range(3):
+ g.rect(x + MW / 2 - 7 + d * 6, yy, 2, 2, FAINT)
def map_log(step, loupe, subject=False):
@@ -209,7 +233,13 @@ SUBJECT_VIEW = [5, 6, 7, 8, 9, 10, 11]
def clock(g, moment, total):
g.rect(64, 899, 1792, 2, RULE)
g.rect(64, 898, 1792 * moment / total, 4, GOLD)
- g.t(MINI[0] - 16, 934, "moment %d of %d" % (moment, total), S, FAINT, MONO, "end")
+ g.t(1856, 934, "moment %d of %d" % (moment, total), S, FAINT, MONO, "end")
+
+
+def strip(on):
+ """Panes with a minimap: their content 48 narrower, their frame whole (context.tag)."""
+ C.CW, C.MINIMAP = (D.CW - MW - MGAP, MW + MGAP) if on else (D.CW, 0)
+ C.DX_NOTE = 540 if on else 564 # the annotation starts 24 sooner, so its room loses only 24
def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None):
@@ -225,6 +255,7 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None):
y = 48 + sp["band"] + 12
c = open_("source")
+ strip(True)
D.put(64)
ys = C.source(g, y, sp["src"], D.SRC, 18 if subject else 19, 21, [], "list.c", 42)
g.o.append(c) if c else None
@@ -234,10 +265,12 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None):
out["thread"] = (ys, at[0x1001926])
yr = 48 + sp["view"] + 12
c = open_("registers")
+ strip(False)
D.put(976)
out["regs"] = C.registers(g, yr, D.regs(step), D.FLAGS, {"rax": {0: "tick"}, "rcx": {0: "tick"},
"rdi": {0: "strike" if step else "tick"}})
g.o.append(c) if c else None
+ strip(True)
c = open_("stack")
n = sp["words"]
C.stack(g, yr + ph(17) + 12, slot_rows(UNDER, n), frames_from(UNDER, n), rsp=RSP, roles=roles_from(UNDER, n))
@@ -248,7 +281,10 @@ def working_panels(g, step, subject, wrap=lambda name: ("", ""), withhold=None):
marks=(9,) if step else (), rows_shown=SUBJECT_VIEW if subject else BESIDE_VIEW, more_rows=False,
touched={0x1004098} if step else (), withhold=withhold)
g.o.append(c) if c else None
+ strip(False)
out["view"] = view
+ out["boxes"] = {"source": (64, y, ph(sp["src"])), "disasm": (64, y + ph(sp["src"]) + 12, ph(sp["dis"])),
+ "stack": (976, yr + ph(17) + 12, ph(n)), "view": (976, 48, sp["view"])}
return out, sp
@@ -272,12 +308,19 @@ def working(name, step, subject=False, loupe=False, caption=None):
D.loupe(g, lx, ly, [("rdi", DIM), (" → ", FAINT), ("1004070", HEAP)], "heap · struct node, 16 bytes",
0x1004050, D.heap_fields(0x1004050, 80), [(0x1004070 - 0x1004050, 16)], 1, rows=5)
g.rect(hop - 2, ry + ROW - 3, 7 * A + 4, 4, HEAP) # the stem, short: a bracket under the pointer's digits, on the tag
- minimap(g, m.log, win, *MINI[:2], focus="loupe" if loupe else "drawing")
+ minimaps(g, m.log, out["boxes"])
clock(g, 3 if step else 2, 4)
gen.caption(g, caption)
g.save(name)
+def minimaps(g, log, boxes, skip=()):
+ """Each pane's minimap, in the strip its frame keeps at its right, over its body."""
+ for name, (x, y, h) in boxes.items():
+ if name not in skip:
+ pane_minimap(g, log, name, x + D.CW - 2 - MW, y + TAG, h - TAG - 2)
+
+
# ---- the dive: the map coming in to the working frame, four instants -------------------------------------
def glide(t):
"""The glide curve (0.45, 0, 0.55, 1), solved for t."""
@@ -294,15 +337,17 @@ FRAME_RECT = {"source": (64, 212, 880, ph(8)), "disasm": (64, 448, 880, ph(17)),
def dive(name, e, veil, outline, fade_frame):
- """One instant of `dive`: e, the move's progress (glide applied), veil on the map, the windows' outline, how
- far the working frame's own tags and minimap have come in."""
+ """One instant of `dive`: e, the move's progress (glide applied); veil, on the map; outline, the windows' bright
+ frames; fade_frame, how far the working frame's tags and minimaps have come in. Each window travels to its
+ pane's place, its scale from the map's half to whole on its logarithm; each pane's column, the rest of what
+ the map holds of it, squeezes into the pane's minimap strip on the same move; the rest of the map fades."""
m, win = map_log(False, False)
- body = m.o[1:] # the map's drawing, its page and all, without its svg head
+ body = m.o[1:-1] if m.o[-1] == "</svg>" else m.o[1:]
stage(False)
g = Svg()
- sm = 0.5 ** (1 - e) * K ** e # the map: from filling the frame to the minimap, on the log of its scale
- tx, ty = MINI[0] * e, MINI[1] * e
- g.o.append('<g transform="translate(%.2f,%.2f) scale(%.4f)">' % (tx, ty, sm))
+ clips = []
+ # the map's parts no pane takes: faded in place as the move goes
+ g.o.append('<g opacity="%.2f" transform="scale(0.5)">' % (1 - e))
g.o += body
if veil:
g.o.append('<rect width="3840" height="2160" fill="%s" opacity="%.2f"/>' % (PAGE, veil))
@@ -311,7 +356,29 @@ def dive(name, e, veil, outline, fade_frame):
g.o.append('<rect x="%.1f" y="%.1f" width="%.1f" height="%.1f" fill="none" stroke="%s" stroke-width="%.1f"/>'
% (x - 4, y - 4, w + 8, h + 8, BRIGHT, 2 + outline * 2))
g.o.append("</g>")
- # each window: the working panel, from its place on the map to its own, its scale on a logarithm
+ out, sp = working_panels(Svg(), False, False) # where the panes and their strips will be
+ if 0 < e < 1: # each column squeezing into its strip: a row from 24 units to 3
+ for nm, (bx, by, bh) in out["boxes"].items():
+ parts, w0, wn = COLS[nm]
+ sx0, sy0 = bx + D.CW - 2 - MW + 2, by + TAG + 3
+ cap = int((bh - TAG - 2 - 6) // MR)
+ total = sum(p[2] for p in parts)
+ first = 0 if total <= cap else min(max(w0 + wn // 2 - cap // 2, 0), total - cap)
+ n0 = 0
+ for k, (mx, my, n) in enumerate(parts):
+ kx, ky = 0.5 ** (1 - e) * KX ** e, 0.5 ** (1 - e) * (MR / ROW) ** e # on their logarithms
+ tx = mx * 0.5 * (1 - e) + sx0 * e
+ ty = my * 0.5 * (1 - e) + (sy0 + (n0 - first) * MR) * e
+ cid = "c%s%d" % (nm, k)
+ clips.append('<clipPath id="%s"><rect x="%d" y="%d" width="%d" height="%d"/></clipPath>'
+ % (cid, mx, my, D.CW, n * ROW))
+ g.o.append('<g opacity="%.2f" transform="translate(%.2f,%.2f) scale(%.4f,%.4f) translate(%d,%d)">'
+ % (0.5 + 0.5 * e, tx, ty, kx, ky, -mx, -my))
+ g.o.append('<g clip-path="url(#%s)">' % cid)
+ g.o += body
+ g.o.append("</g></g>")
+ n0 += n
+ g.o.insert(1, "<defs>" + "".join(clips) + "</defs>")
map_rect = {"source": win["source"], "disasm": win["disasm"], "registers": win["registers"], "stack": win["stack"],
"view": win["view"], "drawing": win["drawing"]}
@@ -320,8 +387,6 @@ def dive(name, e, veil, outline, fade_frame):
return "", ""
fx, fy, fw, fh = FRAME_RECT[nm]
mx, my, mw, mh = map_rect[nm]
- # at e = 0 the panel's first row lies on its window's first row on the map, both at half size; at e = 1
- # the panel is at its own place and size. Scale on its logarithm, the offset with the move.
row0 = fy if nm in ("registers", "drawing") else fy + TAG + PAD
sw = 0.5 ** (1 - e)
ox, oy = (mx - fx) * 0.5 * (1 - e), (my - row0) * 0.5 * (1 - e)
@@ -338,7 +403,7 @@ def dive(name, e, veil, outline, fade_frame):
g.o.append(c)
if fade_frame > 0:
g.o.append('<g opacity="%.2f">' % fade_frame)
- minimap(g, m.log, win, *MINI[:2])
+ minimaps(g, m.log, out["boxes"])
clock(g, 2, 4)
g.o.append("</g>")
gen.caption(g, [[("Stopped in ",), ("reverse", "mono"), (", about to load ",), ("head->next", "mono"), (".",)],
@@ -363,6 +428,28 @@ def sheet(names, out, labels):
s.save(out)
+def crop_sheet(src, out):
+ """Mock 39: three panes' right ends from a working frame, at 1:1 (a 1080p pixel a unit), with what each minimap
+ lets a viewer read named under it."""
+ im = Image.open(src).convert("RGB")
+ crops = [((800, 448, 944, 888), (24, 64), "the disassembly", ["69 rows: the function whole", "and its neighbours; the pc",
+ "gold, a read cyan; the", "window of 17 rows framed"]),
+ ((1640, 40, 1860, 200), (380, 64), "its bytes", ["the heap's 14 rows on the map;", "the 5 shown framed; the read row"]),
+ ((1640, 660, 1860, 888), (380, 360), "the stack", ["48 of its 103 rows, round the", "window; three dots: it goes on"])]
+ s = Image.new("RGB", (720, 700), "#0a1030")
+ d = ImageDraw.Draw(s)
+ head = ImageFont.truetype("/usr/share/fonts/go/Go-Medium.ttf", 22)
+ body = ImageFont.truetype("/usr/share/fonts/go/Go-Regular.ttf", 18)
+ d.text((24, 18), "each pane's minimap at 1:1, a pixel of 1080p a unit", font=head, fill="#eee6d2")
+ for box, (x, y), name, lines in crops:
+ c = im.crop(box)
+ s.paste(c, (x, y))
+ d.text((x, y + c.height + 10), name, font=head, fill="#eee6d2")
+ for k, t in enumerate(lines):
+ d.text((x, y + c.height + 40 + 24 * k), t, font=body, fill="#9aa6d9")
+ s.save(out)
+
+
if __name__ == "__main__":
import os
stage(True)
@@ -381,7 +468,8 @@ if __name__ == "__main__":
working("11-context-lens", True, subject=True, caption=cap10)
working("21-loupe", True, loupe=True,
caption=[[("rdi", "mono"), (" holds ",), ("1004070", "mono"), ("; under it opens the heap round that node.",)],
- [("The minimap shows the same loupe at its place on the map.",)]])
+ [("Each pane's minimap shows where its rows are in the whole.",)]])
+ crop_sheet("10-context-step.png", "39-minimap-1to1.png")
names = ["20a", "20b", "20c", "20d"]
dive("20a", 0, 0, 0, 0)
dive("20b", 0, 0.5, 1, 0)