<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sketchbook.git/examples/live/test/live.script, branch main</title>
<subtitle>A small Zig platform for sketching games and toys</subtitle>
<id>https://git.0x4200.cafe/sketchbook.git/atom?h=main</id>
<link rel='self' href='https://git.0x4200.cafe/sketchbook.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/'/>
<updated>2026-11-17T15:15:01Z</updated>
<entry>
<title>examples/live: the README's editor lines, and a press the larger name moved</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:38:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=aecc0e8e8979f9afb5cadb7e509bb0cd9b211d0a'/>
<id>urn:sha1:aecc0e8e8979f9afb5cadb7e509bb0cd9b211d0a</id>
<content type='text'>
The README says the grammar also sizes the name each line defines (its
query's `(definition name: (name))`, 1.2 times the rest), that the code
is one sketchbook paragraph whose ranges, carets and marks sit where
sk.text.places lays their bytes out, the press found by the same places,
that the canvas is the window's pixels and the picture at most 720 rows
scaled to it. test/live.script presses where 220 began when every
character was 10 pixels, now the space before it: nothing drags (with
the press at 190 it does, and the script fails).

zig build test: 92 of 92 steps.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: the name a line defines a step larger, by its syntax node</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:34:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=ae807468f15e81ea3b62fee4741ee6b246e6df8b'/>
<id>urn:sha1:ae807468f15e81ea3b62fee4741ee6b246e6df8b</id>
<content type='text'>
`paragraph` gives a span the scale 1.25 * 1.2 (`step`, 19.5 px against
16.25) where the grammar's class is the one queries/highlights.scm gives
a definition's name node, `(definition name: (name) @keyword)`, and that
node alone: chosen from the tree, not from the text's shape. The names
are 12 pixels a character to the rest's 10, and a line with one is 26
high to 22. Everything of the last change lands on the mixed sizes, as
everything is placed by sk.text.places: ranges, the carets, the
problem's mark, the band, and the press that finds a number to drag.

The scripts follow the layout: 220 on line 1 is now at x 182 to 212
(after the larger `out`), so the drags in test/live.script and
test/story.script press at 187 instead of 181, every move 6 pixels on;
the values they expect are the same.

zig build test: 92 of 92 steps.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: square units, x and y from the centre in half the height</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T10:59:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=fb237529724ae1c01b15f99e3b25bdce7c77cf82'/>
<id>urn:sha1:fb237529724ae1c01b15f99e3b25bdce7c77cf82</id>
<content type='text'>
picture.frag gives the tape x and y in half the target's height, 0 at
its centre and y up (`y` -1 to 1, `x` -1.78 to 1.78 on 16:9), so a
circle is round on any window, half resolution included. Lang.builtins
and the README's table say so; the README's program draws its ring
about the centre (`r = sqrt(x * x + y * y)`, the ring's radius and width
doubled into the new unit).

Test: test/live.script replaces the text (`%`, `c`) with a disc of
radius 0.5, `step(x * x + y * y, 0.25)`, and reads its edge 180 pixels
from the centre across and up: white at 170, black at 190, each way.
zig build test: 85 of 85 steps.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: drag a number, the program following as it moves</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T10:58:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=4350e6840940da0b7af800faf5a1455a1de1908e'/>
<id>urn:sha1:4350e6840940da0b7af800faf5a1455a1de1908e</id>
<content type='text'>
The left button pressed on a number token (the grammar's `number` node
at the byte under the pointer, found with the module's parse) starts a
drag kept in State: the literal's bytes, the value, its precision. Each
pointer move rewrites the literal through the editor's `replace`: a step
for every 4 pixels right of where it was pressed (left, down), the step
from the literal's own precision (`220` by ones, `0.25` by hundredths),
printed with as many decimals. The first rewrite is a step to undo and
the rest join it, so one `u` takes the whole drag back. The text changes,
so the program is compiled and heard as it moves. A literal with an
exponent is not dragged (marked ponytail).

`update` finds the byte under the pointer as `code` lays the text out: a
character is 10 by 22 pixels, measured once (the code face at 1.25,
natively: ten M are 100) and now a constant both use, where `code` asked
the host each frame.

Test: test/live.script presses 220, drags 40 pixels right (230), back to
12 left of the press (217), lets go and undoes the drag in one step
(220). zig build test: 85 of 85 steps.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: hear this, the expression a node walk leaves the selection on</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T10:57:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=610ffe373f0f5dd5ccb59bf575f5479ad1ecdbaf'/>
<id>urn:sha1:610ffe373f0f5dd5ccb59bf575f5479ad1ecdbaf</id>
<content type='text'>
After Alt-o, Alt-i, Alt-n or Alt-p (helix's node walks, run in the
editor on the module's parse) the primary range is read back and the
text compiled again with it as a probe: Lang.compile takes the bytes of
a selection and compiles the smallest expression holding them into a
third tape, `Program.probe`. The compiler learns each expression's bytes
as it parses (`spanned`: a number, a name used, a call, parentheses, a
unary minus, each binary operation, a whole line), keeping the smallest
that holds the probe: no table of spans. A name used is the line that
defines it, so a walk onto `kick` hears kick.

State keeps the probe's tape (`probe`, empty when there is none). While
it is set, `draw` hears it as `out` (through the crossfade, as any
change) and sees it as the picture, grey unless it is a colour. Any
other key empties it, so Escape or an edit goes back to the program. It
is in State, so a replay probes where the session did.

Test: Lang.zig, a probe on an argument, a number, a cursor on one of its
digits, a name used, a line's name, a selection Alt-o grew to, and
between two lines (none); test/live.script, Alt-o twice from the 2 of
220 (`220`, then `tau * 220`), then Escape. Lang.compile takes the probe
as a second argument; the other calls pass null. zig build test: 85 of
85 steps, 8 of 8 tests.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: pardes's editor in State, typed with helix's keys</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T10:42:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=ed185f305731309cbddb981166678a552f2fda84'/>
<id>urn:sha1:ed185f305731309cbddb981166678a552f2fda84</id>
<content type='text'>
The plain buffer of part 1 gives way to pardes's text pane as a library
(`pardes-editor`, src/lib_editor.zig there): `Editor(.{ .text = 4096,
.undo = 16 KiB, .registers = 1024, .selections = 64 })`, a value of plain
data, 39,264 bytes of a State of 43,480. The package takes pardes by path
(`../../../02-pardes-code`, the checkout beside sketchbook's) with
`.editor = true` and its smallest tree-sitter set; sketchbook is spelled
`../../../sketchbook` as pardes spells it, since a package is told by its
path's spelling and sketchbook's build.zig cannot be two modules.

`update` turns events into keys: printables from `text` events only,
specials (Escape, Return, Backspace, Tab, arrows, Home, End, pages,
Delete) and ctrl or alt chords (helix's `A-I` an upper-case letter) from
`key_down`, a chord's letter dropped if it also comes as text. Each call
into the editor thaws the value into a static 128 KiB buffer reset for
the call (`update` may not allocate from the host; a key at 4 KiB of text
took 29 KiB of it). The text is compiled when the editor's `revision`
moves.

Measured (a scratch bench through `update`, the survey's program, 646
bytes, a key typed into its middle, 400 times): a typed key, edit and
compile, 59.5 us best and 78.8 mean in Debug, 7.4 and 7.8 in
ReleaseFast; a motion 6.4 and 0.3. The package's cold `zig build lib`
went from 3.1 s to 6.6 s, its first build under `--watch -fincremental`
from 4.0 to 5.9 s, and an edit of main.zig rebuilt under it from
0.062-0.067 s to 0.067-0.092 s.

Test: test/live.script types through helix now (`i`, the text, Escape,
`gl`, `h`, `rx` for the edit, `l` `d` to break the line, `u` to mend it)
and still replays to equal text, tapes and screenshots, its seeks moved
to the marks' new times. zig build test: 81 of 81 steps, 6 of 6 tests.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: the scripted proof, a session played back and sought</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T09:10:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=8dc369f343fda8f54756376728f4690386c20a69'/>
<id>urn:sha1:8dc369f343fda8f54756376728f4690386c20a69</id>
<content type='text'>
test/live.script now ends with the run's own session replayed: `play
session 0` from its start, then `seek` to the two moments marked as they
happened (the gradient just typed, and the end after an edit, a broken
line and its mend). At each, the State equals the mark leaf by leaf
(`expect-snapshot`: the text, both tapes, the problem, the time), and at
the first the screenshot equals the live one over the text and the
picture (0,0 1000x600, without the scope and the status line). `stop`
then goes on live from that moment: the typed program, before its edit.

What a script could not do: a `record` clip ends at the first mark
(Console.zig's `save` stops it), so the clip cannot be marked while it
is made: the session is replayed instead. A mark is State before its
frame's tick, so its time is the printed time less a frame, and `seek
MS` lands on the last frame at or before MS: the script seeks 5 ms past
each mark's time (272 and 488).

The sound at a jump: `want` counted the queue the clear is about to
drop, so a seek starved the device for a frame; now it counts from
empty. And the block after a jump crosses from the old tape at where the
device was (the clock less what was queued) to the tape at the new time
(Synth.old_start). Not measured: a capture records every block made,
including the tail the jump drops, so it cannot show what was heard
across a seek.

zig build test: 68 of 68 steps, 6 of 6 tests.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: the sound, the out tape on the GPU per sample</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T09:05:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=a4d1e3131499c17bd6f73e65154aa0c2b31c62b3'/>
<id>urn:sha1:a4d1e3131499c17bd6f73e65154aa0c2b31c62b3</id>
<content type='text'>
`pub const audio_pull = 256`; each frame `draw` runs synth.comp over as
many samples as keep the host's lead queued (`in.lead -| queued`, 8192
at most) and streams the block with f.audioBuffer, as spheres does. Time
is a sample clock in Session: set from State's time at every jump (a
seek, a step, a replay's start; the queue is dropped then, so the jump is
heard at once), and free-running otherwise, so a paused replay keeps
sounding its moment. When the out tape differs from the one the last
block played, the block crosses from the old tape to the new over its
length (`set crossfade false` turns that off, to hear what it saves).
The blocks are read back for the scope (an oscilloscope and a spectrum
along the bottom) and, after the console's `capture`, appended to the
sketch's capture.f32 beside its save. The status line shows the lead.

The tapes reach synth.comp in a storage buffer, uploaded per block: two
tapes are 4 KiB, and SDL_GPU's Vulkan backend binds a uniform block 4
KiB at a time (MAX_UBO_SECTION_SIZE), so a 4128-byte Synth block read its
count as 0 past the cut and the kernel wrote nothing, silently: the
probe's first synth numbers timed that. Measured again (RTX 3050, Debug
host, two runs): every synth dispatch 0.08-0.14 ms, 60 or 128
instructions, 256 or 1024 samples, fading or not, the empty pass's cost
alone; the 4 KiB upload 0.07-0.08.

Measured on SDL's dummy driver (nothing audible) from captures:
out = 0.3 * sin(t * tau * 220): peak 0.3000, RMS 0.2121, fundamental
220.000 Hz; edited to 330 in one keystroke, 330.000 Hz. The largest
sample-to-sample step across the edit: 0.0131 with the crossfade (a
330 Hz sine's own steepest step is 0.0130), 0.3725 without; into the
first sound, 0.0011 and 0.2967. The survey's program: peak 0.50, RMS
0.16, its bass at 55.0 Hz.

Test: live.script also expects the stream to receive the GPU's blocks,
and compares screenshots above the scope. zig build test: 68 of 68 steps.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>examples/live: the picture, typed over itself</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T09:03:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=c300a059850115a87a34456dfd60ac97c4a09890'/>
<id>urn:sha1:c300a059850115a87a34456dfd60ac97c4a09890</id>
<content type='text'>
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 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
</feed>
