diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-16 22:59:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 6b07c3b2ee86592a28a713b4c6c40007c28eb6b8 (patch) | |
| tree | cc95801ec3fd34e90315bf033db3a714a68dc8c0 /build.zig | |
| parent | 7e3475a779f9e8dcb14b96cfc59e2b92a20c0cda (diff) | |
| download | sketchbook-6b07c3b2ee86592a28a713b4c6c40007c28eb6b8.tar.gz sketchbook-6b07c3b2ee86592a28a713b4c6c40007c28eb6b8.zip | |
examples: a talk that runs its own Deck, and its script
examples/talk.zig keeps an anim.Deck in its State beside its own data,
turns clicks and keys into asks and paints with an anim.Painter: two
slides, a mass that bobs (loop) while the deck waits, a damping slider laid
out and hit-tested in the talk (it takes its clicks), a choice gate that
branches on it, and slide 1 cleared beside slide 2's writing.
test/talk.script (zig build test-talk) steps it, finishes a step on a
click, goes back, jumps slides, drags the slider without advancing,
reloads mid-wait with the first step retimed (same step, t a second later)
and checks two exports with 2 s holds frame by frame. The vecanim live
scene's words follow the new pause.
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -249,6 +249,28 @@ pub fn build(b: *Build) void { test_step.dependOn(&compiled_script.step); test_anim.dependOn(&compiled_script.step); + // The talk example: a Deck in a sketch's own State, stepped, sent back, + // jumped by slides, clicked on its slider, reloaded mid-wait with its + // first step retimed, and exported twice, with the same frames. + const talk_imports: []const Build.Module.Import = &.{ .{ .name = "anim", .module = sb.modules.anim }, .{ .name = "sketch", .module = sketch } }; + const talk = sb.app(.{ .name = "talk", .root_source_file = b.path("examples/talk.zig"), .imports = &.{ + .{ .name = "anim", .module = sb.modules.anim }, + .{ .name = "typst", .module = sb.addTypst(b.createModule(.{ .root_source_file = b.path("examples/talk.zig"), .imports = talk_imports })) }, + } }); + const talk_check = talk.addReloadCheck(.{ .script = b.path("test/talk.script"), .edits = &.{.{ + .file = "examples/talk.zig", + .old = "s.play(.{ title.write(), law.write() }, .{});", + .new = "s.play(.{ title.write(), law.write() }, .{ .seconds = 3 });", + }} }); + const talk_exe = talk.addExecutable(); + for ([_][]const u8{ "a", "b" }, [_]u64{ 400, 401 }) |define, frames| { + talk_check.run.addArg("--define"); + talk_check.run.addPrefixedDirectoryArg(b.fmt("{s}=", .{define}), talk.addExport(talk_exe, .{ .fps = 30, .frames = frames, .size = .{ 640, 360 } }).frames); + } + const test_talk = b.step("test-talk", "Play the talk example: steps, back, slides, its slider, a reload mid-wait and its export"); + test_talk.dependOn(&talk_check.run.step); + test_step.dependOn(&talk_check.run.step); + // Both vector renderers against resvg, through the host (tools/svgdiff.py). const svgview = sb.app(.{ .name = "svgview", .root_source_file = b.path("test/svgview.zig"), .imports = &.{.{ .name = "vector", .module = sb.modules.vector }} }); const diff = b.addSystemCommand(&.{ "python3", "tools/svgdiff.py" }); |
