@anime-studio/cli 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +238 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/describe.d.ts +7 -0
  8. package/dist/describe.d.ts.map +1 -0
  9. package/dist/describe.js +48 -0
  10. package/dist/describe.js.map +1 -0
  11. package/dist/doctor.d.ts +44 -0
  12. package/dist/doctor.d.ts.map +1 -0
  13. package/dist/doctor.js +121 -0
  14. package/dist/doctor.js.map +1 -0
  15. package/dist/index.d.ts +11 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +11 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/load.d.ts +13 -0
  20. package/dist/load.d.ts.map +1 -0
  21. package/dist/load.js +41 -0
  22. package/dist/load.js.map +1 -0
  23. package/dist/skills.d.ts +28 -0
  24. package/dist/skills.d.ts.map +1 -0
  25. package/dist/skills.js +56 -0
  26. package/dist/skills.js.map +1 -0
  27. package/package.json +55 -3
  28. package/skills/animestudio/SKILL.md +165 -0
  29. package/skills/animestudio/examples/first-frame.ts +54 -0
  30. package/skills/animestudio/examples/hello.scene.json +50 -0
  31. package/skills/animestudio/examples/hello.sequence.json +13 -0
  32. package/skills/animestudio/examples/remotion/Root.tsx +25 -0
  33. package/skills/animestudio/examples/remotion/index.ts +5 -0
  34. package/skills/animestudio/examples/render-video.ts +110 -0
  35. package/skills/animestudio/references/packages.md +54 -0
  36. package/skills/animestudio/references/rendering.md +127 -0
  37. package/skills/animestudio/references/scene-format.md +101 -0
  38. package/skills/animestudio/references/validation-and-debugging.md +67 -0
  39. package/skills/animestudio-animation/SKILL.md +176 -0
  40. package/skills/animestudio-animation/examples/gestures.ts +55 -0
  41. package/skills/animestudio-animation/examples/hold.ts +82 -0
  42. package/skills/animestudio-animation/examples/knockdown.ts +68 -0
  43. package/skills/animestudio-animation/examples/sheet.ts +80 -0
  44. package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
  45. package/skills/animestudio-animation/references/clips.md +103 -0
  46. package/skills/animestudio-animation/references/director-beats.md +48 -0
  47. package/skills/animestudio-animation/references/holding.md +106 -0
  48. package/skills/animestudio-animation/references/locomotion.md +86 -0
  49. package/skills/animestudio-animation/references/timing.md +89 -0
  50. package/skills/animestudio-characters/SKILL.md +211 -0
  51. package/skills/animestudio-characters/examples/cast.ts +63 -0
  52. package/skills/animestudio-characters/examples/human.ts +52 -0
  53. package/skills/animestudio-characters/examples/import-svg.ts +68 -0
  54. package/skills/animestudio-characters/examples/lumo.svg +36 -0
  55. package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
  56. package/skills/animestudio-characters/examples/sprout.ts +48 -0
  57. package/skills/animestudio-characters/examples/turnaround.ts +91 -0
  58. package/skills/animestudio-characters/references/custom-rig.md +139 -0
  59. package/skills/animestudio-characters/references/import-svg.md +59 -0
  60. package/skills/animestudio-characters/references/look-options.md +143 -0
  61. package/skills/animestudio-characters/references/rig-surface.md +62 -0
  62. package/skills/animestudio-script/SKILL.md +164 -0
  63. package/skills/animestudio-script/examples/director.ts +143 -0
  64. package/skills/animestudio-script/examples/sheet.ts +58 -0
  65. package/skills/animestudio-script/examples/short.ts +193 -0
  66. package/skills/animestudio-script/references/actions.md +84 -0
  67. package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
  68. package/skills/animestudio-script/references/director.md +110 -0
  69. package/skills/animestudio-script/references/shots-and-editing.md +79 -0
  70. package/skills/animestudio-script/references/writing-for-animation.md +84 -0
  71. package/skills/animestudio-sets/SKILL.md +232 -0
  72. package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
  73. package/skills/animestudio-sets/examples/render-scene.ts +35 -0
  74. package/skills/animestudio-sets/examples/sets.ts +257 -0
  75. package/skills/animestudio-sets/references/drawing-sets.md +119 -0
  76. package/skills/animestudio-sets/references/fx.md +92 -0
  77. package/skills/animestudio-sets/references/lighting-camera.md +93 -0
  78. package/skills/animestudio-sets/references/scene-fields.md +132 -0
