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 /test/talk.script | |
| 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 'test/talk.script')
| -rw-r--r-- | test/talk.script | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/test/talk.script b/test/talk.script new file mode 100644 index 0000000..e123d59 --- /dev/null +++ b/test/talk.script @@ -0,0 +1,104 @@ +# The talk example (examples/talk.zig): a Deck in the sketch's own State, +# stepped by the clicks and keys the sketch turns into asks. +frames 90 +expect deck.waiting false +expect deck.slide 1 +# Slide 2 lies after the choice, which has not been made. +expect deck.slides 1 +# A click during the first step finishes it: held at the first pause. +click 100 100 +expect deck.t 2.5 ~0.0001 +expect deck.waiting true +expect deck.log.len 0 +# The mass bobs while the deck waits. +screenshot .zig-cache/talk/bob-a.png +frames 14 +screenshot .zig-cache/talk/bob-b.png +expect-different-screenshot .zig-cache/talk/bob-a.png .zig-cache/talk/bob-b.png +# The next click opens the pause where it lands: the slider comes in, and +# the deck waits at the choice. +click 100 100 +expect deck.log.len 1 +expect deck.log.buffer[0].wait 0.2833 ~0.001 +await deck.waiting true +frames 5 +# Reloaded mid-wait, the first step retimed from 2 s to 3: the same step, +# as far into it, a second later. +console set deck.playing false +expect deck.t 3.4833 ~0.001 +load {v2} +expect deck.t 4.4833 ~0.001 +expect deck.waiting true +expect deck.log.len 1 +expect deck.log.buffer[0].wait 0.2833 ~0.001 +console set deck.playing true +# A click on the slider is the slider's: zeta goes there, the deck stays. +click 790 580 +expect app.zeta 1.5 ~0.01 +expect deck.log.len 1 +expect deck.waiting true +# So is a drag along it, let go and all. +down 640 580 +move 400 580 +up 400 580 +expect app.zeta 0.2 ~0.01 +expect app.dragging false +expect deck.log.len 1 +expect deck.waiting true +# Going on chooses by the slider: under 1, it rings; slide 2 is laid. +key space +expect deck.log.len 2 +expect deck.log.buffer[1].value 0 +expect deck.slides 2 +frames 90 +screenshot .zig-cache/talk/rings.png +# Back: held at the choice again; over 1, it creeps. +key page_up +expect deck.log.len 1 +expect deck.waiting true +click 840 580 +expect app.zeta 1.667 ~0.01 +key space +expect deck.log.len 2 +expect deck.log.buffer[1].value 1 +frames 90 +screenshot .zig-cache/talk/creeps.png +expect-different-screenshot .zig-cache/talk/rings.png .zig-cache/talk/creeps.png +# Slide 2 at rest: it holds no pause, so its end. +key right_bracket +expect deck.slide 2 +expect deck.log.len 3 +expect deck.waiting false +# Back a slide: slide 1 at rest, held at its first pause (3 s of writing +# in this build, then the mass). +key left_bracket +expect deck.slide 1 +expect deck.log.len 0 +expect deck.t 3.5 ~0.0001 +expect deck.waiting true +# Recorded, clicks, the slider and keys replay to the same State: the deck +# opens gates in update, from events and State alone. +console record 0 +click 100 100 +frames 40 +click 790 580 +key space +frames 30 +key page_up +key right_bracket +frames 10 +console save 2 +console play 0 +frames 120 +expect-snapshot 2 +console stop +# Exported ({a}, {b}: 30 fps, half size), each gate holds 2 s: the mass +# bobs through the first hold (to 4.5 s), nothing moves at the choice +# (5.1 to 7.1 s), and the verdict writes after it. Twice, the same frames. +expect-different-screenshot {a}/000080.png {a}/000090.png +expect-different-screenshot {a}/000130.png {a}/000170.png +expect-same-screenshot {a}/000170.png {a}/000200.png +expect-different-screenshot {a}/000200.png {a}/000230.png +expect-same-screenshot {a}/000080.png {b}/000080.png +expect-same-screenshot {a}/000230.png {b}/000230.png +expect-same-screenshot {a}/000350.png {b}/000350.png |
