diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 01:10:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 9d10fc880bf4e62f8421d351ce15bddeec075322 (patch) | |
| tree | c452f42bb3c6fa94033eff9fad9851106f2a024c /test | |
| parent | d302e4887c4c3fa534fec73a2141d3dc78436ccd (diff) | |
| download | sketchbook-9d10fc880bf4e62f8421d351ce15bddeec075322.tar.gz sketchbook-9d10fc880bf4e62f8421d351ce15bddeec075322.zip | |
examples: manual, Figure 2-1 of the Intel SDM comes alive, as a talk
examples/manual.zig is a live scene with pauses, played by the stock
player: page 31 of the SDM's Vol. 2 (Typst's import of the PDF, every
glyph a shape) fades in on paper beside a title; the camera closes on
Figure 2-1, the instruction format, while the rest of the page greys
and its footnotes go; each field (Prefixes, Opcode, ModR/M, SIB,
Displacement, Immediate) is tinted and glows in turn; 83 C0 01, add
eax, 1, is written below; each byte flies into its field as the fields
it has none for fade; C0 morphs down the arrow into the ModR/M byte's
boxes as 11000000, which splits into 11, 000 and 000 over Mod, Reg and
R/M, each with what it says (direct, /0 ADD, EAX); and the camera goes
back to the page, filled in. Twelve steps, 18 s played straight.
The labels, the ModR/M boxes, the figure and its footnotes are parts of
the page, by rectangles in the page's units read off pdftotext -bbox
(points to units: (pt - 306) * 4/3, (pt - 396) * 4/3) and checked with
the guides; each tint is the s.rect of its label's rectangle. The bits
are parts of a Typst object, cut by character (0.6 em of DejaVu Sans
Mono at 14 pt).
The PDF is never committed. build.zig's -Dmanual names it, by default
~/01-resources/intel-devref-ii.pdf; when the file is not there the
scene is one line saying how to build with it. zig build manual plays
it in a window. test/manual.script, run by zig build test (and
test-manual) only when the file is there, steps through the talk with
pixel checks (the paper, a tint where it should be and not where it
should not, a step back) and exports it twice at 10 fps, the same
frames both times.
zig build bench also times the manual's page (its one #image source,
when the build has the PDF), with a budget of its own for a drawing of
over 1000 shapes: parse under 25 ms, CPU draw under 10, GPU record under
4, at 1280x720. Measured: 6.4, 1.9 and 0.77 ms on a quiet run; 14.8, 3.5
and 1.4 at load average 34; once 28.6 ms to parse, at that load, which
failed it (the simple objects' 1 ms is as sensitive: 0.87 ms then). The
manual's simple objects are not benched: a two-glyph 83 fitted to the
whole canvas takes 1.1-1.2 ms on the CPU.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/manual.script | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/manual.script b/test/manual.script new file mode 100644 index 0000000..3bc3c73 --- /dev/null +++ b/test/manual.script @@ -0,0 +1,73 @@ +# The manual example (examples/manual.zig) on Vol. 2 of the Intel SDM: +# Figure 2-1 stepped through in the stock player, and exported twice. +# Built only when the PDF is there (-Dmanual). +frames 150 +expect deck.waiting true +expect deck.log.len 0 +screenshot .zig-cache/manual/page.png +# The page on its paper, the whole of it in view. +expect-pixel .zig-cache/manual/page.png 400 650 255 255 255 255 2 +# Onto the figure; the rest of the page greys. +key space +await deck.waiting true +screenshot .zig-cache/manual/figure.png +expect-pixel .zig-cache/manual/figure.png 460 160 255 255 255 255 2 +# Each field in turn, tinted: the third is ModR/M. +key space +await deck.waiting true +key space +await deck.waiting true +key space +await deck.waiting true +expect deck.log.len 4 +screenshot .zig-cache/manual/modrm.png +expect-pixel .zig-cache/manual/modrm.png 460 160 192 233 242 255 3 +expect-pixel .zig-cache/manual/modrm.png 300 160 255 255 255 255 2 +# Back a step: Opcode's tint again, ModR/M's gone. +key page_up +expect deck.log.len 3 +frames 2 +screenshot .zig-cache/manual/opcode.png +expect-pixel .zig-cache/manual/opcode.png 460 160 255 255 255 255 2 +expect-pixel .zig-cache/manual/opcode.png 300 160 192 233 242 255 3 +key space +await deck.waiting true +key space +await deck.waiting true +key space +await deck.waiting true +key space +await deck.waiting true +# 83 C0 01 written below, where the footnotes were. +key space +await deck.waiting true +screenshot .zig-cache/manual/bytes.png +# Into their fields: ModR/M's label gives way to C0. +key space +await deck.waiting true +screenshot .zig-cache/manual/flown.png +expect-different-screenshot .zig-cache/manual/bytes.png .zig-cache/manual/flown.png 440 140 180 90 +# C0 down into its boxes as bits, then split over Mod, Reg and R/M. +key space +await deck.waiting true +screenshot .zig-cache/manual/bits.png +expect-pixel .zig-cache/manual/bits.png 527 185 255 255 255 255 2 +key space +await deck.waiting true +screenshot .zig-cache/manual/split.png +expect-different-screenshot .zig-cache/manual/bits.png .zig-cache/manual/split.png 280 420 310 70 +expect deck.log.len 11 +# Back to the page, filled in, and the end of the talk. +key space +frames 120 +expect deck.log.len 12 +expect deck.waiting false +screenshot .zig-cache/manual/end.png +expect-different-screenshot .zig-cache/manual/page.png .zig-cache/manual/end.png 470 260 340 120 +# Exported ({a}, {b}: 10 fps, half size), each step held 1.5 s: the same +# frames twice, and the talk moves through them. +expect-same-screenshot {a}/000040.png {b}/000040.png +expect-same-screenshot {a}/000200.png {b}/000200.png +expect-same-screenshot {a}/000340.png {b}/000340.png +expect-different-screenshot {a}/000040.png {a}/000200.png +expect-different-screenshot {a}/000200.png {a}/000340.png |