@@ -0,0 +1,232 @@
1
+ ---
2
+ name: animestudio-sets
3
+ description: Builds the world an animeStudio scene happens in — the set (cenário) drawn as SVG layers with parallax and depth, the ground actors stand on, props (static, animated, screen-fixed, rigid bodies), lighting, the camera, cartoon fx and in-scene transitions. Use it whenever you create or fix a set, background, backdrop or location, place props, light a scene, move or frame the camera, or compose shots for 16:9 or 9:16 in animeStudio.
4
+ ---
5
+
6
+ # animeStudio sets: backgrounds, props, lighting, camera
7
+
8
+ A scene (`*.scene.json`, or a `SceneDoc` in TypeScript) is a stage: a canvas, painted
9
+ `layers`, a `world` with ground, `props`, `lighting`, a `camera`, and a `script` of actions.
10
+ This skill covers everything except the characters' acting. For walking, talking, holding
11
+ objects and sitting see [`animestudio-animation`](../animestudio-animation/SKILL.md); for whole
12
+ episodes staged by the director see [`animestudio-script`](../animestudio-script/SKILL.md).
13
+
14
+ The truth is the schema (`packages/core/src/format/schema.ts`): scene objects are **strict**, so
15
+ an invented field is a validation error. Never invent fields, fx names, light types or camera
16
+ options; check the references below.
17
+
18
+ | Need | Read |
19
+ |---|---|
20
+ | Every scene, layer, prop, body, cord, ground and channel field | [references/scene-fields.md](references/scene-fields.md) |
21
+ | Lights, shading, grading, every camera option | [references/lighting-camera.md](references/lighting-camera.md) |
22
+ | All 22 `fx` types, `shake`, in-scene transitions | [references/fx.md](references/fx.md) |
23
+ | Drawing sets as SVG, scale, composition 16:9 / 9:16 | [references/drawing-sets.md](references/drawing-sets.md) |
24
+ | Exhaustive spec | [FORMAT.md §3](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#3-scene-document-scenejson) |
25
+
26
+ ## Coordinates (get these right first)
27
+
28
+ - Scene space is SVG: `0..width` × `0..height`, **y down**, angles in degrees clockwise, time in seconds.
29
+ - An actor's `x`, `y` is the point **between its feet** (the character's setup origin). Put `y` on
30
+ the floor line of the set, or give the actor `ground` on a surface.
31
+ - Layer and prop art is drawn in scene coordinates around its own origin; `x`, `y` move it.
32
+ - Draw order is `z` (default 0), for layers, actors and props alike. Convention:
33
+ sky −100, far scenery −90…−60, furniture behind people −50…−10, actors 0…5, foreground 50,
34
+ screen overlays 150–200.
35
+ - `parallax` is how much the camera moves something: `1` normal, `<1` far away (sky 0–0.1,
36
+ mountains 0.3–0.5), `>1` nearer than the actors (foreground 1.1–1.3), `0` fixed to the screen.
37
+
38
+ ## Workflow
39
+
40
+ 1. **Canvas.** `width`/`height`/`fps`/`duration`/`background`: 1920×1080 for 16:9, 1080×1920
41
+ for 9:16, 30 fps (24 for a filmic look). `background` is a fallback colour under everything.
42
+ 2. **Decide the floor line** (the y where feet stand) and the actor scale before drawing
43
+ anything. A kit adult (`cartoonCharacter`) is ~530 px tall at scale 1: a wide 16:9 shot at
44
+ 1080 high wants scale ≈ 1 (the figure ≈ half the frame) with the floor at y ≈ 900–960.
45
+ 3. **Draw the set as layers** (sky → far → mid → floor → furniture → foreground), each one
46
+ SVG string. Size everything people use from the character (a door ≈ 1.35 × a person, a counter
47
+ top ≈ 0.5 ×, a seat ≈ 0.25 ×), never from the frame. See
48
+ [drawing-sets.md](references/drawing-sets.md).
49
+ 4. **Ground.** Flat floor: actors' `y` = floor line. Slopes, hills, steps: `world.surfaces` plus
50
+ `"ground": { "surface": id }` on the actor (its `y` then follows the surface).
51
+ 5. **Props**: things that move, get used, or must be in front of/behind people.
52
+ 6. **Lighting**: a mood, light sources that glow, a key light for cel shading.
53
+ 7. **Camera**: an establishing frame, then moves, follows or framing.
54
+ 8. **Validate**: `npx tsx packages/cli/src/bin.ts validate my.scene.json` (or `toon validate`).
55
+ 9. **Render stills and look at them** (below). Fix, re-render, look again.
56
+
57
+ ## Layers: the painted set
58
+
59
+ ```jsonc
60
+ "layers": [
61
+ { "id": "sky", "z": -100, "parallax": 0, "art": "<rect width='1920' height='1080' fill='url(#g)'/>" },
62
+ { "id": "hills", "z": -80, "parallax": 0.45, "art": "<path d='M-900 760 Q…' fill='#9a7fb8'/>" },
63
+ { "id": "ground", "z": -60, "art": "<path d='M-500 930 C… V1500 H-500 Z' fill='#7fb36a'/>" },
64
+ { "id": "bush", "z": 50, "parallax": 1.25, "art": "<path …/>" }
65
+ ]
66
+ ```
67
+
68
+ - Layer fields: `id`, `art`, plus placement `x`, `y`, `rotation`, `scale`, `z`, `parallax`,
69
+ `opacity`. All animatable as `layers.<id>.<field>` tracks (`z` stepped).
70
+ - `art` is raw SVG markup. `<defs>` (gradients) may live inside it; give gradient ids unique names.
71
+ - **Overscan.** A layer at parallax 1 must cover every place the camera will look: draw it
72
+ past the frame (`-500 … width+500`) when the camera pans, follows or zooms out. Parallax 0
73
+ layers only need the frame. Far layers need less margin, foreground layers (>1) more.
74
+ - Layers never boil, smear or step on twos: cartoon timing touches actors and props only.
75
+ - Split a set into several layers only for depth (parallax, z between actors) or animation.
76
+ A static background can be one layer.
77
+
78
+ ## Ground
79
+
80
+ ```jsonc
81
+ "world": { "gravity": [0, 2000], "surfaces": [{ "id": "hill", "path": "M-500 930 C 200 930 700 820 1150 830 S 1900 900 2500 880" }] },
82
+ "actors": [{ "id": "pip", "character": "pip", "x": 260, "y": 930, "scale": 1.2,
83
+ "ground": { "surface": "hill", "offset": 4, "feet": ["footNear", "footFar"] } }]
84
+ ```
85
+
86
+ - A surface `path` is the **top edge** of the walkable ground, scene space, drawn left to right,
87
+ extended past both frame edges. Draw the ground layer from the **same path** (then close it
88
+ down: `… V1500 H-500 Z`) so feet and drawing agree.
89
+ - `ground.offset` sinks the feet a few px into the line (reads as weight); `feet` lists the
90
+ character's foot IK chain ids (`toon describe` lists them) so each foot meets the slope.
91
+ - Rigid bodies collide with every surface. `world.ground` is a flat floor **for rigid bodies
92
+ only**; it does not move actors.
93
+ - Furniture against the back wall stands on the wall's base line; actors stand lower, in front
94
+ of it. Keep the two lines distinct (e.g. base 790, feet 950) and draw the floor between them.
95
+
96
+ ## Props
97
+
98
+ ```jsonc
99
+ { "id": "lamp", "art": "<g>…</g>", "x": 1190, "y": 912, "z": -10 }, // static scenery that can move later
100
+ { "id": "badge", "art": "<g>…</g>", "x": 40, "y": 40, "z": 200, "parallax": 0 }, // fixed to the screen
101
+ { "id": "crate", "art": "<rect x='-45' y='-45' width='90' height='90'/>", "x": 1350, "y": -500,
102
+ "body": { "type": "dynamic", "shape": { "box": [90, 90] }, "restitution": 0.25 } } // falls and lands
103
+ ```
104
+
105
+ - Draw a prop's art **around its origin** where it is held, stands or pivots: a lamp's foot at
106
+ (0, 0), a ball's centre at (0, 0). A rigid body's `shape` is centred on the origin, `box` is
107
+ the full `[width, height]`.
108
+ - Animate with tracks `props.<id>.x|y|rotation|scale|opacity|z`; opacity 0 removes it from the
109
+ frame (a switch: lamp on/off = two props or an opacity step).
110
+ - **Screen-fixed** props (`parallax: 0`, high `z`): titles, badges, captions, signatures. They
111
+ ignore camera moves, roll and dolly.
112
+ - **Rigid bodies** (`body`): `dynamic` (simulated), `static` (a wall, an invisible floor:
113
+ `art: ""`), `kinematic` (follows its tracks and pushes others). Then `impulse`, `grab`,
114
+ `release`. Bodies need the bake: in TypeScript use `prepareScene` from `@anime-studio/rigid`
115
+ (not bare `compileScene`); the CLI and the renderers do it for you.
116
+ - Things an actor holds, sits on or rides: `grab`/`release`/`put`, `mount`, `reach` — see
117
+ [`animestudio-animation`](../animestudio-animation/SKILL.md). A prop on a string or a phone
118
+ cord: `cord` ([scene-fields.md](references/scene-fields.md#cord)).
119
+ - Furniture with states (a TV on/off, a door, a clock) is either props with opacity steps, or a
120
+ tiny rig (`*.toon.json` with a `switch` part or clips) placed as an **actor** with
121
+ `"holds": 0, "twos": false` so it never drifts. Director sets have **fixtures** for this — see
122
+ [DIRECTOR.md "Set fixtures"](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md#set-fixtures).
123
+
124
+ ## Lighting in one block
125
+
126
+ ```jsonc
127
+ "lighting": {
128
+ "ambient": { "color": "#1c1f55", "opacity": 0.5 }, // night: darkness over all
129
+ "lights": [
130
+ { "id": "bulb", "type": "point", "x": 1190, "y": 220, "radius": 560, "glow": 0.5, "color": "#ffd98a", "flicker": { "amount": 0.06 } },
131
+ { "id": "key", "type": "directional", "angle": 120, "glow": 0 } // shades characters
132
+ ],
133
+ "shading": { "light": "key", "color": "#2b2a6b", "opacity": 0.3, "rim": "#ffd98a", "rimOpacity": 0.6, "offset": 6 },
134
+ "vignette": { "color": "#000", "opacity": 0.35 }
135
+ }
136
+ ```
137
+
138
+ - Point lights glow (screen blend) and **cut holes in the ambient darkness**; a directional light
139
+ with `glow: 0` is the key light for cel shading. Characters get shading only when a `shading`
140
+ block exists.
141
+ - Keep big glows off faces and line art: additive light lifts black lines to grey (radius ≈ the
142
+ lamp's reach, `glow` ≤ 0.6).
143
+ - Animate with the `light` action (`channel: "lights.bulb.intensity"`, `"lighting.ambient.opacity"`…)
144
+ or tracks; hex colours interpolate. Full list in
145
+ [lighting-camera.md](references/lighting-camera.md).
146
+
147
+ ## Camera in one block
148
+
149
+ ```jsonc
150
+ "camera": { "x": 960, "y": 540, "zoom": 1, "bounds": [-500, 0, 2500, 1080] },
151
+ "script": [
152
+ { "at": 0.2, "action": "camera", "follow": "pip", "offset": [160, 0], "deadZone": [80, 0], "lookAhead": 0.3 },
153
+ { "at": 3.0, "action": "camera", "frame": ["pip", "crate"], "padding": 160, "maxZoom": 1.3, "blend": 0.8 },
154
+ { "at": 3.6, "action": "camera", "punch": 0.12 },
155
+ { "at": 4.0, "action": "camera", "x": 1100, "y": 560, "zoom": 1.6, "duration": 1.5 },
156
+ { "at": 6.0, "action": "camera", "x": 960, "y": 540, "zoom": 1, "duration": 0 } // a cut
157
+ ]
158
+ ```
159
+
160
+ - `camera.x/y` is the scene point at the **centre** of the frame. Every camera action starts
161
+ from where the camera really is, so moves, follows and framings never jump.
162
+ - `bounds` = the drawn world: the view never shows past it. Set it whenever you follow or frame.
163
+ - Moves ≥ 1 s with the default `sineInOut`; `punch` 0.1–0.2 for reactions; `handheld` 3–6 px
164
+ for life; `blur` + `focus` for depth of field; `shake` for impacts.
165
+
166
+ ## Effects and transitions
167
+
168
+ `fx` draws cartoon emanata at an actor's anchor, a prop or a scene point; anime fx
169
+ (`focusLines`, `speedLines`, `impactFrame`, `caption`) are screen-space. `transition`
170
+ (`fade`, `iris`, `wipe`, `flash`) covers/uncovers the screen inside the scene. All names and
171
+ fields: [fx.md](references/fx.md).
172
+
173
+ ```jsonc
174
+ { "at": 1.1, "action": "fx", "type": "dust", "prop": "crate", "scale": 1.4 },
175
+ { "at": 1.2, "actor": "pip", "action": "fx", "type": "surprise" },
176
+ { "at": 0.9, "action": "fx", "type": "caption", "text": "The hill", "style": "place" },
177
+ { "at": 5.0, "action": "transition", "type": "iris", "mode": "out", "duration": 1.0, "target": "pip" }
178
+ ```
179
+
180
+ ## The check loop: render stills and LOOK
181
+
182
+ Never ship a set you have not seen. Render PNG stills and open them (the Read tool shows images):
183
+
184
+ ```ts
185
+ import { evaluateScene, frameToSVG } from "@anime-studio/core";
186
+ import { prepareScene } from "@anime-studio/rigid";
187
+ const scene = await prepareScene(doc, { characters }); // compile + rigid bake
188
+ writeFileSync("out/f.svg", frameToSVG(evaluateScene(scene, 1.0)));
189
+ execFileSync("rsvg-convert", ["-w", "960", "-o", "out/f.png", "out/f.svg"]);
190
+ ```
191
+
192
+ Render (1) the **empty set**, (2) the set **with the actors** at their marks, (3) a frame at
193
+ **every camera change and physics event** (a body lands earlier than you think: time its `dust`
194
+ and `shake` from the still). Check, in this order:
195
+
196
+ - The set reads at a glance: one clear floor line, the place is obvious, nothing busy behind heads.
197
+ - Feet sit **on** the floor line (not floating, not sunk); scale matches the furniture (a person
198
+ is taller than a counter, shorter than a door, a fridge, a lamp).
199
+ - Faces sit against plain, contrasting areas, never on a busy pattern or a same-value colour
200
+ (a dark-haired head on a dark chalkboard disappears); no set line runs exactly at the neck or eyes.
201
+ - Foreground layers never cover a face; screen-fixed text stays inside the safe area.
202
+ - Lights show where the source is drawn, glows do not wash out the characters, the night reads as night.
203
+ - At every camera position no edge of a layer is visible (overscan, `bounds`).
204
+
205
+ ## Runnable examples (from the repo root)
206
+
207
+ | File | Shows |
208
+ |---|---|
209
+ | [examples/sets.ts](examples/sets.ts) | `kitchen()`, `parkAtNight(w, h)` (16:9 and 9:16, slope surface, lamp light), `classroom()` — reusable set functions returning layers, props, surfaces, lighting and marks; stills empty / with a kit character / a camera push-in |
210
+ | [examples/hillside.scene.json](examples/hillside.scene.json) | Pure JSON: parallax layers, a sloped surface with foot IK, a falling rigid crate, a screen-fixed badge, dusk lighting with a fading sun, follow → frame → punch, dust/surprise/caption fx, fade-in and iris-out |
211
+ | [examples/render-scene.ts](examples/render-scene.ts) | Stills of any scene JSON at chosen times (loads characters relative to the file, bakes rigid bodies) |
212
+
213
+ ```sh
214
+ npx tsx skills/animestudio-sets/examples/sets.ts
215
+ npx tsx packages/cli/src/bin.ts validate skills/animestudio-sets/examples/hillside.scene.json
216
+ npx tsx skills/animestudio-sets/examples/render-scene.ts skills/animestudio-sets/examples/hillside.scene.json 0.1 1.6 3.4 5.5
217
+ ```
218
+
219
+ Outputs go to `skills/animestudio-sets/examples/out/`.
220
+
221
+ ## Common mistakes
222
+
223
+ - Invented fields (`"layer": …` on a prop, `"type": "spot"` light, `"zoomTo"`): the schema
224
+ rejects unknown keys. Look them up.
225
+ - Drawing the set at frame size and then panning: the edge of the world shows. Overscan + `bounds`.
226
+ - Feet on a y that is not the drawn floor, or a surface path that does not match the ground art.
227
+ - Characters scaled to fill the frame in a wide shot, or furniture drawn for a different scale
228
+ than the cast: decide the scale first, size the set from it.
229
+ - A ground-level horizon line at the characters' eye or neck height (a tangent): move it.
230
+ - `compileScene` on a scene with `body` props: bodies do not move. Use `prepareScene`.
231
+ - Big point-light glow on top of the actors: washed-out, grey line art.
232
+ - Text and logos in a parallax-1 layer: they slide with the camera. Use `parallax: 0` props.
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "../../../schemas/scene.schema.json",
3
+ "format": "toon-scene",
4
+ "version": 1,
5
+ "width": 1920,
6
+ "height": 1080,
7
+ "fps": 30,
8
+ "duration": 6,
9
+ "background": "#f7c59f",
10
+ "characters": { "pip": "../../../examples/characters/pip.toon.json" },
11
+ "world": {
12
+ "gravity": [0, 2000],
13
+ "surfaces": [
14
+ { "id": "hill", "path": "M-500 930 C 200 930 700 820 1150 830 S 1900 900 2500 880" }
15
+ ]
16
+ },
17
+ "camera": { "x": 960, "y": 540, "zoom": 1, "bounds": [-500, 0, 2500, 1080] },
18
+ "layers": [
19
+ {
20
+ "id": "sky", "z": -100, "parallax": 0,
21
+ "art": "<defs><linearGradient id='dusk' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='#6f7fd1'/><stop offset='0.7' stop-color='#f7a98b'/><stop offset='1' stop-color='#ffd59e'/></linearGradient></defs><rect x='0' y='0' width='1920' height='1080' fill='url(#dusk)'/>"
22
+ },
23
+ {
24
+ "id": "sun", "z": -95, "parallax": 0.05,
25
+ "art": "<circle cx='1480' cy='640' r='110' fill='#ffe08a'/>"
26
+ },
27
+ {
28
+ "id": "clouds", "z": -90, "parallax": 0.2,
29
+ "art": "<g fill='#fde3d2'><ellipse cx='300' cy='200' rx='140' ry='40'/><ellipse cx='380' cy='180' rx='80' ry='40'/><ellipse cx='1150' cy='140' rx='160' ry='36'/><ellipse cx='2000' cy='230' rx='130' ry='38'/></g>"
30
+ },
31
+ {
32
+ "id": "farHills", "z": -80, "parallax": 0.45,
33
+ "art": "<path d='M-900 760 Q -300 560 300 740 T 1500 700 T 2800 740 V1400 H-900 Z' fill='#9a7fb8'/>"
34
+ },
35
+ {
36
+ "id": "ground", "z": -60,
37
+ "art": "<path d='M-500 930 C 200 930 700 820 1150 830 S 1900 900 2500 880 V1500 H-500 Z' fill='#7fb36a'/><path d='M-500 930 C 200 930 700 820 1150 830 S 1900 900 2500 880' fill='none' stroke='#2b2238' stroke-width='3'/><path d='M-500 1000 C 200 1000 700 900 1150 910 S 1900 980 2500 960' fill='none' stroke='#6c9e58' stroke-width='8'/>"
38
+ },
39
+ {
40
+ "id": "grassFront", "z": 50, "parallax": 1.25,
41
+ "art": "<path d='M1700 1080 q20 -120 40 0 q20 -160 45 0 q15 -110 35 0 Z' fill='#4f8a4a' stroke='#2b2238' stroke-width='3' stroke-linejoin='round'/>"
42
+ }
43
+ ],
44
+ "actors": [
45
+ {
46
+ "id": "pip", "character": "pip", "x": 260, "y": 930, "scale": 1.2,
47
+ "ground": { "surface": "hill", "offset": 4, "feet": ["footNear", "footFar"] }
48
+ }
49
+ ],
50
+ "props": [
51
+ {
52
+ "id": "crate", "x": 1350, "y": -500, "z": 5,
53
+ "art": "<g stroke='#2b2238' stroke-width='3' stroke-linejoin='round'><rect x='-45' y='-45' width='90' height='90' fill='#d9a46a'/><path d='M-45 -45 L45 45 M45 -45 L-45 45' fill='none'/></g>",
54
+ "body": { "type": "dynamic", "shape": { "box": [90, 90] }, "restitution": 0.25, "friction": 0.7 }
55
+ },
56
+ {
57
+ "id": "ball", "x": 820, "y": 600, "z": 5,
58
+ "art": "<g stroke='#2b2238' stroke-width='3'><circle r='30' fill='#ff6b5b'/><path d='M-30 0 Q0 -14 30 0' fill='none'/></g>",
59
+ "body": { "type": "dynamic", "shape": { "circle": 30 }, "restitution": 0.55 }
60
+ },
61
+ {
62
+ "id": "badge", "x": 40, "y": 40, "z": 200, "parallax": 0,
63
+ "art": "<g font-family='Avenir Next, Helvetica, Arial' font-weight='700'><rect width='250' height='56' rx='28' fill='#2b2238' opacity='0.85'/><text x='125' y='37' text-anchor='middle' font-size='26' fill='#fff7e6'>Hillside, dusk</text></g>"
64
+ }
65
+ ],
66
+ "lighting": {
67
+ "ambient": { "color": "#6a4a8c", "opacity": 0.15 },
68
+ "lights": [
69
+ { "id": "sun", "type": "point", "x": 1480, "y": 640, "radius": 700, "glow": 0.45, "color": "#ffc46b", "parallax": 0.05 },
70
+ { "id": "key", "type": "directional", "angle": 170, "glow": 0 }
71
+ ],
72
+ "shading": { "light": "key", "color": "#5b3f86", "opacity": 0.25, "rim": "#ffc46b", "rimOpacity": 0.6, "offset": 6 },
73
+ "grade": { "color": "#ffb86b", "opacity": 0.12, "blend": "soft-light" },
74
+ "vignette": { "color": "#2b2238", "opacity": 0.25 }
75
+ },
76
+ "script": [
77
+ { "at": 0, "actor": "pip", "action": "play", "clip": "idle", "loop": true, "layer": -1, "fadeIn": 0 },
78
+ { "at": 0, "action": "transition", "type": "fade", "mode": "in", "duration": 0.5, "color": "#2b2238" },
79
+ { "at": 0.2, "actor": "pip", "action": "walkTo", "x": 1000, "duration": 2.6 },
80
+ { "at": 0.2, "action": "camera", "follow": "pip", "offset": [160, 0], "deadZone": [80, 0], "lookAhead": 0.3 },
81
+ { "at": 0.9, "action": "fx", "type": "caption", "text": "The hill", "style": "place", "duration": 2 },
82
+ { "at": 1.1, "action": "fx", "type": "dust", "prop": "crate", "scale": 1.4 },
83
+ { "at": 1.1, "action": "shake", "duration": 0.3, "amount": 6 },
84
+ { "at": 1.15, "actor": "pip", "action": "lookAt", "target": "crate" },
85
+ { "at": 1.2, "actor": "pip", "action": "fx", "type": "surprise" },
86
+ { "at": 3.0, "action": "camera", "frame": ["pip", "crate"], "padding": 160, "maxZoom": 1.3, "blend": 0.8 },
87
+ { "at": 3.2, "action": "light", "channel": "lights.sun.intensity", "value": 0.4, "duration": 2.5 },
88
+ { "at": 3.2, "action": "light", "channel": "lighting.ambient.opacity", "value": 0.4, "duration": 2.5 },
89
+ { "at": 3.6, "action": "camera", "punch": 0.12 },
90
+ { "at": 3.6, "actor": "pip", "action": "fx", "type": "sparkle" },
91
+ { "at": 5.0, "action": "transition", "type": "iris", "mode": "out", "duration": 1.0, "target": "pip" }
92
+ ]
93
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Renders stills of a JSON scene (rigid bodies baked) so you can LOOK at the set, the props, the
3
+ * light and the camera at chosen times.
4
+ *
5
+ * npx tsx skills/animestudio-sets/examples/render-scene.ts [scene.json] [t1 t2 …]
6
+ *
7
+ * Default: hillside.scene.json at 0.1 1.0 1.6 3.4 5.5 s. Output: examples/out/<scene>-<t>.png.
8
+ * Validate first: npx tsx packages/cli/src/bin.ts validate skills/animestudio-sets/examples/hillside.scene.json
9
+ */
10
+ import { execFileSync } from "node:child_process";
11
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
12
+ import { basename, dirname, join, resolve } from "node:path";
13
+ import { type SceneDoc, type ToonDoc, evaluateScene, frameToSVG, parseScene } from "@anime-studio/core";
14
+ import { prepareScene } from "@anime-studio/rigid";
15
+
16
+ const here = import.meta.dirname;
17
+ const OUT = join(here, "out");
18
+ const [file = join(here, "hillside.scene.json"), ...times] = process.argv.slice(2);
19
+ const at = times.length ? times.map(Number) : [0.1, 1.0, 1.6, 3.4, 5.5];
20
+
21
+ const doc = JSON.parse(readFileSync(file, "utf8")) as SceneDoc;
22
+ // Character paths are relative to the scene file.
23
+ const characters = Object.fromEntries(
24
+ Object.entries(doc.characters).map(([id, p]) => [id, JSON.parse(readFileSync(resolve(dirname(file), p), "utf8")) as ToonDoc]),
25
+ );
26
+ const scene = await prepareScene(parseScene(doc, { characters }), { characters });
27
+
28
+ mkdirSync(OUT, { recursive: true });
29
+ const name = basename(file).replace(/\.scene\.json$/, "");
30
+ for (const t of at) {
31
+ const svg = join(OUT, `${name}-${t}.svg`);
32
+ writeFileSync(svg, frameToSVG(evaluateScene(scene, t)));
33
+ execFileSync("rsvg-convert", ["-w", String(Math.round(doc.width / 2)), "-o", svg.replace(/\.svg$/, ".png"), svg]);
34
+ console.log(`out/${name}-${t}.png`);
35
+ }
@@ -0,0 +1,257 @@
1
+ /**
2
+ * Three reusable cartoon sets (a kitchen, a park at night with a lamp light, a classroom) and a
3
+ * still of each: empty, then with one kit character standing in it. The park is also drawn for a
4
+ * vertical 9:16 frame.
5
+ *
6
+ * npx tsx skills/animestudio-sets/examples/sets.ts
7
+ *
8
+ * Output: skills/animestudio-sets/examples/out/<set>-empty.png, <set>-actor.png (needs rsvg-convert).
9
+ */
10
+ import { execFileSync } from "node:child_process";
11
+ import { mkdirSync, writeFileSync } from "node:fs";
12
+ import { join } from "node:path";
13
+ import type { ActionDef, LayerDef, LightingDef, PropDef, SceneDoc, SurfaceDef } from "@anime-studio/core";
14
+ import { evaluateScene, frameToSVG } from "@anime-studio/core";
15
+ import { type CartoonLook, cartoonCharacter } from "@anime-studio/kit";
16
+ import { prepareScene } from "@anime-studio/rigid";
17
+
18
+ const OUT = join(import.meta.dirname, "out");
19
+
20
+ // --- The house look ----------------------------------------------------------------------------------
21
+ // One ink and one line weight for the whole show, matching the kit's "modern" characters
22
+ // (ink #2b2238, line 2.4 at scale 1). Characters stand at scale ~1 in a 1080-high wide shot, so the
23
+ // set's lines are drawn at ~3 px: the same weight on screen.
24
+ const INK = "#2b2238";
25
+ const LINE = 3;
26
+ const ln = `stroke="${INK}" stroke-width="${LINE}" stroke-linejoin="round" stroke-linecap="round"`;
27
+ const rect = (x: number, y: number, w: number, h: number, fill: string, extra = "") =>
28
+ `<rect x="${x}" y="${y}" width="${w}" height="${h}" fill="${fill}" ${extra}/>`;
29
+
30
+ /** What a set function returns: everything a scene needs to stand actors in it. */
31
+ export interface CartoonSet {
32
+ width: number;
33
+ height: number;
34
+ background: string;
35
+ /** Scene y where the feet stand (the floor line). */
36
+ floor: number;
37
+ /** Good x positions for actors (left, centre, right marks). */
38
+ marks: Record<string, number>;
39
+ layers: LayerDef[];
40
+ props?: PropDef[];
41
+ surfaces?: SurfaceDef[];
42
+ lighting?: LightingDef;
43
+ }
44
+
45
+ // --- Kitchen (16:9) ----------------------------------------------------------------------------------
46
+ /** A daytime kitchen seen side-on: back wall with window, counter, fridge; a plant in the foreground. */
47
+ export function kitchen(): CartoonSet {
48
+ const W = 1920, H = 1080;
49
+ const BASE = 790; // where the back wall meets the floor (furniture against the wall stands here)
50
+ const FLOOR = 950; // where the actors' feet stand: in front of the furniture
51
+ const wall = `${rect(-200, -200, W + 400, BASE + 200, "#f3dc9b")}
52
+ ${Array.from({ length: 16 }, (_, i) => `<path d="M${-200 + i * 150} -200 V${BASE}" stroke="#ead08a" stroke-width="22"/>`).join("")}
53
+ ${rect(-200, BASE, W + 400, H - BASE + 200, "#d9a978")}
54
+ ${Array.from({ length: 6 }, (_, i) => `<path d="M-200 ${BASE + 30 + i * i * 14} H${W + 200}" stroke="#c99868" stroke-width="3"/>`).join("")}
55
+ <path d="M-200 ${BASE} H${W + 200}" ${ln}/>`;
56
+ // Window over the sink: sky, two panes, a sill.
57
+ const window = `<g ${ln}>
58
+ ${rect(640, 200, 420, 300, "#bfe4f2")}
59
+ <path d="M850 200 V500 M640 350 H1060"/>
60
+ ${rect(620, 500, 460, 22, "#fff7e6")}</g>
61
+ <ellipse cx="740" cy="270" rx="46" ry="16" fill="#fff"/><ellipse cx="960" cy="420" rx="60" ry="18" fill="#fff"/>`;
62
+ // Counter (hip height for a scale-1 adult: top ≈ 0.5 × 530 px above the wall base) and cabinets.
63
+ const counter = `<g ${ln}>
64
+ ${rect(380, 545, 960, BASE - 545, "#7fb7a6")}
65
+ ${[380, 620, 860, 1100].map((x) => `${rect(x + 14, 575, 212, BASE - 590, "#8fc7b5")}<path d="M${x + 100} 660 h40"/>`).join("")}
66
+ ${rect(360, 530, 1000, 26, "#f7f1e3")}
67
+ ${rect(400, 150, 200, 200, "#8fc7b5")}${rect(1100, 150, 220, 200, "#8fc7b5")}
68
+ <path d="M480 300 h40 M1190 300 h40"/>
69
+ <path d="M760 530 v-40 q0 -30 40 -30 h40" fill="none"/></g>`;
70
+ // Fridge (taller than a person: ≈ 1.2 × 530).
71
+ const fridge = `<g ${ln}>
72
+ ${rect(1480, 140, 280, BASE - 140, "#f7f5f0", 'rx="22"')}
73
+ <path d="M1480 380 H1760 M1510 230 v80 M1510 420 v120"/></g>
74
+ ${rect(1550, 190, 60, 70, "#ff6b5b", `transform="rotate(-6 1580 225)"`)}`;
75
+ return {
76
+ width: W, height: H, background: "#f3dc9b", floor: FLOOR,
77
+ marks: { left: 520, centre: 960, right: 1340 },
78
+ layers: [
79
+ { id: "wall", art: wall, z: -100 },
80
+ { id: "window", art: window, z: -90 },
81
+ { id: "counter", art: counter, z: -80 },
82
+ { id: "fridge", art: fridge, z: -80 },
83
+ // Foreground: in front of the actors (z > 0) and a little nearer (parallax > 1), kept in the
84
+ // corner so it never covers a face. Its pot is cut by the frame edge: it reads as near.
85
+ {
86
+ id: "plant", z: 50, parallax: 1.15,
87
+ art: `<g ${ln}><path d="M70 1080 L90 930 H250 L270 1080 Z" fill="#e0794f"/>
88
+ <path d="M170 930 C120 820 40 800 20 760 C90 770 150 820 170 930 C170 800 220 740 280 720 C260 800 210 860 170 930" fill="#4e9a5b"/></g>`,
89
+ },
90
+ ],
91
+ lighting: {
92
+ lights: [{ id: "key", type: "directional", angle: 60, glow: 0 }],
93
+ shading: { light: "key", color: "#8a5a6a", opacity: 0.18, rimOpacity: 0.35, offset: 5 },
94
+ grade: { color: "#ffd9a0", opacity: 0.12, blend: "soft-light" },
95
+ },
96
+ };
97
+ }
98
+
99
+ // --- Park at night (16:9 or 9:16) ---------------------------------------------------------------------
100
+ /**
101
+ * A park at night on a gentle slope: sky, moon and stars far away (low parallax), tree line in the
102
+ * middle distance, a path the actors walk on (a ground surface), a bench and a street lamp whose
103
+ * bulb is a point light cutting through the ambient darkness. Laid out from the frame size, so it
104
+ * works for 16:9 and 9:16.
105
+ */
106
+ export function parkAtNight(W = 1920, H = 1080, s = H > W ? 1.4 : 1): CartoonSet {
107
+ // `s`: the actor scale the set is drawn for. Things people use (a lamp, a bench) are sized from
108
+ // the characters (a kit adult is ~530 px tall at scale 1), never from the frame.
109
+ const vertical = H > W;
110
+ const FLOOR = Math.round(H * (vertical ? 0.78 : 0.86)); // ground at the middle of the frame
111
+ const slope = Math.round(H * 0.03); // the path rises gently to the right
112
+ const y = (x: number) => FLOOR - (slope * x) / W; // straight slope: easy to place things on
113
+ const pad = 400; // overscan for camera moves and zoom-outs
114
+ const surface = `M${-pad} ${y(-pad)} L${W + pad} ${y(W + pad)}`;
115
+ const LAMP_X = Math.round(W * (vertical ? 0.72 : 0.62));
116
+ const LAMP_H = Math.round(700 * s); // a street lamp: ~1.3 × a person
117
+ const bulb: [number, number] = [LAMP_X, y(LAMP_X) - LAMP_H + 8];
118
+ const stars = Array.from({ length: 70 }, (_, i) => `<circle cx="${((i * 263) % (W + 2 * pad)) - pad}" cy="${(i * 137) % Math.round(FLOOR * 0.55)}" r="${1.5 + (i % 3)}" fill="#fff" opacity="${0.4 + (i % 4) * 0.15}"/>`).join("");
119
+ const trees = Array.from({ length: 9 }, (_, i) => {
120
+ const x = -pad + i * ((W + 2 * pad) / 8), r = 120 + ((i * 53) % 70), top = FLOOR - 260 - ((i * 37) % 80);
121
+ return `<rect x="${x - 14}" y="${top}" width="28" height="${FLOOR - top}" fill="#1c2a3f"/><circle cx="${x}" cy="${top - r * 0.5}" r="${r}" fill="#203553"/>`;
122
+ }).join("");
123
+ const benchX = Math.round(W * (vertical ? 0.2 : 0.22));
124
+ const bw = Math.round(220 * s), bh = Math.round(70 * s); // seat at knee height
125
+ const by = y(benchX + bw / 2);
126
+ return {
127
+ width: W, height: H, background: "#141b33", floor: FLOOR,
128
+ marks: { left: Math.round(W * 0.3), lamp: LAMP_X - Math.round(W * (vertical ? 0.2 : 0.09)), right: Math.round(W * 0.8) },
129
+ layers: [
130
+ { id: "sky", z: -100, parallax: 0, art: `<defs><linearGradient id="nightSky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0f1430"/><stop offset="1" stop-color="#2b3566"/></linearGradient></defs>${rect(0, 0, W, H, "url(#nightSky)")}` },
131
+ { id: "stars", z: -95, parallax: 0.05, art: `${stars}<circle cx="${W * 0.82}" cy="${H * 0.14}" r="${H * 0.055}" fill="#f6efd2"/><circle cx="${W * 0.82 - H * 0.022}" cy="${H * 0.13}" r="${H * 0.05}" fill="#141b33"/>` },
132
+ { id: "trees", z: -80, parallax: 0.5, art: trees },
133
+ {
134
+ id: "ground", z: -60,
135
+ art: `<path d="${surface} V${H + pad} H${-pad} Z" fill="#263f3a"/>
136
+ <path d="M${-pad} ${y(-pad) + 26} L${W + pad} ${y(W + pad) + 26} V${H + pad} H${-pad} Z" fill="#3b4a52"/>
137
+ <path d="${surface}" ${ln} fill="none"/>
138
+ <g ${ln}><path d="M${benchX} ${by - bh} h${bw} M${benchX + 20} ${by - bh} V${by} M${benchX + bw - 20} ${by - bh} V${by} M${benchX} ${by - 1.9 * bh} h${bw}" fill="none" stroke="#7a5a44" stroke-width="${16 * s}"/></g>`,
139
+ },
140
+ ],
141
+ // The lamp is a prop standing on the path (its post's foot at its origin): it can be moved,
142
+ // switched (opacity) or knocked over without redrawing the set.
143
+ props: [{
144
+ id: "lamp", x: LAMP_X, y: y(LAMP_X), z: -10,
145
+ art: `<g ${ln}><rect x="-11" y="${-LAMP_H + 20}" width="22" height="${LAMP_H - 20}" fill="#3c4256"/>
146
+ <rect x="-28" y="-18" width="56" height="18" fill="#3c4256"/>
147
+ <path d="M-42 ${-LAMP_H + 20} L42 ${-LAMP_H + 20} L28 ${-LAMP_H - 30} L-28 ${-LAMP_H - 30} Z" fill="#3c4256"/>
148
+ <ellipse cx="0" cy="${-LAMP_H + 12}" rx="26" ry="12" fill="#ffe9a8"/></g>`,
149
+ }],
150
+ surfaces: [{ id: "path", path: surface }],
151
+ lighting: {
152
+ ambient: { color: "#1c1f55", opacity: 0.5 },
153
+ lights: [
154
+ { id: "bulb", type: "point", x: bulb[0], y: bulb[1], radius: Math.round(560 * s), glow: 0.5, color: "#ffd98a", flicker: { amount: 0.06 } },
155
+ { id: "key", type: "directional", angle: 120, glow: 0 },
156
+ ],
157
+ shading: { light: "key", color: "#2b2a6b", opacity: 0.3, rim: "#ffd98a", rimOpacity: 0.6, offset: 6 },
158
+ vignette: { color: "#000", opacity: 0.35 },
159
+ },
160
+ };
161
+ }
162
+
163
+ // --- Classroom (16:9) --------------------------------------------------------------------------------
164
+ /** A classroom: chalkboard wall, windows with daylight, a clock; a row of desks in the foreground. */
165
+ export function classroom(): CartoonSet {
166
+ const W = 1920, H = 1080;
167
+ const BASE = 780, FLOOR = 930;
168
+ const room = `${rect(-200, -200, W + 400, BASE + 200, "#cfe0d4")}
169
+ ${rect(-200, BASE - 40, W + 400, 40, "#a7bfae")}
170
+ ${rect(-200, BASE, W + 400, H - BASE + 200, "#c58f5e")}
171
+ ${Array.from({ length: 14 }, (_, i) => `<path d="M${-200 + i * 170} ${BASE} L${-420 + i * 210} ${H + 200}" stroke="#b27e50" stroke-width="3"/>`).join("")}
172
+ <path d="M-200 ${BASE} H${W + 200}" ${ln}/>`;
173
+ const windows = `<g ${ln}>${[90, 330].map((x) => `${rect(x, 170, 200, 360, "#bfe4f2")}<path d="M${x + 100} 170 V530 M${x} 350 H${x + 200}"/>`).join("")}</g>`;
174
+ const board = `<g ${ln}>${rect(640, 170, 900, 420, "#2f5446", 'rx="6"')}${rect(630, 590, 920, 18, "#b98c5f")}</g>
175
+ <g fill="none" stroke="#eef3ea" stroke-width="5" stroke-linecap="round" opacity="0.9">
176
+ <text x="720" y="330" font-family="Chalkboard, Comic Sans MS, sans-serif" font-size="96" fill="#eef3ea" stroke="none">2 + 2 = ?</text>
177
+ <circle cx="1300" cy="380" r="90"/><path d="M1210 380 h180 M1300 290 v180"/></g>`;
178
+ const clock = `<g ${ln}><circle cx="1720" cy="230" r="62" fill="#fff7e6"/><path d="M1720 230 V190 M1720 230 L1748 246"/></g>`;
179
+ // Foreground desks: low enough to hide only legs, never faces; nearer than the actors.
180
+ const desk = (x: number) => `<g ${ln}>${rect(x, 905, 380, 28, "#d9a46a", 'rx="6"')}<path d="M${x + 30} 933 V1120 M${x + 350} 933 V1120" stroke-width="14" stroke="#6e5a4a"/>${rect(x + 40, 880, 120, 26, "#f2efe6")}${rect(x + 60, 870, 90, 12, "#ff6b5b")}</g>`;
181
+ return {
182
+ width: W, height: H, background: "#cfe0d4", floor: FLOOR,
183
+ // Heads read best against a plain light wall, not the dark board: the teacher's mark is beside it.
184
+ marks: { teacher: 520, centre: 960, right: 1660 },
185
+ layers: [
186
+ { id: "room", art: room, z: -100 },
187
+ { id: "windows", art: windows, z: -90 },
188
+ { id: "board", art: board, z: -90 },
189
+ { id: "clock", art: clock, z: -90 },
190
+ { id: "desks", art: `${desk(-80)}${desk(1640)}`, z: 50, parallax: 1.2 },
191
+ ],
192
+ lighting: {
193
+ // Daylight from the windows on the left: the key light travels to the right and down.
194
+ lights: [{ id: "sun", type: "directional", angle: 30, glow: 0 }],
195
+ shading: { light: "sun", color: "#5b6f8a", opacity: 0.2, rimOpacity: 0.4, offset: 5 },
196
+ },
197
+ };
198
+ }
199
+
200
+ // --- Rendering ---------------------------------------------------------------------------------------
201
+ const LOOK: CartoonLook = {
202
+ name: "Ana", build: "woman", female: true, skin: "#d9a07e", hair: "bob", hairColor: "#3a2418",
203
+ top: "tee", topColor: "#2ec4b6", bottom: "pants", bottomColor: "#34406b", shoes: "sneakers", shoeColor: "#f4f1ea",
204
+ };
205
+ const characters = { ana: cartoonCharacter(LOOK) };
206
+
207
+ /** A scene of a set, optionally with Ana standing at a mark (scale for a 1080-high wide shot ≈ 1). */
208
+ function sceneOf(set: CartoonSet, actor?: { x: number; scale: number; flip?: boolean }, extra: Partial<SceneDoc> = {}): SceneDoc {
209
+ const onSurface = set.surfaces?.[0];
210
+ return {
211
+ format: "toon-scene", version: 1, width: set.width, height: set.height, fps: 30, duration: 3,
212
+ background: set.background,
213
+ characters: { ana: "inline" }, // the parsed rig is passed in the assets below
214
+ camera: { x: set.width / 2, y: set.height / 2, zoom: 1 },
215
+ world: onSurface ? { surfaces: set.surfaces } : undefined,
216
+ layers: set.layers,
217
+ props: set.props,
218
+ lighting: set.lighting,
219
+ actors: actor ? [{
220
+ id: "ana", character: "ana", x: actor.x, y: set.floor, scale: actor.scale, flip: actor.flip,
221
+ // On a sloped set the surface sets y at the actor's x (the y above is ignored).
222
+ ...(onSurface ? { ground: { surface: onSurface.id } } : {}),
223
+ }] : [],
224
+ script: actor ? ([
225
+ { at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1, fadeIn: 0 },
226
+ ] as ActionDef[]) : [],
227
+ ...extra,
228
+ } as SceneDoc;
229
+ }
230
+
231
+ async function still(name: string, doc: SceneDoc, t = 1) {
232
+ const scene = await prepareScene(doc, { characters });
233
+ const svg = join(OUT, `${name}.svg`);
234
+ writeFileSync(svg, frameToSVG(evaluateScene(scene, t)));
235
+ execFileSync("rsvg-convert", ["-w", String(Math.round(doc.width / 2)), "-o", join(OUT, `${name}.png`), svg]);
236
+ console.log(`out/${name}.png`);
237
+ }
238
+
239
+ if (process.argv[1]?.endsWith("sets.ts")) {
240
+ mkdirSync(OUT, { recursive: true });
241
+ const k = kitchen(), p = parkAtNight(), c = classroom(), pv = parkAtNight(1080, 1920);
242
+ await still("kitchen-empty", sceneOf(k));
243
+ await still("kitchen-actor", sceneOf(k, { x: k.marks.centre, scale: 1 }));
244
+ await still("park-empty", sceneOf(p));
245
+ await still("park-actor", sceneOf(p, { x: p.marks.lamp, scale: 1 }));
246
+ // The same park, with the camera pushed in on Ana (a camera move: the sky stays, trees drift less).
247
+ await still("park-closeup", sceneOf(p, { x: p.marks.lamp, scale: 1 }, {
248
+ script: [
249
+ { at: 0, actor: "ana", action: "play", clip: "idle", loop: true, layer: -1, fadeIn: 0 },
250
+ { at: 0, actor: "ana", action: "lookAt", target: "lamp" },
251
+ { at: 0, action: "camera", frame: ["ana"], on: "face", padding: 220, duration: 3 },
252
+ ] as ActionDef[],
253
+ }), 2.5);
254
+ await still("classroom-empty", sceneOf(c));
255
+ await still("classroom-actor", sceneOf(c, { x: c.marks.teacher, scale: 1 }));
256
+ await still("park-vertical-actor", sceneOf(pv, { x: pv.marks.lamp, scale: 1.4 }));
257
+ }