@anime-studio/cli 0.2.0 → 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.
- package/dist/bin.js +20 -0
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/skills.d.ts +28 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +56 -0
- package/dist/skills.js.map +1 -0
- package/package.json +6 -5
- package/skills/animestudio/SKILL.md +165 -0
- package/skills/animestudio/examples/first-frame.ts +54 -0
- package/skills/animestudio/examples/hello.scene.json +50 -0
- package/skills/animestudio/examples/hello.sequence.json +13 -0
- package/skills/animestudio/examples/remotion/Root.tsx +25 -0
- package/skills/animestudio/examples/remotion/index.ts +5 -0
- package/skills/animestudio/examples/render-video.ts +110 -0
- package/skills/animestudio/references/packages.md +54 -0
- package/skills/animestudio/references/rendering.md +127 -0
- package/skills/animestudio/references/scene-format.md +101 -0
- package/skills/animestudio/references/validation-and-debugging.md +67 -0
- package/skills/animestudio-animation/SKILL.md +176 -0
- package/skills/animestudio-animation/examples/gestures.ts +55 -0
- package/skills/animestudio-animation/examples/hold.ts +82 -0
- package/skills/animestudio-animation/examples/knockdown.ts +68 -0
- package/skills/animestudio-animation/examples/sheet.ts +80 -0
- package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
- package/skills/animestudio-animation/references/clips.md +103 -0
- package/skills/animestudio-animation/references/director-beats.md +48 -0
- package/skills/animestudio-animation/references/holding.md +106 -0
- package/skills/animestudio-animation/references/locomotion.md +86 -0
- package/skills/animestudio-animation/references/timing.md +89 -0
- package/skills/animestudio-characters/SKILL.md +211 -0
- package/skills/animestudio-characters/examples/cast.ts +63 -0
- package/skills/animestudio-characters/examples/human.ts +52 -0
- package/skills/animestudio-characters/examples/import-svg.ts +68 -0
- package/skills/animestudio-characters/examples/lumo.svg +36 -0
- package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
- package/skills/animestudio-characters/examples/sprout.ts +48 -0
- package/skills/animestudio-characters/examples/turnaround.ts +91 -0
- package/skills/animestudio-characters/references/custom-rig.md +139 -0
- package/skills/animestudio-characters/references/import-svg.md +59 -0
- package/skills/animestudio-characters/references/look-options.md +143 -0
- package/skills/animestudio-characters/references/rig-surface.md +62 -0
- package/skills/animestudio-script/SKILL.md +164 -0
- package/skills/animestudio-script/examples/director.ts +143 -0
- package/skills/animestudio-script/examples/sheet.ts +58 -0
- package/skills/animestudio-script/examples/short.ts +193 -0
- package/skills/animestudio-script/references/actions.md +84 -0
- package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
- package/skills/animestudio-script/references/director.md +110 -0
- package/skills/animestudio-script/references/shots-and-editing.md +79 -0
- package/skills/animestudio-script/references/writing-for-animation.md +84 -0
- package/skills/animestudio-sets/SKILL.md +232 -0
- package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
- package/skills/animestudio-sets/examples/render-scene.ts +35 -0
- package/skills/animestudio-sets/examples/sets.ts +257 -0
- package/skills/animestudio-sets/references/drawing-sets.md +119 -0
- package/skills/animestudio-sets/references/fx.md +92 -0
- package/skills/animestudio-sets/references/lighting-camera.md +93 -0
- package/skills/animestudio-sets/references/scene-fields.md +132 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Locomotion: walks, runs and turns
|
|
2
|
+
|
|
3
|
+
Reference: [FORMAT.md §3.3 `walkTo`](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#33-script-actions),
|
|
4
|
+
[AI_GUIDE.md](https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md) (personality walks, runs),
|
|
5
|
+
[DIRECTOR.md → walk/run](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md#beats-do).
|
|
6
|
+
|
|
7
|
+
## `walkTo`
|
|
8
|
+
|
|
9
|
+
`x`, `y?`, `duration` **or** `speed` (px/s, default 220), `clip` (default `walk`), `ease?`.
|
|
10
|
+
|
|
11
|
+
- The body moves on an accelerate–cruise–decelerate profile; the clip plays stride-matched
|
|
12
|
+
(`stride × actor scale` per cycle), so the planted foot stays put. It faces the way it goes.
|
|
13
|
+
- It takes over a move under way from where the actor is (both axes). Do not overlap two walks of
|
|
14
|
+
one actor; chain them (`at` of the second ≥ end of the first).
|
|
15
|
+
- 2.5D rigs: in a three-quarter view the steps look shorter in the picture, so the clip plays
|
|
16
|
+
faster (up to 1.3× its natural rate, then the stride lengthens up to 1.8×). Past that, a little
|
|
17
|
+
slide shows — it means the speed is wrong for the view, not that you should key the feet.
|
|
18
|
+
- A walk that reverses turns through the front (or the back walking away), stepping through the
|
|
19
|
+
drawn angles; set the walk's `view` before the walk starts.
|
|
20
|
+
|
|
21
|
+
## Choosing the gait
|
|
22
|
+
|
|
23
|
+
| Gait | Mood / situation | Speed tip |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `walk` | Default | 150–250 px/s at scale 1 (director: 170) |
|
|
26
|
+
| `sneak` | Creeping up on someone, tiptoeing past | Slow: about half a walk |
|
|
27
|
+
| `strut` | Showing off, confident | Like a walk |
|
|
28
|
+
| `tired` | Exhausted, sad, late at night | Slower than a walk |
|
|
29
|
+
| `march` | Parade, determined | Like a walk, quick cadence |
|
|
30
|
+
| `run` | A hurry, a chase | Natural: `stride × scale / duration` (≈ 720 px/s at scale 1) |
|
|
31
|
+
| `scaredRun` | Fleeing in panic — not for a hurry | Natural (≈ 1600 px/s at scale 1) |
|
|
32
|
+
|
|
33
|
+
Compute a run's speed instead of guessing:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const c = characters.ana.clips!.scaredRun;
|
|
37
|
+
const speed = (c.stride! * SCALE) / c.duration;
|
|
38
|
+
{ at: 5.7, actor: "ana", action: "walkTo", x: -350, clip: "scaredRun", speed }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Much slower and a run plays in slow motion; much faster and the legs blur. Give a run room: at
|
|
42
|
+
natural speed it crosses about two leg lengths per cycle. A character in a `skirt`/`longSkirt`
|
|
43
|
+
runs shorter (a long skirt shuffles) — do not expect a sprinter's stride.
|
|
44
|
+
|
|
45
|
+
## Views for travel
|
|
46
|
+
|
|
47
|
+
| Movement | View |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Walking across the frame | `profile` (three-quarter, face visible) or `q64` |
|
|
50
|
+
| Running across | `q64` (the rig's travel view: side-on, face still showing) or `side` |
|
|
51
|
+
| Walking away into depth | `back`, in-place foreshortened walk (director `cross`) |
|
|
52
|
+
| Walking towards camera | `front` / `half` — the steps foreshorten, keep it short |
|
|
53
|
+
|
|
54
|
+
Set the travel view with a short duration as the walk starts and turn back on arrival:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
{ at: 5.7, actor: "ana", action: "pose", control: "view", value: "q64", duration: 0.2 },
|
|
58
|
+
{ at: 5.7, actor: "ana", action: "walkTo", x: -350, clip: "scaredRun", speed },
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Turning on the spot
|
|
62
|
+
|
|
63
|
+
- `pose view` with a `duration` (0.25–0.5 s) steps through the in-between drawings. Look-at and
|
|
64
|
+
eyes can lead: `lookAt` first, the body 0.1 s later.
|
|
65
|
+
- `face` (`left`/`right`) mirrors at once. In a director staging `face` turns through the angles
|
|
66
|
+
automatically (and `life` blinks on the turn).
|
|
67
|
+
- Turning to the audience to speak: `view: "front"` plus `lookAt: null`.
|
|
68
|
+
|
|
69
|
+
## Following and framing
|
|
70
|
+
|
|
71
|
+
- Track a walker: `{ action: "camera", follow: "ana", offset: [120, 0], deadZone: [60, 0], lookAhead: 0.3 }`.
|
|
72
|
+
- Two-shots: `{ action: "camera", frame: ["ana", "ben"], padding: 120 }` keeps both in during walks.
|
|
73
|
+
|
|
74
|
+
## Entering and leaving
|
|
75
|
+
|
|
76
|
+
- Start off screen (`x` beyond the frame) and `walkTo` in; for runs add `fx` `dust` at
|
|
77
|
+
`anchor: "origin"` on the start and the stop.
|
|
78
|
+
- In a director staging use `enter` / `exit` (the actor is invisible until entering; the camera
|
|
79
|
+
never frames someone not there yet).
|
|
80
|
+
|
|
81
|
+
## Checks
|
|
82
|
+
|
|
83
|
+
- Contact sheet with a floor ruler (`examples/sheet.ts` draws ticks every 80 px): a planted foot
|
|
84
|
+
must stay on the same tick across two frames 0.1 s apart.
|
|
85
|
+
- Arrival spacing: `anchorPosition(scene, id, "head", t)` after the walk; keep a step between
|
|
86
|
+
characters' heads.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Timing and acting
|
|
2
|
+
|
|
3
|
+
Reference: [FORMAT.md §3.8 Cartoon timing](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#38-cartoon-timing),
|
|
4
|
+
[DIRECTOR.md → Staging (`anticipation`, `life`, `arcs`)](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md#staging),
|
|
5
|
+
[API.md → `fluid`](https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md#anime-studiokit).
|
|
6
|
+
|
|
7
|
+
## The settings
|
|
8
|
+
|
|
9
|
+
Scene `animation` (FORMAT §3.8):
|
|
10
|
+
|
|
11
|
+
| Field | Default | Effect |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `twos` | 1 (ones) | Frames per drawing of the characters (2 = on twos); camera, layers, free props stay smooth |
|
|
14
|
+
| `holds` | 0 | Moving holds: a slight seeded drift so held poses never freeze (up to ±1.2 px at 1) |
|
|
15
|
+
| `smear` | 0 | Fast actors stretch along their path; fast limbs get faded multiples |
|
|
16
|
+
| `arcs` | 0 | `reach` blends travel on an arc away from the shoulder/hip |
|
|
17
|
+
| `boil` | 0 | Line boil: outlines wobble every two frames (costly in crowded scenes) |
|
|
18
|
+
|
|
19
|
+
Actors may override: `twos: false` (a clock, a car), `holds: 0` (furniture).
|
|
20
|
+
|
|
21
|
+
Director staging `animation` adds (staged by the director, never written into the scene):
|
|
22
|
+
|
|
23
|
+
| Field | Effect |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `anticipation` (0..1) | Walks and runs lean back before setting off, into the move, past upright on arrival; landings squash; limb moves ≥ 0.25 s overshoot and settle (from 0.5). Gesture clips are untouched (already `fluid`) |
|
|
26
|
+
| `life` (0..1) | Blinks on every head turn, saccades while listening, head nods on stressed words |
|
|
27
|
+
| `arcs` (0..1) | IK moves keyed by the director get an arc |
|
|
28
|
+
|
|
29
|
+
## House style: smooth
|
|
30
|
+
|
|
31
|
+
Render smooth: `twos`, `smear` and `boil` **off** unless the user asks for a hand-drawn look —
|
|
32
|
+
episodes made with these rigs read more fluid without them. `holds` (0.3–0.5), `anticipation`, `life` and `arcs` add acting without stepping the
|
|
33
|
+
motion; prefer them.
|
|
34
|
+
|
|
35
|
+
```jsonc
|
|
36
|
+
"animation": { "holds": 0.4, "arcs": 1 } // scene
|
|
37
|
+
{ "animation": { "holds": 0.4, "arcs": 1, "anticipation": 1, "life": 1 } } // staging
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Principles, applied
|
|
41
|
+
|
|
42
|
+
**Anticipation.** Before a big action, a small one the other way. The kit gestures carry it
|
|
43
|
+
(`fluid()`); for the body, the director's `anticipation`, or in a scene: a reaction `take`-style —
|
|
44
|
+
emotion and a short `fx` 0.05–0.1 s before the move. A punch: guard (`stance`) → `punch`.
|
|
45
|
+
|
|
46
|
+
**Timing and spacing.** Fast in, slow settle. Emotion changes 0.2–0.5 s; a shock 0.05–0.12 s.
|
|
47
|
+
View turns 0.25–0.5 s. Camera moves ≥ 1 s, `sineInOut`. Gesture `fadeIn` 0.15–0.25 s.
|
|
48
|
+
|
|
49
|
+
**Holds.** Let a pose read: 0.4–1 s after a gesture, at least 1.5 s on a K.O. before `getUp`.
|
|
50
|
+
A hold is not a freeze: keep `idle` underneath (and `holds` on).
|
|
51
|
+
|
|
52
|
+
**One clear action at a time.** A character does one readable thing per beat. Stagger secondary
|
|
53
|
+
changes: gaze (t), face (t + 0.05), body (t + 0.1). Two characters: let one act while the other
|
|
54
|
+
reacts — never both gesturing on the same frame.
|
|
55
|
+
|
|
56
|
+
**Contrast of speed.** Slow sneak → sudden `scaredRun`; long hold → quick take. Contrast is
|
|
57
|
+
what makes a beat land.
|
|
58
|
+
|
|
59
|
+
**Overlap and follow-through.** The kit rigs have springs on forearms, head, ponytail and big hair:
|
|
60
|
+
they lag and settle by themselves after a stop. Start the next action slightly before the
|
|
61
|
+
previous one ends (fades overlap) so motion flows.
|
|
62
|
+
|
|
63
|
+
**Arcs.** Hands travel on arcs: `animation.arcs: 1` for `reach` moves.
|
|
64
|
+
|
|
65
|
+
**Reactions.** The listener is half the scene: `lookAt` the speaker, a small emotion change on the
|
|
66
|
+
key word, an `fx` on the surprise. React to the cause *after* it happens (≥ 0.1 s) unless the
|
|
67
|
+
character anticipates it.
|
|
68
|
+
|
|
69
|
+
**Staging.** Profile/three-quarter for action between characters, front for talking to the
|
|
70
|
+
audience, keep screen direction (who is left of whom) across cuts, keep a step between faces.
|
|
71
|
+
|
|
72
|
+
## A reaction beat, timed
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
const T = 5.0; // the noise off screen
|
|
76
|
+
{ at: T - 0.05, actor: "ana", action: "fx", type: "surprise" },
|
|
77
|
+
{ at: T, actor: "ana", action: "lookAt", target: [1400, 360] },
|
|
78
|
+
{ at: T, actor: "ana", action: "pose", control: "emotion", value: "scared", duration: 0.12 },
|
|
79
|
+
{ at: T + 0.05, actor: "ana", action: "pose", control: "view", value: "profile", duration: 0.25 },
|
|
80
|
+
{ at: T + 0.1, actor: "ana", action: "play", clip: "scared", duration: 0.55, fadeIn: 0.08 },
|
|
81
|
+
{ at: T + 0.65, actor: "ana", action: "fx", type: "sweat" },
|
|
82
|
+
{ at: T + 0.75, actor: "ana", action: "walkTo", x: -350, clip: "scaredRun", speed: runSpeed },
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Dialogue gestures
|
|
86
|
+
|
|
87
|
+
Start the gesture slightly before the line it goes with (0.1–0.2 s). Use `talk` (loop) under
|
|
88
|
+
speech for small hands; save big clips (`present`, `pointUp`, `shrug`) for the stressed word. In a
|
|
89
|
+
staging the director adds talking hands and head nods (`life`) for you.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: animestudio-characters
|
|
3
|
+
description: Design and build characters (personagens) for the animeStudio animation engine — a cast from cartoonCharacter(look) or humanCharacter in @anime-studio/kit, a hand-written *.toon.json rig (skeleton, parts, controls, clips), or an SVG drawing imported with import-svg — and check them with a turnaround line-up sheet across views and emotions. Use it whenever you create, restyle, review or debug a character, cast, look, rig, emotions or turnaround for animeStudio.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# animeStudio characters
|
|
7
|
+
|
|
8
|
+
A character is a `*.toon.json` document (`format: "toon"`): palette, art, skeleton, parts, anchors,
|
|
9
|
+
IK, physics, controls, behaviours and clips. Scenes and the director only talk to it through its
|
|
10
|
+
**controls** (`view`, `emotion`, `mouth`, `look`…), **clips** and **anchors**, so a character is done
|
|
11
|
+
when those exist, validate, and look right from every angle you will film it.
|
|
12
|
+
|
|
13
|
+
Pick the path:
|
|
14
|
+
|
|
15
|
+
| You need | Path | Effort |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| A human for a TV-cartoon series (sitcom, family, school, office) | `cartoonCharacter(look)` | minutes |
|
|
18
|
+
| An anime-style hero/villain (spiky hair, capes, glowing eyes), profile + front only | `humanCharacter(look)` | minutes |
|
|
19
|
+
| An animal, creature, object, or a style the kit cannot make | hand-written `*.toon.json` | hours |
|
|
20
|
+
| A character someone already drew | SVG → `importSvg` / `toon import-svg`, then add controls | an hour |
|
|
21
|
+
|
|
22
|
+
Never invent field values, hair names, clip or emotion names: they are closed sets (see
|
|
23
|
+
`references/look-options.md`, `references/rig-surface.md`) and `toon describe` lists what a built
|
|
24
|
+
character really has.
|
|
25
|
+
|
|
26
|
+
## 1. The fast path: `cartoonCharacter`
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { cartoonCharacter, cartoonInfo, type CartoonLook } from "@anime-studio/kit";
|
|
30
|
+
|
|
31
|
+
const rosa: CartoonLook = {
|
|
32
|
+
name: "Rosa", build: "woman", female: true, tall: 1.05, skin: "#d9a07a",
|
|
33
|
+
hair: "bob", hairColor: "#1c1a2e",
|
|
34
|
+
top: "blazer", topColor: "#f3efe6", top2: "#2f7f8f", // blazer: top2 = jacket, topColor = shirt
|
|
35
|
+
bottom: "skirt", bottomColor: "#22414a", shoes: "heels", shoeColor: "#c0392b",
|
|
36
|
+
earrings: true, lipstick: "#b8343c",
|
|
37
|
+
};
|
|
38
|
+
const doc = cartoonCharacter(rosa); // style "modern" by default
|
|
39
|
+
const info = cartoonInfo(doc, rosa); // height, extent, depth… for staging
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Required: `name`, `build`, `skin`, `hair`, `hairColor`, `top`, `topColor`, `bottom`, `bottomColor`,
|
|
43
|
+
`shoes`. Everything else is optional. The value sets, in short (full tables with notes in
|
|
44
|
+
[references/look-options.md](references/look-options.md) — read it before writing a look):
|
|
45
|
+
|
|
46
|
+
- `build`: baby child kid teen woman man big elder · `heavy` 0..1 · `tall` × · `female` · `limbs` thin|normal|thick
|
|
47
|
+
- `hair`: bowl sidePart afro puffs ponytail long perm mullet buzz bald bun braids rollers tuft receding slick bob curtains spiky
|
|
48
|
+
- `jaw`: round square pointy chubby · `nose`: button round long wide
|
|
49
|
+
- `top`: tee stripes polo shirt tank jersey blouse dress overalls jacket cardigan blazer · `top2` · `pattern`: stripes pinstripes checks polka (+ `stripe`, `stripeWidth`)
|
|
50
|
+
- `bottom`: pants shorts bermuda skirt longSkirt · `shoes`: sneakers studded canvas flipflops dress heels sandals (+ `shoeColor`, `socks`)
|
|
51
|
+
- accessories: `hat` (cap capBack flatCap top bowler cowboy, + `hatColor`), `glasses` (true | "sun"), `tie`, `sweater`, `necklace` {kind: pearls|chain}, `suspenders`, `watch`, `apron`, `pocketItem`, `earItem` (pencil|cigarette), `earrings`, `accent`, `cape`, `veil`, `boutonniere`
|
|
52
|
+
- face: `moustache` `goatee` `freckles` `wrinkles` `stubble` `flushed` `lipstick` `hairLine`
|
|
53
|
+
|
|
54
|
+
Traps the types do not show:
|
|
55
|
+
|
|
56
|
+
- `jacket` / `cardigan` / `blazer`: **`top2` is the jacket and its sleeves**, `topColor` the shirt
|
|
57
|
+
in the opening. `overalls`: the bib is `bottomColor`, `topColor` is the shirt under it.
|
|
58
|
+
- `pattern` prints the torso only: a `dress` with a pattern has a plain skirt. An `apron` ends at
|
|
59
|
+
the waist. Prefer `blouse` + `skirt`/`longSkirt` for a printed outfit.
|
|
60
|
+
- `look.limbs` (thickness) is not `CartoonStyle.limbs` (tapered | tube).
|
|
61
|
+
- Anything that belongs to one series (props, sets, names) stays in the series, never in the kit.
|
|
62
|
+
|
|
63
|
+
### Styles
|
|
64
|
+
|
|
65
|
+
`cartoonCharacter(look, { style })`:
|
|
66
|
+
|
|
67
|
+
- `"modern"` (default): natural TV-cartoon figure about five heads tall, big round eyes with dot
|
|
68
|
+
pupils, one thin even ink line, flat colours. Emotions here are subtle (brows and mouth): pair
|
|
69
|
+
them with a gesture clip or an `fx` when they must read at a distance.
|
|
70
|
+
- `"painted"`: the look's own proportions, lines in a dark tone of each colour, cel shadows, fists.
|
|
71
|
+
- `"flat"`: one near-black ink, one line weight, no shadows, tube arms, open hands, bigger heads.
|
|
72
|
+
- a `CartoonStyle` object `{ ink, shade, line, limbs, hands, eyes, posture, proportions, blush }`
|
|
73
|
+
refining `painted` (e.g. `{ proportions: "cartoon", eyes: "big", blush: true }`).
|
|
74
|
+
|
|
75
|
+
Use one style for the whole cast. `pitch` (degrees) matches a room camera looking down.
|
|
76
|
+
|
|
77
|
+
### What the built rig gives you
|
|
78
|
+
|
|
79
|
+
Twelve drawn views on one 2.5D skeleton (`front half q24 profile q50 q64 q77 side q112 away q158
|
|
80
|
+
back`; `profile` = three-quarter facing right is the main one), a `head` control that turns the
|
|
81
|
+
head on its own (`~q50` = mirrored), 15 emotions, a `jaw` gape, a viseme mouth, ~45 clips including
|
|
82
|
+
personality walks (`sneak strut tired march scaredRun`), anchors `head face top eye ear earB mouth
|
|
83
|
+
hand handB fist`, springs on forearms, head, ponytail and big hair. Exact lists:
|
|
84
|
+
[references/rig-surface.md](references/rig-surface.md) (read it when scripting the character).
|
|
85
|
+
Facing left is the actor's `flip`, not a view.
|
|
86
|
+
|
|
87
|
+
### Tune the anatomy (never hack the drawing code)
|
|
88
|
+
|
|
89
|
+
Body and face proportions live in one editable document. Start from the **styled** anatomy, or the
|
|
90
|
+
style's proportions are lost:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { cartoonAnatomy, styledAnatomy, checkAnatomy, cartoonCharacter } from "@anime-studio/kit";
|
|
94
|
+
const a = structuredClone(styledAnatomy(cartoonAnatomy(look), "modern", look));
|
|
95
|
+
a.body.head *= 1.15; // bigger head
|
|
96
|
+
console.log(checkAnatomy(a)); // [] or { severity, rule, message } per broken rule
|
|
97
|
+
const doc = cartoonCharacter(look, { style: "modern", anatomy: a }); // throws on errors
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`body` (hip, torso, neck, head, shoulders, waist, hips, depth, arm), `limbs`, `face` (in head
|
|
101
|
+
radii: eyeY, eyeX, eye, pupil, brow, noseY, nose, mouthY, mouthW…), `physics`. Per-view mouth
|
|
102
|
+
problems that were auto-corrected are listed in `doc.meta.anatomyIssues`.
|
|
103
|
+
|
|
104
|
+
## 2. `humanCharacter` (anime-style)
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { humanCharacter } from "@anime-studio/kit";
|
|
108
|
+
const hiro = humanCharacter({ name: "Hiro", skin: "#f1c7a3", hair: "spiky", hairColor: "#2a2f6b",
|
|
109
|
+
iris: "#3b8fd9", outfit: "hoodie", top: "#e2543a", pants: "#2c2f3a", shoes: "#f2f2f2", scarf: "#f2c14e" });
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`hair`: spiky mane messy ponytail cap short curly hood · `outfit`: tee hoodie gi coat armor · plus
|
|
113
|
+
`hairTip`, `topDark`, `accent`, `glasses`, `glow` (villain eyes), `headband`, `scarf`, `cape`,
|
|
114
|
+
`bulk`. Views are `profile` and `front` only (no back). It lacks the cartoon's prop clips
|
|
115
|
+
(`texting`, `carry`, `gamepad`…) and the `annoyed` / `gape` emotions. Run `examples/human.ts`.
|
|
116
|
+
|
|
117
|
+
## 3. Design a cast that reads
|
|
118
|
+
|
|
119
|
+
Do this before writing looks, then verify on the sheet:
|
|
120
|
+
|
|
121
|
+
1. **Silhouette first.** Fill every character black in your head: each must be recognisable.
|
|
122
|
+
Vary `build`, `tall`, `heavy` and above all the hair mass (`afro`, `perm`, `puffs`, `bun`,
|
|
123
|
+
`spiky` vs `buzz`, `bob`, `bald`) and hats. No two characters share build + hair outline.
|
|
124
|
+
2. **One dominant hue per character**, spread round the colour wheel, with a value contrast
|
|
125
|
+
between top and bottom. Avoid neighbours in the same hue and skin-coloured clothes.
|
|
126
|
+
3. **One signature detail** each (glasses, a cap, pearls, heels, a moustache): it carries the
|
|
127
|
+
identity at thumbnail size and survives the back view.
|
|
128
|
+
4. **Contrast in pairs.** The characters who share most scenes should differ most (tall/short,
|
|
129
|
+
round/angular, warm/cool).
|
|
130
|
+
5. **Readable small.** Faces are tiny in wide shots; identity must come from shape and colour.
|
|
131
|
+
6. Give the face what the personality needs (`jaw`, `nose`, `wrinkles`, `freckles`, `stubble`):
|
|
132
|
+
these show in close-ups, not in the line-up.
|
|
133
|
+
|
|
134
|
+
## 4. Check it: render the sheet and LOOK
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx tsx skills/animestudio-characters/examples/cast.ts # writes out/<id>.toon.json, prints sizes
|
|
138
|
+
npx tsx skills/animestudio-characters/examples/turnaround.ts # [style] [views|all]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Then open with your image viewer (the Read tool for agents) `out/lineup.png`, `out/lineup-small.png`
|
|
142
|
+
(360 px wide), every `out/turn-<id>.png` and `out/emotions.png`. Check:
|
|
143
|
+
|
|
144
|
+
- each character is identifiable in `lineup-small.png`; heights and widths differ;
|
|
145
|
+
- the views agree (hair, hat, glasses, prints hold from `front` to `back`; the back view still says
|
|
146
|
+
who it is);
|
|
147
|
+
- emotions differ in the zoomed rows; colours do not clash with the set you will use;
|
|
148
|
+
- no anatomy issues printed by `cast.ts`; then `toon validate` and `toon describe` each file.
|
|
149
|
+
|
|
150
|
+
How the sheet works: one scene with one actor per cell, each playing `idle` on `layer: -1` and set
|
|
151
|
+
instantly (`duration: 0`) to a `view` and an `emotion`, evaluated at one time with
|
|
152
|
+
`prepareScene` + `evaluateScene`, `frameToSVG`, then `rsvg-convert` and `magick -append`. Zoomed
|
|
153
|
+
rows use a camera `zoom` with the actors spaced by `cellW / zoom`. Copy it for clips (`play` a clip
|
|
154
|
+
and pick the time) or for a new cast.
|
|
155
|
+
|
|
156
|
+
## 5. The custom path: a hand-written `*.toon.json`
|
|
157
|
+
|
|
158
|
+
Read [references/custom-rig.md](references/custom-rig.md) first, then FORMAT
|
|
159
|
+
[§2](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#2-character-document-toonjson)
|
|
160
|
+
and AI_GUIDE ["Writing characters"](https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md#writing-characters).
|
|
161
|
+
Start from `examples/sprout.toon.json` (a complete small creature) and check it with
|
|
162
|
+
`examples/sprout.ts`. The essentials:
|
|
163
|
+
|
|
164
|
+
- Setup space: ground at y = 0, facing right, y down, degrees clockwise; bones in setup form
|
|
165
|
+
(`from` / `to`), parents first; slight knee bend at rest.
|
|
166
|
+
- Parts in draw order: `rigid`, `switch` (eyes, hands, views), `morph` (mouth `A`–`H` + `smile` /
|
|
167
|
+
`frown`, every shape the same command structure), `hose` (limbs), `skinned`, `hull`.
|
|
168
|
+
- `palette(name)` for every colour; anchors `head`, `hand`, `handB`.
|
|
169
|
+
- Controls named `mouth` (viseme), `look` (aim; a head drawn pointing up takes `forward: 90`),
|
|
170
|
+
`emotion` (pose); behaviours `blink` + `breathe`; springs on ears, tails, leaves.
|
|
171
|
+
- Clips: `idle` (loop, same first and last values) at least; `stride` on walks.
|
|
172
|
+
|
|
173
|
+
## 6. Importing an SVG drawing
|
|
174
|
+
|
|
175
|
+
Name the layers (`bone:neck1@root`, `part:head@shade`, `switch:eyes/open@shade`,
|
|
176
|
+
`skin:neck@neck1,neck2`, `anchor:head@shade`, `origin`) and run
|
|
177
|
+
`toon import-svg drawing.svg --name lumo -o lumo.toon.json` or `importSvg(svg, { name })`. You get a
|
|
178
|
+
skeleton, parts and anchors, no controls or clips: add those as in section 5. Details and drawing
|
|
179
|
+
rules: [references/import-svg.md](references/import-svg.md); example: `examples/import-svg.ts`.
|
|
180
|
+
|
|
181
|
+
## 7. Know what a character can do: `toon describe`
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npx tsx packages/cli/src/bin.ts describe skills/animestudio-characters/examples/out/rosa.toon.json
|
|
185
|
+
# in a project: npx @anime-studio/cli describe rosa.toon.json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
It lists the controls with their values, clips (duration, loop, stride), anchors and every channel.
|
|
189
|
+
Paste it into the prompt of whoever writes the scene; `validate` before every hand-off.
|
|
190
|
+
|
|
191
|
+
## Hands and props
|
|
192
|
+
|
|
193
|
+
Props in the hands (phones, books, boxes) use the kit's `HOLD` presets, `holdFit`, `holdBoth`,
|
|
194
|
+
`boxFit` and the scene's `grab` — that is scene work: see the `animestudio-animation` skill and
|
|
195
|
+
FORMAT [§2.6](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#26-anchors).
|
|
196
|
+
For a custom rig, give each hand a `switch` with `open`, `fist`, `point`, `grip` variants and a
|
|
197
|
+
`hand` / `handB` anchor so grabs work.
|
|
198
|
+
|
|
199
|
+
## Examples in this skill
|
|
200
|
+
|
|
201
|
+
All run from the repo root with `npx tsx skills/animestudio-characters/examples/<file>.ts` and write
|
|
202
|
+
only to `skills/animestudio-characters/examples/out/`. `rsvg-convert` is required for PNGs,
|
|
203
|
+
ImageMagick `magick` is optional.
|
|
204
|
+
|
|
205
|
+
| File | Shows |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `cast.ts` | four contrasting original characters (`LOOKS`), written as `.toon.json` with measurements |
|
|
208
|
+
| `turnaround.ts` | the line-up, small line-up, per-character turnaround and zoomed emotion sheets |
|
|
209
|
+
| `human.ts` | `humanCharacter`: views, emotions and clips listed, a strip rendered |
|
|
210
|
+
| `sprout.toon.json` + `sprout.ts` | a complete hand-written rig, validated and rendered (emotions, wave, hop, a viseme) |
|
|
211
|
+
| `lumo.svg` + `import-svg.ts` | a named SVG drawing imported, completed with controls and clips, rendered |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small original cast built with the fast path, `cartoonCharacter(look)`.
|
|
3
|
+
*
|
|
4
|
+
* Run from the repo root: npx tsx skills/animestudio-characters/examples/cast.ts [style]
|
|
5
|
+
* (style: modern — the default —, painted or flat). Writes one `<id>.toon.json` per character to
|
|
6
|
+
* skills/animestudio-characters/examples/out/ and prints each one's measurements and anatomy issues.
|
|
7
|
+
*
|
|
8
|
+
* The cast is designed for contrast: four heights and builds, four hair silhouettes, one dominant
|
|
9
|
+
* hue each (teal, green, red, orange), and one signature accessory each (heels, glasses, cap, pearls),
|
|
10
|
+
* so every character reads at thumbnail size and in a crowd.
|
|
11
|
+
*/
|
|
12
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import type { ToonDoc } from "@anime-studio/core";
|
|
16
|
+
import { type CartoonLook, type CartoonOptions, cartoonCharacter, cartoonInfo } from "@anime-studio/kit";
|
|
17
|
+
|
|
18
|
+
export const LOOKS: Record<string, CartoonLook> = {
|
|
19
|
+
// Tall, slim, sharp: a bob, a blazer and heels. Teal + a red accent.
|
|
20
|
+
// (jacket / cardigan / blazer: `top2` is the jacket and its sleeves, `topColor` the shirt in the opening.)
|
|
21
|
+
rosa: {
|
|
22
|
+
name: "Rosa", build: "woman", female: true, tall: 1.05, skin: "#d9a07a", hair: "bob", hairColor: "#1c1a2e",
|
|
23
|
+
top: "blazer", topColor: "#f3efe6", top2: "#2f7f8f", bottom: "skirt", bottomColor: "#22414a",
|
|
24
|
+
shoes: "heels", shoeColor: "#c0392b", earrings: true, lipstick: "#b8343c", nose: "button",
|
|
25
|
+
},
|
|
26
|
+
// Small and round-faced: big light hair, glasses, freckles. Green.
|
|
27
|
+
theo: {
|
|
28
|
+
name: "Theo", build: "kid", skin: "#f1c9a5", hair: "curtains", hairColor: "#d08a2e", jaw: "chubby",
|
|
29
|
+
top: "polo", topColor: "#6cbf4f", bottom: "bermuda", bottomColor: "#c8a16a",
|
|
30
|
+
shoes: "canvas", shoeColor: "#e64a3b", socks: "#ffffff", glasses: true, freckles: true,
|
|
31
|
+
},
|
|
32
|
+
// Wide and heavy: square jaw, flat cap, checked shirt, stubble. Red.
|
|
33
|
+
gus: {
|
|
34
|
+
name: "Gus", build: "big", heavy: 0.7, skin: "#c98a62", hair: "buzz", hairColor: "#3a2a20", jaw: "square", nose: "wide",
|
|
35
|
+
top: "shirt", topColor: "#c4473a", top2: "#f1d9a6", pattern: "checks", bottom: "pants", bottomColor: "#3d4a5c",
|
|
36
|
+
shoes: "dress", shoeColor: "#3b2a24", hat: "flatCap", hatColor: "#6a5a48", stubble: true, earItem: "pencil",
|
|
37
|
+
},
|
|
38
|
+
// Short and stooped: a big white perm, a polka-dot blouse, a long skirt, pearls. Orange.
|
|
39
|
+
// (A `pattern` prints the torso only: on a `dress` the skirt stays plain, so prefer a blouse + skirt.)
|
|
40
|
+
ida: {
|
|
41
|
+
name: "Ida", build: "elder", female: true, skin: "#f3d2bd", hair: "perm", hairColor: "#e6e3ee", nose: "round",
|
|
42
|
+
top: "blouse", topColor: "#e8913a", pattern: "polka", stripe: "#fff4dc", bottom: "longSkirt", bottomColor: "#7a4a2a",
|
|
43
|
+
shoes: "sandals", shoeColor: "#5a3a22", wrinkles: true, necklace: { kind: "pearls" },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const cast = (style?: CartoonOptions["style"]): Record<string, ToonDoc> =>
|
|
48
|
+
Object.fromEntries(Object.entries(LOOKS).map(([id, look]) => [id, cartoonCharacter(look, style ? { style } : {})]));
|
|
49
|
+
|
|
50
|
+
// Run as a script: write the documents and print what the director will read.
|
|
51
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
52
|
+
const style = process.argv[2] as CartoonOptions["style"] | undefined;
|
|
53
|
+
const out = join(dirname(fileURLToPath(import.meta.url)), "out");
|
|
54
|
+
mkdirSync(out, { recursive: true });
|
|
55
|
+
for (const [id, doc] of Object.entries(cast(style))) {
|
|
56
|
+
const file = join(out, `${id}.toon.json`);
|
|
57
|
+
writeFileSync(file, JSON.stringify(doc));
|
|
58
|
+
const info = cartoonInfo(doc, LOOKS[id], style ? { style } : {});
|
|
59
|
+
const issues = (doc.meta as { anatomyIssues?: unknown[] }).anatomyIssues ?? [];
|
|
60
|
+
console.log(`${id.padEnd(5)} height ${info.height.toFixed(0).padStart(4)} legs ${info.legLength.F.toFixed(0)} ` +
|
|
61
|
+
`extent ${info.extent.front.toFixed(0)}/${info.extent.back.toFixed(0)} anatomy issues ${issues.length} → ${file}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The other kit builder: `humanCharacter(look)` — an anime-style human with a profile and a front
|
|
3
|
+
* view (no back drawing), the fighting set and flowing hair/cape physics.
|
|
4
|
+
*
|
|
5
|
+
* Run from the repo root: npx tsx skills/animestudio-characters/examples/human.ts
|
|
6
|
+
* Needs `rsvg-convert`. Writes out/hiro.toon.json and out/hiro.png (profile, front, punch, happy).
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { dirname, join } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
import { type SceneDoc, evaluateScene, frameToSVG } from "@anime-studio/core";
|
|
13
|
+
import { prepareScene } from "@anime-studio/rigid";
|
|
14
|
+
import { type HumanLook, humanCharacter } from "@anime-studio/kit";
|
|
15
|
+
|
|
16
|
+
const OUT = join(dirname(fileURLToPath(import.meta.url)), "out");
|
|
17
|
+
mkdirSync(OUT, { recursive: true });
|
|
18
|
+
|
|
19
|
+
const look: HumanLook = {
|
|
20
|
+
name: "Hiro", skin: "#f1c7a3", hair: "spiky", hairColor: "#2a2f6b", hairTip: "#4b5bd1", iris: "#3b8fd9",
|
|
21
|
+
outfit: "hoodie", top: "#e2543a", pants: "#2c2f3a", shoes: "#f2f2f2", scarf: "#f2c14e",
|
|
22
|
+
};
|
|
23
|
+
const hiro = humanCharacter(look);
|
|
24
|
+
writeFileSync(join(OUT, "hiro.toon.json"), JSON.stringify(hiro));
|
|
25
|
+
const d = hiro as unknown as { controls: Record<string, { poses?: object }>; clips: object };
|
|
26
|
+
console.log("views:", Object.keys(d.controls.view?.poses ?? {}).join(" "));
|
|
27
|
+
console.log("emotions:", Object.keys(d.controls.emotion?.poses ?? {}).join(" "));
|
|
28
|
+
console.log("clips:", Object.keys(d.clips).join(" "));
|
|
29
|
+
|
|
30
|
+
const cells = [
|
|
31
|
+
{ label: "profile", view: "profile" }, { label: "front", view: "front" },
|
|
32
|
+
{ label: "punch", view: "profile", clip: "punch" }, { label: "happy", view: "front", emotion: "happy" },
|
|
33
|
+
];
|
|
34
|
+
const cellW = 300, W = cellW * cells.length, H = 640, floor = 580;
|
|
35
|
+
const scene = {
|
|
36
|
+
format: "toon-scene", version: 1, width: W, height: H, fps: 30, duration: 2, background: "#f6efe0",
|
|
37
|
+
characters: { hiro: "hiro.toon.json" },
|
|
38
|
+
camera: { x: W / 2, y: H / 2, zoom: 1 },
|
|
39
|
+
layers: [{ id: "floor", art: `<rect x="0" y="${floor}" width="${W}" height="${H - floor}" fill="#e3d4b5"/>` +
|
|
40
|
+
cells.map((c, i) => `<text x="${cellW * i + cellW / 2}" y="${floor + 40}" font-family="sans-serif" font-size="24" text-anchor="middle" fill="#5a4a3a">${c.label}</text>`).join("") }],
|
|
41
|
+
actors: cells.map((_, i) => ({ id: `h${i}`, character: "hiro", x: cellW * i + cellW / 2, y: floor, z: 1 })),
|
|
42
|
+
script: cells.flatMap((c, i) => [
|
|
43
|
+
{ at: 0, actor: `h${i}`, action: "play", clip: "idle", loop: true, layer: -1 },
|
|
44
|
+
{ at: 0, actor: `h${i}`, action: "pose", control: "view", value: c.view, duration: 0 },
|
|
45
|
+
...(c.emotion ? [{ at: 0, actor: `h${i}`, action: "pose", control: "emotion", value: c.emotion, duration: 0 }] : []),
|
|
46
|
+
...(c.clip ? [{ at: 0, actor: `h${i}`, action: "play", clip: c.clip }] : []),
|
|
47
|
+
]),
|
|
48
|
+
} as unknown as SceneDoc;
|
|
49
|
+
const frame = evaluateScene(await prepareScene(scene, { characters: { hiro } }), 0.28);
|
|
50
|
+
writeFileSync(join(OUT, "hiro.svg"), frameToSVG(frame));
|
|
51
|
+
execFileSync("rsvg-convert", ["-w", String(W), "-o", join(OUT, "hiro.png"), join(OUT, "hiro.svg")]);
|
|
52
|
+
console.log("wrote", join(OUT, "hiro.png"));
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An SVG drawing → a character: import lumo.svg, then add what a drawing cannot carry (behaviours,
|
|
3
|
+
* controls, clips), validate it and render a strip to LOOK at.
|
|
4
|
+
*
|
|
5
|
+
* Run from the repo root: npx tsx skills/animestudio-characters/examples/import-svg.ts
|
|
6
|
+
* Needs `rsvg-convert`. Writes out/lumo.imported.toon.json (raw import), out/lumo.toon.json (finished)
|
|
7
|
+
* and out/lumo.png.
|
|
8
|
+
*
|
|
9
|
+
* The CLI does the same import: `toon import-svg lumo.svg --name lumo -o lumo.toon.json`.
|
|
10
|
+
*/
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import { type SceneDoc, type ToonDoc, evaluateScene, frameToSVG, parseToon } from "@anime-studio/core";
|
|
16
|
+
import { importSvg } from "@anime-studio/import-svg";
|
|
17
|
+
import { prepareScene } from "@anime-studio/rigid";
|
|
18
|
+
|
|
19
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const OUT = join(HERE, "out");
|
|
21
|
+
mkdirSync(OUT, { recursive: true });
|
|
22
|
+
|
|
23
|
+
// 1. Import: skeleton, parts (rigid / switch / skinned) and anchors come from the drawing's names.
|
|
24
|
+
const imported = importSvg(readFileSync(join(HERE, "lumo.svg"), "utf8"), { name: "lumo" });
|
|
25
|
+
for (const w of imported.warnings) console.warn(`warn ${w}`);
|
|
26
|
+
writeFileSync(join(OUT, "lumo.imported.toon.json"), JSON.stringify(imported.doc, null, 2));
|
|
27
|
+
const doc = imported.doc as ToonDoc;
|
|
28
|
+
|
|
29
|
+
// 2. Add life: a blink, an emotion-ish pose control, a looping idle and a nod.
|
|
30
|
+
doc.meta = { description: "A desk-lamp creature imported from an SVG drawing. Facing right." };
|
|
31
|
+
doc.behaviors = [{ type: "blink", id: "blink", part: "eyes", open: "open", closed: "closed", interval: [2, 4], duration: 0.15 }];
|
|
32
|
+
doc.controls = {
|
|
33
|
+
emotion: { type: "pose", poses: {
|
|
34
|
+
neutral: {},
|
|
35
|
+
curious: { "bones.shade.rotation": -15, "bones.neck2.rotation": -8 },
|
|
36
|
+
sad: { "bones.neck1.rotation": 10, "bones.neck2.rotation": 35, "bones.shade.rotation": 30, "parts.eyes.variant": "closed" },
|
|
37
|
+
} },
|
|
38
|
+
};
|
|
39
|
+
doc.clips = {
|
|
40
|
+
idle: { duration: 2.4, loop: true, tracks: { "bones.neck2.rotation": [[0, 0], [1.2, 3], [2.4, 0]], "bones.shade.rotation": [[0, 0], [1.2, -3], [2.4, 0]] } },
|
|
41
|
+
nod: { duration: 0.8, tracks: { "bones.shade.rotation": [[0, 0], [0.2, 20, "easeOut"], [0.4, -6], [0.6, 10], [0.8, 0]] } },
|
|
42
|
+
};
|
|
43
|
+
// A small spring on the shade for follow-through when the neck moves.
|
|
44
|
+
doc.physics = [{ type: "spring", bones: ["shade"], stiffness: 0.55, damping: 0.35 }];
|
|
45
|
+
|
|
46
|
+
const lumo = parseToon(doc); // throws with every issue listed if something is wrong
|
|
47
|
+
writeFileSync(join(OUT, "lumo.toon.json"), JSON.stringify(lumo, null, 2));
|
|
48
|
+
|
|
49
|
+
// 3. Render: rest, curious, sad, mid-nod.
|
|
50
|
+
const cells = [{ label: "neutral" }, { label: "curious", emotion: "curious" }, { label: "sad", emotion: "sad" }, { label: "nod", clip: "nod" }];
|
|
51
|
+
const cellW = 260, W = cellW * cells.length, H = 340, floor = 290;
|
|
52
|
+
const scene = {
|
|
53
|
+
format: "toon-scene", version: 1, width: W, height: H, fps: 30, duration: 2, background: "#f6efe0",
|
|
54
|
+
characters: { lumo: "lumo.toon.json" },
|
|
55
|
+
camera: { x: W / 2, y: H / 2, zoom: 1 },
|
|
56
|
+
layers: [{ id: "floor", art: `<rect x="0" y="${floor}" width="${W}" height="${H - floor}" fill="#e3d4b5"/>` +
|
|
57
|
+
cells.map((c, i) => `<text x="${cellW * i + cellW / 2}" y="${floor + 34}" font-family="sans-serif" font-size="22" text-anchor="middle" fill="#5a4a3a">${c.label}</text>`).join("") }],
|
|
58
|
+
actors: cells.map((_, i) => ({ id: `l${i}`, character: "lumo", x: cellW * i + cellW / 2, y: floor, z: 1 })),
|
|
59
|
+
script: cells.flatMap((c, i) => [
|
|
60
|
+
{ at: 0, actor: `l${i}`, action: "play", clip: "idle", loop: true, layer: -1 },
|
|
61
|
+
...(c.emotion ? [{ at: 0, actor: `l${i}`, action: "pose", control: "emotion", value: c.emotion, duration: 0 }] : []),
|
|
62
|
+
...(c.clip ? [{ at: 0, actor: `l${i}`, action: "play", clip: c.clip }] : []),
|
|
63
|
+
]),
|
|
64
|
+
} as unknown as SceneDoc;
|
|
65
|
+
const frame = evaluateScene(await prepareScene(scene, { characters: { lumo } }), 0.2);
|
|
66
|
+
writeFileSync(join(OUT, "lumo.svg"), frameToSVG(frame));
|
|
67
|
+
execFileSync("rsvg-convert", ["-w", String(W), "-o", join(OUT, "lumo.png"), join(OUT, "lumo.svg")]);
|
|
68
|
+
console.log("wrote", join(OUT, "lumo.toon.json"), "and", join(OUT, "lumo.png"));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 260" width="200" height="260">
|
|
2
|
+
<!-- A desk-lamp creature drawn for @anime-studio/import-svg. Names are ids (Inkscape labels and
|
|
3
|
+
data-name work too). Facing right; the origin circle marks the ground point between the feet. -->
|
|
4
|
+
<circle id="origin" cx="100" cy="250" r="2" fill="none"/>
|
|
5
|
+
|
|
6
|
+
<!-- Bones: a <line> from joint to tip; "@parent" links it. Parents may come in any order. -->
|
|
7
|
+
<line id="bone:root" x1="100" y1="250" x2="100" y2="236" stroke="none"/>
|
|
8
|
+
<line id="bone:neck1@root" x1="100" y1="236" x2="92" y2="170" stroke="none"/>
|
|
9
|
+
<line id="bone:neck2@neck1" x1="92" y1="170" x2="112" y2="110" stroke="none"/>
|
|
10
|
+
<line id="bone:shade@neck2" x1="112" y1="110" x2="150" y2="96" stroke="none"/>
|
|
11
|
+
|
|
12
|
+
<!-- A skin: one path bent by two bones (weights by distance to each bone). -->
|
|
13
|
+
<path id="skin:neck@neck1,neck2" d="M96 236 L88 170 L108 110 L116 112 L96 170 L104 236 Z" fill="#9aa3b5" stroke="#2b2633" stroke-width="3" stroke-linejoin="round"/>
|
|
14
|
+
|
|
15
|
+
<!-- Rigid parts: any element or group, attached to one bone. Later = drawn on top. -->
|
|
16
|
+
<g id="part:base@root">
|
|
17
|
+
<ellipse cx="100" cy="244" rx="46" ry="10" fill="#4b5470" stroke="#2b2633" stroke-width="3"/>
|
|
18
|
+
</g>
|
|
19
|
+
<g id="part:head@shade">
|
|
20
|
+
<path d="M104 92 L150 70 L176 112 L124 124 Z" fill="#f2c14e" stroke="#2b2633" stroke-width="3" stroke-linejoin="round"/>
|
|
21
|
+
<circle cx="112" cy="110" r="8" fill="#4b5470" stroke="#2b2633" stroke-width="3"/>
|
|
22
|
+
</g>
|
|
23
|
+
|
|
24
|
+
<!-- A switch: variants of one part ("switch:<part>/<variant>@<bone>", the first is the default). -->
|
|
25
|
+
<g id="switch:eyes/open@shade">
|
|
26
|
+
<circle cx="140" cy="90" r="7" fill="#fff" stroke="#2b2633" stroke-width="2.5"/>
|
|
27
|
+
<circle cx="142" cy="90" r="3" fill="#2b2633"/>
|
|
28
|
+
</g>
|
|
29
|
+
<g id="switch:eyes/closed@shade">
|
|
30
|
+
<path d="M133 91 Q140 95 147 91" fill="none" stroke="#2b2633" stroke-width="3" stroke-linecap="round"/>
|
|
31
|
+
</g>
|
|
32
|
+
|
|
33
|
+
<!-- Anchors: a <circle> marking a named point on a bone. -->
|
|
34
|
+
<circle id="anchor:head@shade" cx="140" cy="96" r="2" fill="none"/>
|
|
35
|
+
<circle id="anchor:light@shade" cx="160" cy="118" r="2" fill="none"/>
|
|
36
|
+
</svg>
|