summaryrefslogtreecommitdiff
path: root/examples/noc/test/pendulum.timeline.script
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 21:28:20 -0300
committerGabriel Schneider <[email protected]>2026-11-16 21:28:20 -0300
commit6933f99ddb2d7103515d26838496309a807bba26 (patch)
tree991c2fe7d4a57957222876e190fa4d16a0fb889c /examples/noc/test/pendulum.timeline.script
parent82fca5c9f29124f37f6dcd08e73e6999ce44a69d (diff)
downloadsketchbook-6933f99ddb2d7103515d26838496309a807bba26.tar.gz
sketchbook-6933f99ddb2d7103515d26838496309a807bba26.zip
Move standalone sketches into sketchbook examples
Diffstat (limited to 'examples/noc/test/pendulum.timeline.script')
-rw-r--r--examples/noc/test/pendulum.timeline.script68
1 files changed, 68 insertions, 0 deletions
diff --git a/examples/noc/test/pendulum.timeline.script b/examples/noc/test/pendulum.timeline.script
new file mode 100644
index 0000000..11252f2
--- /dev/null
+++ b/examples/noc/test/pendulum.timeline.script
@@ -0,0 +1,68 @@
+# Timeline check (design.md "Acceptance: timeline"), from
+# accel_to_mouse.timeline.script. The interaction is a drag of the bob and a
+# press that misses it. While dragged, the angle follows the pointer of each
+# frame, so a replay that batched frames or started from other input state
+# would end elsewhere.
+
+# 1. Record, from the start: the bob hangs at PI/4, (444, 154).
+console snapshot 1
+console record 0
+down 444 154
+expect dragging true
+move 400 200
+move 330 220
+frames 5
+move 250 200
+move 160 60
+up 160 60
+frames 40
+# A press away from the bob grabs nothing.
+down 600 300
+move 500 300
+up 500 300
+expect dragging false
+frames 30
+console save 2
+
+# 2. Played to the end, exactly.
+console play 0
+frames 120
+expect-snapshot 2
+screenshot .zig-cache/e2e/pendulum-played.png
+# 5. Paused: `draw` must not move State.
+frames 30
+expect-snapshot 2
+
+# 3. Sought to the end, and to the middle and played on.
+console seek end
+expect-snapshot 2
+screenshot .zig-cache/e2e/pendulum-sought.png
+# 7. What a seek shows equals what playing showed.
+expect-same-screenshot .zig-cache/e2e/pendulum-played.png .zig-cache/e2e/pendulum-sought.png
+console seek 300
+console pause
+frames 10
+console pause
+frames 30
+console pause
+frames 120
+expect-snapshot 2
+
+# 4. Stepped from the start, then back and forth.
+console seek start
+console step 100000
+expect-snapshot 2
+console step -25
+console step 25
+expect-snapshot 2
+
+# 6. A live pointer move (and a held button), then the same replay.
+console stop
+move 20 20
+down 20 20
+frames 10
+up 20 20
+console play 0
+frames 120
+expect-snapshot 2
+console stop