diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 06:03:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | c300a059850115a87a34456dfd60ac97c4a09890 (patch) | |
| tree | c058035ba628771aafefdcca9ba96bbe43276fa1 /examples/live/test | |
| parent | e7679f416daeee551e81a592c7fe06b8d8f7b705 (diff) | |
| download | sketchbook-c300a059850115a87a34456dfd60ac97c4a09890.tar.gz sketchbook-c300a059850115a87a34456dfd60ac97c4a09890.zip | |
examples/live: the picture, typed over itself
The sketch: State holds the text (a plain 4 KiB buffer, typed characters
appended, backspace deleting the last, return a newline: marked ponytail,
the place pardes's editor takes in part 2), the last good out and color
tapes, the problem and the time, summed from recorded ticks. `update`
compiles the text at every keystroke; a program that parses replaces the
tapes and clears the problem, one that does not sets the problem and
changes nothing else, so the last good picture stays.
`draw` runs picture.frag over the color tape into an image the size of
the canvas, 1280x720, or half of it when the tape is longer than 64
instructions (the probe: 128 took 2.7 ms at full size, 0.85 at half),
and scales it up. The text is drawn over it on a dark band with the
library's text calls (the code face at 1.25, a column a fixed advance),
the caret at the end, the problem as a red mark under its byte and its
words under the text, and live/recording/replay/paused with the time in
a corner.
Test: test/live.script, the start of the scripted proof: a tone typed
(its eight instructions asserted), a gradient (hsv over x and y, four),
an edit (y to x: three, the picture different), a broken line (the
problem at byte 52, the tape and the picture the same) and its mend.
zig build test: 56 of 56 steps, 6 of 6 tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'examples/live/test')
| -rw-r--r-- | examples/live/test/live.script | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/live/test/live.script b/examples/live/test/live.script new file mode 100644 index 0000000..386ab33 --- /dev/null +++ b/examples/live/test/live.script @@ -0,0 +1,37 @@ +# A program typed, its tapes after each line, a broken line and its mend. +# Screenshots land in .zig-cache/live/ for review. +frames 2 +type out = sin(tau * 220 * t) * 0.3 +expect problem.len 0 +expect out.len 8 +expect out.code[5].op sin +expect out.code[7].op mul +key return +type color = hsv(x, 0.5, y) +expect color.len 4 +expect color.code[0].op x +expect color.code[3].op hsv +frames 2 +screenshot .zig-cache/live/gradient.png +# An edit: y becomes x, and the picture changes. +key backspace +key backspace +type x) +expect color.len 3 +expect color.code[2].op hsv +expect color.code[2].c 0 +frames 2 +screenshot .zig-cache/live/edited.png +expect-different-screenshot .zig-cache/live/gradient.png .zig-cache/live/edited.png 640 300 600 380 +# Broken: the tape and the picture stay, the problem is set at its byte. +key backspace +expect problem.at 52 +expect color.len 3 +expect color.code[2].c 0 +frames 2 +screenshot .zig-cache/live/broken.png +expect-same-screenshot .zig-cache/live/edited.png .zig-cache/live/broken.png 0 640 300 600 380 +# Mended. +type ) +expect problem.len 0 +expect color.len 3 |
