summaryrefslogtreecommitdiff
path: root/examples/vecanim/README.md
blob: cc6dc0e353ed1bfb42432a2fe5b88c83b14c6426 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# vecanim

Scenes for sketchbook's [`anim`](../../README.md#animation)
module: manim-style vector animation, with Typst for text and math, scenes
written as code (compiled, or live and interactive), cameras, morphs and
slide-style pauses. The library, its player and their tests live in
sketchbook; this package is the scenes, a script for each, and a
`build.zig` that lists them.

```sh
zig build run                          # play scenes/intro.zig, with hot reload
zig build lib --watch                  # second terminal: save the scene, see it live
zig build run -Dscene=scenes/live.zig  # any other scene file (and lib -Dscene=...)
zig build test                         # each scene played through its script, headless
zig build web                          # the same player in the browser (CPU renderer)
zig build export -- frames --size 1920x1080      # every frame as frames/000000.png, ...
zig build export -- - --size 3840x2160 --fps 60 |
    ffmpeg -f rawvideo -pix_fmt rgba -s 3840x2160 -r 60 -i - -pix_fmt yuv420p intro.mp4
```

Keys: click, space or page down for the next step of a scene that pauses
(space plays and pauses one that does not), page up back a step, `]`/`[`
next/previous slide, P play/pause, left/right previous/next play, `,`/`.`
step a frame, home/end, up/down speed, B GPU/CPU, L loop, G guides
(bounding boxes, origins and the scene's axes, with scene coordinates and
the pointer's); drag and wheel to look around, R to reset the view.

- `scenes/intro.zig`, compiled: shapes, Pythagoras morphing from one
  equation to the next, a camera move with an updater swinging an arrow,
  Typst math and a paragraph.
- `scenes/live.zig`, live, presented like slides: a wave of dots whose
  height the timeline animates, whose phase runs on while a pause waits,
  and which rise to meet the mouse.

`build.zig` lists the scenes with the script `zig build test` plays each
through (screenshots in `.zig-cache/e2e`). `-Dscene` picks the one `run`,
`lib`, `web` and `export` use. Each player is its own sketchbook app named
after its scene (`vecanim-intro`, `vecanim-live`), so several can run and
reload side by side with their own state.