<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sketchbook.git/examples/live, 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: each byte's place is laid out when the text moves, not every frame: the places and their layout are kept in the Session beside the revision they were made at, and made again at a jump (a revision counts keys, it does not name a text); with the text library optimised, drawing the code in a Debug host goes from 2.85 ms to 0.38 ms a frame at the storyboard's 320 bytes and from 28 ms to 5.3 ms at 3.5 KiB; zig build test 92/92 steps</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:56:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=b52da82a9405ac4c9f1c18e2ef53594d5c1f6721'/>
<id>urn:sha1:b52da82a9405ac4c9f1c18e2ef53594d5c1f6721</id>
<content type='text'>
Co-Authored-By: Claude Fable 5.2 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<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 canvas is the window's pixels, so the code is sharp</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:35:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=3373059db38e3b0bbf6105e91180300a4f1c6ead'/>
<id>urn:sha1:3373059db38e3b0bbf6105e91180300a4f1c6ead</id>
<content type='text'>
With a GPU the canvas is an offscreen texture at canvas pixels, which
the host scales (linearly) to the window: the demo's fixed 1280x720 in a
larger window drew its code at 16 px and showed it blurred. `draw` sets
the canvas to the room the host has (`window_width`/`height`, at least
640x360), so a glyph lands on a whole pixel of the display at any window
size, and lays out by it: the picture fills it, the scope sits at its
bottom, the mode and time at its right. The picture is drawn at most 720
rows high (half that past 64 instructions, as before) and scaled up, so
a large window costs the GPU what 1280x720 did; square units hold, as
its width follows the room's aspect.

Headless the room is the canvas unless `--size` gives one, so every test
picture is the one before, pixel for pixel. The display here is a 3840x2160
screen at scale 1, where this is all device-sharp needs; at a density of
2 the window is not asked for its pixels (SDL_WINDOW_HIGH_PIXEL_DENSITY),
so the compositor scales it: a change to the host, not to the demo.

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: the code drawn as a paragraph, every place measured</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:32:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=ccdb7e478248fcf8489eb8a6f9b58178107a26f5'/>
<id>urn:sha1:ccdb7e478248fcf8489eb8a6f9b58178107a26f5</id>
<content type='text'>
`code` draws the editor's text with one f.paragraph: the code face at
1.25, a span in its class's ink where the grammar's class changes
(`paragraph`, which `update` calls too). Every range, the caret and the
problem's mark are boxes from sk.text.places, one layout of the same
paragraph: a byte's box runs from its place to the next byte's on its
line (a `\n` and the end a space wide), a range a box a line it covers.
The band is the layout's size. The constant 10x22 cell goes: `update`
finds the byte under a press with the same places (the last byte whose
line holds the pointer's y and whose x is at or left of it), then the
number token there by the grammar's parse, as before.

The pictures do not move: at this face and size the measured advance is
10 and the line 22, so every storyboard beat's code band is the part 2
picture's, pixel for pixel (0 of 960x600 differ in each of 11 beats;
only the scope and the lead in the corner, which vary run to run, do).

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 README, the editor's keys, hear this, the drag, scrubbing</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T11:07:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=abe2962264d590a6f54d64434222cd4b10b62160'/>
<id>urn:sha1:abe2962264d590a6f54d64434222cd4b10b62160</id>
<content type='text'>
The README says the text is pardes's editor and what it needs (pardes
beside sketchbook); the keys that matter, helix's in two lines (`i`,
Escape, the motions, `x`, `d`, `c`, `r`, `u`/`U`, `%`) and the pointer;
hear this (Alt-o, Alt-i, Alt-n, Alt-p: that expression alone, heard and
seen grey until the next key; an example in thump); the drag (a step
every 4 pixels, by the number's own precision, one step to undo); how to
scrub in the console's words (`sessions`, `play session N [at S]`,
`pause`, `seek MS`, `step -N`, `stop`); what the tests play, the
storyboard among them; and in How it works, the editor's value in State
and the grammar, its colours, node walks and indent. The reload is 0.07
to 0.09 s under `zig build lib --watch -fincremental`.

zig build test: 86 of 86 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 storyboard as a script, two minutes typed through the editor</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T11:04:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=3571b3e8bfb54d6f98ad3bc1f89147275716e5fc'/>
<id>urn:sha1:3571b3e8bfb54d6f98ad3bc1f89147275716e5fc</id>
<content type='text'>
test/story.script plays the survey's storyboard (reports/demo1.md, the
screen and the storyboard) through the editor and asserts State at each
beat: a tone typed (`out` 8 instructions, heard on the stream); 220
dragged with the pointer to 330 (245 on the way); a gradient (`color`
10, ending in hsv); `beat`, `kick` and `thump` opened above, `out =
thump`, the colour's brightness times `0.5 + kick` (both tapes now hold
the kick's exp: the picture pulses because it says kick); the last `)`
deleted (the problem at its byte, 162, the tape unchanged) and typed
back; inside thump's `sin(...)` (`f*`, `;`, `mi(`), Alt-o hears and sees
the call alone (17 instructions ending in sin) and Alt-i its argument
(16), Escape the program again; `root` with `seq`, `bass`, `out = bass +
thump`, `r` and the ring (`out` 35, `color` 31). Then the session played
back, paused, sought to the tone and the kick (each the live moment,
leaf by leaf), stepped back 30 frames (0.9 s, the gradient), live again
at the kick with the beat made a third faster (`f2`, `;`, `r3`), and the
first session sought to its end as it was: nothing overwritten. Each
beat's screenshot lands in .zig-cache/story/, named by it; the test step
plays it with test/live.script. The storyboard's programs use the
square units (`x / 4`, `y / 2 + 0.5` for a gradient over the window).

zig build test: 86 of 86 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>
</feed>
