@anime-studio/cli 0.2.0 → 0.3.0

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 (82) hide show
  1. package/dist/bin.js +74 -2
  2. package/dist/bin.js.map +1 -1
  3. package/dist/doctor.d.ts +8 -1
  4. package/dist/doctor.d.ts.map +1 -1
  5. package/dist/doctor.js +30 -5
  6. package/dist/doctor.js.map +1 -1
  7. package/dist/index.d.ts +6 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +6 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/mix.d.ts +21 -0
  12. package/dist/mix.d.ts.map +1 -0
  13. package/dist/mix.js +95 -0
  14. package/dist/mix.js.map +1 -0
  15. package/dist/raster.d.ts +63 -0
  16. package/dist/raster.d.ts.map +1 -0
  17. package/dist/raster.js +145 -0
  18. package/dist/raster.js.map +1 -0
  19. package/dist/render-worker.d.ts +27 -0
  20. package/dist/render-worker.d.ts.map +1 -0
  21. package/dist/render-worker.js +33 -0
  22. package/dist/render-worker.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/dist/video.d.ts +64 -0
  28. package/dist/video.d.ts.map +1 -0
  29. package/dist/video.js +221 -0
  30. package/dist/video.js.map +1 -0
  31. package/package.json +7 -5
  32. package/skills/animestudio/SKILL.md +168 -0
  33. package/skills/animestudio/examples/first-frame.ts +54 -0
  34. package/skills/animestudio/examples/hello.scene.json +50 -0
  35. package/skills/animestudio/examples/hello.sequence.json +13 -0
  36. package/skills/animestudio/examples/remotion/Root.tsx +25 -0
  37. package/skills/animestudio/examples/remotion/index.ts +5 -0
  38. package/skills/animestudio/examples/render-video.ts +110 -0
  39. package/skills/animestudio/references/packages.md +54 -0
  40. package/skills/animestudio/references/rendering.md +148 -0
  41. package/skills/animestudio/references/scene-format.md +101 -0
  42. package/skills/animestudio/references/validation-and-debugging.md +66 -0
  43. package/skills/animestudio-animation/SKILL.md +177 -0
  44. package/skills/animestudio-animation/examples/gestures.ts +55 -0
  45. package/skills/animestudio-animation/examples/hold.ts +82 -0
  46. package/skills/animestudio-animation/examples/knockdown.ts +68 -0
  47. package/skills/animestudio-animation/examples/sheet.ts +80 -0
  48. package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
  49. package/skills/animestudio-animation/references/clips.md +103 -0
  50. package/skills/animestudio-animation/references/director-beats.md +48 -0
  51. package/skills/animestudio-animation/references/holding.md +106 -0
  52. package/skills/animestudio-animation/references/locomotion.md +86 -0
  53. package/skills/animestudio-animation/references/timing.md +89 -0
  54. package/skills/animestudio-characters/SKILL.md +211 -0
  55. package/skills/animestudio-characters/examples/cast.ts +63 -0
  56. package/skills/animestudio-characters/examples/human.ts +52 -0
  57. package/skills/animestudio-characters/examples/import-svg.ts +68 -0
  58. package/skills/animestudio-characters/examples/lumo.svg +36 -0
  59. package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
  60. package/skills/animestudio-characters/examples/sprout.ts +48 -0
  61. package/skills/animestudio-characters/examples/turnaround.ts +91 -0
  62. package/skills/animestudio-characters/references/custom-rig.md +139 -0
  63. package/skills/animestudio-characters/references/import-svg.md +59 -0
  64. package/skills/animestudio-characters/references/look-options.md +143 -0
  65. package/skills/animestudio-characters/references/rig-surface.md +62 -0
  66. package/skills/animestudio-script/SKILL.md +164 -0
  67. package/skills/animestudio-script/examples/director.ts +143 -0
  68. package/skills/animestudio-script/examples/sheet.ts +58 -0
  69. package/skills/animestudio-script/examples/short.ts +193 -0
  70. package/skills/animestudio-script/references/actions.md +84 -0
  71. package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
  72. package/skills/animestudio-script/references/director.md +110 -0
  73. package/skills/animestudio-script/references/shots-and-editing.md +79 -0
  74. package/skills/animestudio-script/references/writing-for-animation.md +84 -0
  75. package/skills/animestudio-sets/SKILL.md +232 -0
  76. package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
  77. package/skills/animestudio-sets/examples/render-scene.ts +35 -0
  78. package/skills/animestudio-sets/examples/sets.ts +257 -0
  79. package/skills/animestudio-sets/references/drawing-sets.md +119 -0
  80. package/skills/animestudio-sets/references/fx.md +93 -0
  81. package/skills/animestudio-sets/references/lighting-camera.md +93 -0
  82. package/skills/animestudio-sets/references/scene-fields.md +132 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Model sheets for the cast in cast.ts: render them, then LOOK at the PNGs before using the cast.
3
+ *
4
+ * Run from the repo root: npx tsx skills/animestudio-characters/examples/turnaround.ts [style] [views]
5
+ * style modern (default) | painted | flat
6
+ * views comma list of drawn views (default front,half,profile,side,away,back; "all" = the twelve)
7
+ * Needs `rsvg-convert` (librsvg) on PATH; `magick` (ImageMagick) is optional and stacks the sheets.
8
+ *
9
+ * Writes to skills/animestudio-characters/examples/out/:
10
+ * lineup.png the cast side by side in the main view (heights, silhouettes, colours)
11
+ * lineup-small.png the same at 360 px wide: can you still tell who is who?
12
+ * turn-<id>.png one character across the views (do the angles match? does the hair hold?)
13
+ * emotions.png every character x six emotions in the `half` view
14
+ * sheet.png all of the above stacked (with magick)
15
+ */
16
+ import { execFileSync } from "node:child_process";
17
+ import { mkdirSync, writeFileSync } from "node:fs";
18
+ import { dirname, join } from "node:path";
19
+ import { fileURLToPath } from "node:url";
20
+ import { type SceneDoc, type ToonDoc, evaluateScene, frameToSVG } from "@anime-studio/core";
21
+ import { prepareScene } from "@anime-studio/rigid";
22
+ import { type CartoonOptions, cartoonInfo } from "@anime-studio/kit";
23
+ import { LOOKS, cast } from "./cast";
24
+
25
+ const ALL = ["front", "half", "q24", "profile", "q50", "q64", "q77", "side", "q112", "away", "q158", "back"];
26
+ const style = (process.argv[2] ?? "modern") as CartoonOptions["style"];
27
+ const views = !process.argv[3] ? ["front", "half", "profile", "side", "away", "back"] : process.argv[3] === "all" ? ALL : process.argv[3].split(",");
28
+ const EMOTIONS = ["neutral", "happy", "sad", "angry", "surprised", "scared"];
29
+ const OUT = join(dirname(fileURLToPath(import.meta.url)), "out");
30
+ mkdirSync(OUT, { recursive: true });
31
+
32
+ const docs = cast(style);
33
+ const ids = Object.keys(LOOKS);
34
+
35
+ interface Cell { character: string; view: string; emotion?: string; label: string }
36
+
37
+ /** One row of characters standing on a floor, each in its own view and emotion, rendered to PNG. */
38
+ async function row(file: string, cells: Cell[], { cellW = 300, H = 720, floor = 640, width, zoom = 1, focus }: { cellW?: number; H?: number; floor?: number; width?: number; zoom?: number; focus?: number } = {}) {
39
+ const W = cellW * cells.length;
40
+ // Zoomed rows (faces): the camera looks at `focus` (scene y) and the actors stand closer together
41
+ // in scene units, so each still fills one cell of the picture.
42
+ const camY = focus ?? H / 2;
43
+ const step = cellW / zoom;
44
+ const xOf = (i: number) => W / 2 + (i - (cells.length - 1) / 2) * step;
45
+ const labelY = zoom === 1 ? floor + 50 : camY + (H / 2 - 14) / zoom;
46
+ const used = [...new Set(cells.map((c) => c.character))];
47
+ const scene = {
48
+ format: "toon-scene", version: 1, width: W, height: H, fps: 30, duration: 2, background: "#f6efe0",
49
+ characters: Object.fromEntries(used.map((id) => [id, `${id}.toon.json`])),
50
+ camera: { x: W / 2, y: camY, zoom },
51
+ layers: [
52
+ { id: "floor", art: `<rect x="-${W}" y="${floor}" width="${W * 3}" height="${H}" fill="#e3d4b5"/>` },
53
+ // Labels in front of the actors (z 2 > their z 1), on a plate so they read over clothes.
54
+ { id: "labels", z: 2, art: cells.filter((c) => c.label).map((c, i) =>
55
+ `<rect x="${xOf(i) - 60 / zoom}" y="${labelY - 24 / zoom}" width="${120 / zoom}" height="${32 / zoom}" rx="${6 / zoom}" fill="#f6efe0" opacity="0.85"/>` +
56
+ `<text x="${xOf(i)}" y="${labelY}" font-family="sans-serif" font-size="${22 / zoom}" text-anchor="middle" fill="#5a4a3a">${c.label}</text>`).join("") },
57
+ ],
58
+ actors: cells.map((c, i) => ({ id: `a${i}`, character: c.character, x: xOf(i), y: floor, z: 1 })),
59
+ script: cells.flatMap((c, i) => [
60
+ // A looping base clip so nobody freezes, then the drawn view and the emotion, set instantly.
61
+ { at: 0, actor: `a${i}`, action: "play", clip: "idle", loop: true, layer: -1 },
62
+ { at: 0, actor: `a${i}`, action: "pose", control: "view", value: c.view, duration: 0 },
63
+ { at: 0, actor: `a${i}`, action: "pose", control: "emotion", value: c.emotion ?? "neutral", duration: 0 },
64
+ ]),
65
+ } as unknown as SceneDoc;
66
+ const characters: Record<string, ToonDoc> = Object.fromEntries(used.map((id) => [id, docs[id]]));
67
+ const frame = evaluateScene(await prepareScene(scene, { characters }), 0.5);
68
+ const svg = join(OUT, file.replace(/\.png$/, ".svg"));
69
+ writeFileSync(svg, frameToSVG(frame));
70
+ execFileSync("rsvg-convert", ["-w", String(width ?? W), "-o", join(OUT, file), svg]);
71
+ console.log("wrote", join(OUT, file));
72
+ }
73
+
74
+ await row("lineup.png", ids.map((id) => ({ character: id, view: "profile", label: LOOKS[id].name })));
75
+ await row("lineup-small.png", ids.map((id) => ({ character: id, view: "profile", label: "" })), { width: 360 });
76
+ for (const id of ids) await row(`turn-${id}.png`, views.map((v) => ({ character: id, view: v, label: v })), { cellW: 260 });
77
+ // Emotions read on the face: zoom in on the head and chest (the height comes from cartoonInfo).
78
+ for (const id of ids) {
79
+ const height = cartoonInfo(docs[id], LOOKS[id], { style }).height;
80
+ await row(`emotions-${id}.png`, EMOTIONS.map((e) => ({ character: id, view: "half", emotion: e, label: e })),
81
+ { cellW: 300, H: 460, zoom: 1.6, focus: 640 - height * 0.8 });
82
+ }
83
+
84
+ try {
85
+ execFileSync("magick", [...ids.map((id) => join(OUT, `emotions-${id}.png`)), "-background", "#f6efe0", "-gravity", "center", "-append", join(OUT, "emotions.png")]);
86
+ execFileSync("magick", [join(OUT, "lineup.png"), ...ids.map((id) => join(OUT, `turn-${id}.png`)), join(OUT, "emotions.png"),
87
+ "-background", "#f6efe0", "-gravity", "center", "-append", "-resize", "1800x>", join(OUT, "sheet.png")]);
88
+ console.log("wrote", join(OUT, "emotions.png"), "and", join(OUT, "sheet.png"));
89
+ } catch {
90
+ console.log("magick not found: the row PNGs are in", OUT);
91
+ }
@@ -0,0 +1,139 @@
1
+ # Writing a `*.toon.json` character by hand
2
+
3
+ Read this when the kit builders cannot make the character (animals, creatures, objects, a style of
4
+ your own). Full spec: [FORMAT.md §2](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md#2-character-document-toonjson);
5
+ authoring rules: [AI_GUIDE.md, "Writing characters"](https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md#writing-characters).
6
+ Worked example: `examples/sprout.toon.json` (in this skill) and the repo's `examples/characters/pip.ts`.
7
+
8
+ ## Conventions that cause most mistakes
9
+
10
+ - Units px, **y down**, angles in degrees **clockwise**, time in seconds.
11
+ - **Setup space**: origin `(0, 0)` on the ground between the feet, character **facing right**. Draw all
12
+ art where it sits in the rest pose (`space: "setup"`, the default).
13
+ - Every animated character channel is an **offset from the rest pose** (rotation 30 = 30° more).
14
+ - The format rejects unknown fields: a typo (`rotaton`) is a validation error, not ignored.
15
+
16
+ ## Document skeleton
17
+
18
+ ```jsonc
19
+ {
20
+ "format": "toon", "version": 1, "name": "sprout",
21
+ "meta": { "description": "…" }, // shown by `toon describe`
22
+ "palette": { "body": "#8fcf6a", "ink": "#2b2633" },
23
+ "art": { "head": "<circle cx='4' cy='-160' r='34' fill='palette(body)'/>" },
24
+ "skeleton": [], "parts": [], "anchors": {}, "ik": [], "physics": [],
25
+ "controls": {}, "behaviors": [], "clips": {}
26
+ }
27
+ ```
28
+
29
+ Optional: `defs` (raw SVG defs, ids namespaced per actor), `colliders` (capsules on bones for scene
30
+ rigid bodies), `rig3d` (2.5D rigs — use the kit instead of writing one by hand).
31
+
32
+ ## `palette`
33
+
34
+ Use `palette(name)` for **every** colour in art and part styles: scenes recolour actors through it.
35
+
36
+ ## `skeleton`
37
+
38
+ Parents before children. Prefer the **setup form**: `{ "id", "parent", "from": [x, y], "to": [x, y] }`
39
+ (joint and tip in setup space). A zero-length bone (no `to`) is a pivot (pupils). Fields: `mass`
40
+ (physics inertia), `limits.rotation: [min, max]`, `inheritRotation`, `inheritScale`, `scaleX/Y`.
41
+
42
+ - Give legs a slight knee bend at rest so IK never reaches full extension.
43
+ - A foot that must stay flat: a toe bone with `inheritRotation: false`.
44
+ - Conventional names: a top-level `ground` bone carries the shadow; a `neck` bone is what `fall` bends.
45
+
46
+ ## `parts` (draw order = array order; `z` overrides)
47
+
48
+ | type | Use | Key fields |
49
+ |---|---|---|
50
+ | `rigid` | cut-out art on one bone | `bone`, `art` |
51
+ | `switch` | swappable drawings: eyes, hands, mouths, views | `bone`, `variants: { name: art }`, `default`, `alt?` |
52
+ | `morph` | blend shapes: lip sync mouths, brows | `bone`, `base`, `shapes`, `clip?`, style |
53
+ | `hose` | rubber-hose limb through a bone chain | `bones`, `width` (`n`, `[start, end]` or per joint), `cap`, `smooth`, style |
54
+ | `skinned` | one path bent by several bones | `path`, `bones`, `weights?`, `falloff` |
55
+ | `hull` | soft shape over skeleton points (skirt, cape) | `points: [{ bone, at, r }]` |
56
+ | `solid` | 3D volumes on a `rig3d` (2.5D only) | `bodies` |
57
+
58
+ Style fields: `fill`, `stroke`, `strokeWidth`, `attrs`. Common: `opacity`, `visible`,
59
+ `visibleWhen: { part, variant, and? }` (pupils only while eyes are `open`; view-specific parts).
60
+
61
+ - **Morph shapes must be the same figure**: the same number and kind of path commands in the same
62
+ order (write them from one function, or keep `M + n×C + Z` everywhere). Name mouth shapes `A`–`H`
63
+ (`X` falls back to `A`), plus `smile` / `frown` for emotions.
64
+ - `switch` `alt: [{ when: { part, variant }, variants }]` draws other art for some variants while
65
+ another switch shows a variant (a mirrored hand in a front view). The variant name does not change.
66
+ - Hands: a switch with variants `open`, `fist`, `point`, `grip` (kit `handShapes` / `cartoonHands`
67
+ draw them). A held prop switches the holding bone's switch to `grip` automatically.
68
+
69
+ ## `anchors`
70
+
71
+ `{ "name": { "bone", "at": [x, y] } }` in setup space. Name them `head` (lookAt targets aim there; a
72
+ fall lays the spine to it), `hand` / `handB` (grab), `mouth`, `ear`, `top`. Add `turn: 0..1` for props
73
+ that should turn with the hand.
74
+
75
+ ## `ik`
76
+
77
+ `{ "id", "bones": [upper, lower], "bend": 1 | -1, "mix": 1 }`. Two bones: analytic; 3+: FABRIK. The
78
+ target is the rest tip plus `ik.<id>.x/y`. Leg chains also tell `fall` where the hip is.
79
+
80
+ ## `physics`
81
+
82
+ - `spring` on chains: tails, ears, hair, antennae (`stiffness` 0..1, `damping` 0..1, `gravity`).
83
+ - `jiggle` on one bone: bellies, cheeks (`translate`, `squash`).
84
+ Baked, deterministic; restarts at rest when the actor flips.
85
+
86
+ ## `controls` — expose meaning, not bones
87
+
88
+ | type | Shape | Notes |
89
+ |---|---|---|
90
+ | `viseme` | `{ part: "mouth" \| ["mouth", "mouthFront"], map? }` | `say` drives it; missing visemes fall back (`H→C`, `G→B`, `X→A`) |
91
+ | `aim` | `{ targets: [{ bone, weight, mode, forward, maxAngle, radius }] }` | head bone drawn pointing up in a right-facing profile → `forward: 90`; pupils `mode: "translate"`, `radius` |
92
+ | `pose` | `{ poses: { name: { channel: value } }, override? }` | numbers add on top of clips; variants override |
93
+
94
+ Name them `mouth` (viseme), `look` (aim), `emotion` (pose) so scenes and the director find them;
95
+ a `view` pose control for multi-view rigs; a `side` pose control (`right`/`left`) is set from facing.
96
+
97
+ ## `behaviors`
98
+
99
+ `blink` (`part`, `open`, `closed`, `interval`, `duration`), `breathe` (`bone`, `amount`, `period`),
100
+ `sway` (`bone`, `angle`, `period`). Always add a blink and a breathe: a still character reads dead.
101
+
102
+ ## `clips`
103
+
104
+ `{ duration, loop?, stride?, clear?, tracks: { channel: [[t, v, ease?], …] } }`.
105
+
106
+ - Keys without `ease` are smooth monotone splines; use `"linear"` for feet in contact; `backOut` /
107
+ `easeOut` for snappy accents. **The ease of a key shapes the segment arriving at it.**
108
+ - Loops start and end on the same values. Locomotion sets `stride` (px per cycle) so `walkTo` does
109
+ not slide the feet.
110
+ - Ship at least `idle` (loop). Add `walk` if the character will move.
111
+ - `clear: true` (2.5D rigs): the engine keeps the arms off the head (not for face-contact clips).
112
+
113
+ ## Channels you can animate
114
+
115
+ `bones.<id>.rotation | x | y | scaleX | scaleY | squash | rotationMix`, `parts.<id>.variant`,
116
+ `parts.<id>.opacity`, `parts.<id>.morph.<shape>`, `ik.<id>.x | y | mix | bend`, `controls.<id>`,
117
+ `behaviors.<id>.mix`, `physics.<index>.mix`.
118
+
119
+ ## Multiple views on one skeleton
120
+
121
+ Add a hidden `switch` part `view` with empty variants, gate view-specific parts with
122
+ `visibleWhen: { part: "view", variant: [...] }`, and a `view` pose control that sets
123
+ `parts.view.variant` and moves bones; hide the face from behind with `parts.<id>.opacity: -1`. The
124
+ kit's `withViews(doc, spec)` does this for you. Draw the front view truly symmetric.
125
+
126
+ ## Validate, describe, look
127
+
128
+ ```bash
129
+ npx tsx packages/cli/src/bin.ts validate my.toon.json # in a project: npx @anime-studio/cli validate …
130
+ npx tsx packages/cli/src/bin.ts describe my.toon.json
131
+ npx tsx packages/cli/src/bin.ts render my.toon.json --clip wave --time 0.4 -o f.svg && rsvg-convert f.svg -o f.png
132
+ ```
133
+
134
+ | Message | Fix |
135
+ |---|---|
136
+ | `unknown bone "x". Known bones: …` | use a listed id |
137
+ | `parent "x" is not declared before this bone` | reorder `skeleton` |
138
+ | `use either setup form (from/to) or local form …` | one form per bone |
139
+ | `Unrecognized key: "rotaton"` | typo |
@@ -0,0 +1,59 @@
1
+ # Importing an SVG drawing (`@anime-studio/import-svg`, `toon import-svg`)
2
+
3
+ Read this when the character already exists as a drawing (Inkscape, Illustrator, Figma export, or an
4
+ SVG you write). The importer turns a layered SVG into a valid `*.toon.json` with a skeleton, parts
5
+ and anchors. It does **not** create controls, behaviours, physics or clips: add those afterwards
6
+ (see `custom-rig.md`). Worked example: `examples/lumo.svg` + `examples/import-svg.ts`.
7
+
8
+ ```ts
9
+ import { readFileSync, writeFileSync } from "node:fs";
10
+ import { importSvg } from "@anime-studio/import-svg";
11
+ const { doc, warnings } = importSvg(readFileSync("lumo.svg", "utf8"), { name: "lumo" });
12
+ warnings.forEach((w) => console.warn(w)); // read them: each one is something dropped or guessed
13
+ writeFileSync("lumo.toon.json", JSON.stringify(doc, null, 2));
14
+ ```
15
+
16
+ ```bash
17
+ toon import-svg lumo.svg --name lumo -o lumo.toon.json # npx @anime-studio/cli import-svg …
18
+ # inside the animeStudio repo:
19
+ npx tsx packages/cli/src/bin.ts import-svg lumo.svg --name lumo -o lumo.toon.json
20
+ ```
21
+
22
+
23
+ ## Naming convention
24
+
25
+ The name of an element is its `inkscape:label`, else `data-name`, else `id` (Illustrator's `_x3A_`
26
+ escapes for `:` are decoded).
27
+
28
+ | Name | Element | Becomes |
29
+ |---|---|---|
30
+ | `bone:<id>[@<parent>]` | `<line>` / `<path>` (first → last point) or `<circle>` (zero length) | a bone in setup form; `bone:root` places the root itself |
31
+ | `part:<id>@<bone>` | any element or group | a `rigid` part on that bone |
32
+ | `switch:<part>/<variant>@<bone>` | any element or group | a variant of switch `<part>`; the first one is the default |
33
+ | `skin:<id>@<bone1>,<bone2>` | a `<path>` | a `skinned` part bent by those bones (weights by distance) |
34
+ | `anchor:<name>@<bone>` | a `<circle>` | a named anchor at its centre |
35
+ | `origin` | a `<circle>` | the ground point between the feet (default: the bottom centre of the viewBox) |
36
+
37
+ Unnamed visible elements outside parts become rigid parts on the root bone (`art0`, `art1`…).
38
+ Draw order follows document order.
39
+
40
+ ## Drawing rules
41
+
42
+ - Draw the character **facing right**, standing on the origin; coordinates are re-expressed
43
+ relative to it, so y ends up negative upwards like every toon character.
44
+ - Put bones on their own hidden lines (`stroke="none"`) from the joint to the tip; a parent may come
45
+ before or after its children in the file.
46
+ - Skins take `fill` / `stroke` / `stroke-width` as a browser would (inherited from groups, `style`
47
+ attribute winning). Stylesheet classes are **not** applied to skins: set paint on the path.
48
+ - `transform` attributes are applied; an unreadable transform function is warned about and skipped.
49
+ - Relative units (`%`, `em`) cannot be resolved; absolute units (`mm`, `pt`…) are converted.
50
+ - Colours are copied literally. To make the actor recolourable, replace them with `palette(name)`
51
+ tokens afterwards and add a `palette`.
52
+
53
+ ## After the import
54
+
55
+ 1. `toon validate` and `toon describe` the raw file: check the bones and parts are what you meant.
56
+ 2. Add `meta.description`, a `blink` (the eyes need a switch with `open` / `closed`), a `breathe`,
57
+ pose controls (`emotion`), an `aim` (`look`) and a `viseme` control if there is a mouth.
58
+ 3. Add clips (`idle` at least) and springs on dangling bones.
59
+ 4. Validate again (`parseToon` throws with every issue), render a strip of poses, look at it.
@@ -0,0 +1,143 @@
1
+ # `CartoonLook` and `CartoonOptions` — every allowed value
2
+
3
+ Source of truth: `packages/kit/src/cartoon.ts` (types `CartoonLook`, `CartoonBuild`, `CartoonHair`,
4
+ `CartoonHat`, `CartoonTop`, `CartoonBottom`, `CartoonShoes`, `CartoonPattern`, `CartoonNose`,
5
+ `CartoonJaw`, `CartoonStyle`, `CartoonOptions`). If a value here disagrees with the types, the types
6
+ win. Colours are any CSS hex (`#333` works).
7
+
8
+ ## Required fields
9
+
10
+ | Field | Values |
11
+ |---|---|
12
+ | `name` | display name (string; also used in error messages) |
13
+ | `build` | `baby` `child` `kid` `teen` `woman` `man` `big` `elder` |
14
+ | `skin` | colour |
15
+ | `hair` | `bowl` `sidePart` `afro` `puffs` `ponytail` `long` `perm` `mullet` `buzz` `bald` `bun` `braids` `rollers` `tuft` `receding` `slick` `bob` `curtains` `spiky` |
16
+ | `hairColor` | colour |
17
+ | `top` | `tee` `stripes` `polo` `shirt` `tank` `jersey` `blouse` `dress` `overalls` `jacket` `cardigan` `blazer` |
18
+ | `topColor` | colour (see the table below for what it paints) |
19
+ | `bottom` | `pants` `shorts` `bermuda` `skirt` `longSkirt` |
20
+ | `bottomColor` | colour |
21
+ | `shoes` | `sneakers` `studded` `canvas` `flipflops` `dress` `heels` `sandals` |
22
+
23
+ ## Body and face (optional)
24
+
25
+ | Field | Values | Notes |
26
+ |---|---|---|
27
+ | `heavy` | 0..1 | belly (also deepens `cartoonInfo().depth.front`) |
28
+ | `tall` | multiplier, e.g. 1.05 | scales legs and torso |
29
+ | `limbs` | `thin` (default) `normal` `thick` | arm/leg thickness. Not the same as `CartoonStyle.limbs` |
30
+ | `female` | boolean | narrower waist, wider hips, lashes, smaller nose |
31
+ | `jaw` | `round` `square` `pointy` `chubby` | |
32
+ | `nose` | `button` (default) `round` `long` `wide` | |
33
+ | `moustache` `goatee` `freckles` `wrinkles` `stubble` `flushed` | boolean | face details; a goatee does not follow the gape jaw |
34
+ | `lipstick` | colour | thicker coloured lips |
35
+ | `hairLine` | boolean | a shaved line on the side of a `buzz` cut (asymmetric: adds the `side` control) |
36
+
37
+ ## Clothes, prints and colours (optional)
38
+
39
+ | Field | Values | Notes |
40
+ |---|---|---|
41
+ | `top2` | colour | second colour of the top; default a darker `topColor` |
42
+ | `pattern` | `stripes` `pinstripes` `checks` `polka` | printed on the torso only (a `dress`'s skirt stays plain) |
43
+ | `stripe` | colour | print colour (default `top2`) |
44
+ | `stripeWidth` | fraction of the torso, default 0.13 | band height for `stripes` (≈ 0.25: a football hoop) |
45
+ | `shoeColor` | colour | default per shoe kind |
46
+ | `socks` | colour | |
47
+ | `accent` | colour | hair ties, beads, rollers, earrings |
48
+ | `apron` | colour | covers the torso front (ends at the waist) |
49
+ | `sweater` | colour | thrown over the shoulders, sleeves knotted on the chest |
50
+ | `suspenders` | colour | |
51
+ | `tie` | colour | with `shirt` or `blazer` |
52
+ | `cape` | colour | shoulders down the back to the knees |
53
+ | `veil` | colour | bridal veil from the top of the head down the back |
54
+ | `boutonniere` | colour | flower in the lapel (asymmetric) |
55
+ | `pocketItem` | `{ color, band? }` | a small box sticking out of the shirt pocket (asymmetric) |
56
+ | `earItem` | `pencil` `cigarette` | resting behind the ear (asymmetric) |
57
+
58
+ What `topColor` and `top2` paint, per `top` (read from `topKey` in cartoon.ts):
59
+
60
+ | `top` | `topColor` | `top2` |
61
+ |---|---|---|
62
+ | `tee` `tank` `blouse` `dress` | the whole top (a `dress` also colours its skirt) | unused (pattern colour fallback) |
63
+ | `stripes` | base bands | alternate bands |
64
+ | `jersey` | base | vertical bands and the V neck |
65
+ | `polo` `shirt` | body | collar / placket (`shirt` also gets a breast pocket) |
66
+ | `overalls` | the shirt under it | — (the bib and straps are `bottomColor`) |
67
+ | `jacket` `cardigan` `blazer` | **the shirt in the opening** | **the jacket and its long sleeves** |
68
+
69
+ ## Accessories (optional)
70
+
71
+ | Field | Values |
72
+ |---|---|
73
+ | `hat` | `cap` `capBack` `flatCap` `top` `bowler` `cowboy` |
74
+ | `hatColor` | colour |
75
+ | `glasses` | `true` or `"sun"` (dark lenses) |
76
+ | `necklace` | `{ kind: "pearls" \| "chain", color? }` |
77
+ | `earrings` | boolean |
78
+ | `watch` | colour (one solid per wrist, kept on the same wrist when the actor flips) |
79
+
80
+ A hat sits on the hair: ordinary cuts show only below the band; big hair (`afro`, `puffs`, `perm`,
81
+ `long`, `braids`) keeps its volume round it. Glasses are built from the face's own measures.
82
+
83
+ ## Asymmetric details and the `side` control
84
+
85
+ `earItem`, `pocketItem`, `hairLine`, `boutonniere`, a `sidePart`, a `shirt`'s breast pocket and the
86
+ watch must stay on the same side of the body when the actor faces left. Such a rig gets a pose
87
+ control `side` (`right` / `left`; a plain `tee` look has none)
88
+ that the scene sets from the actor's facing every frame. Never animate it yourself.
89
+
90
+ ## `CartoonOptions` (second argument)
91
+
92
+ ```ts
93
+ cartoonCharacter(look, { style?, pitch?, anatomy? })
94
+ ```
95
+
96
+ | Option | Values |
97
+ |---|---|
98
+ | `style` | `"modern"` (the default when omitted), `"painted"`, `"flat"`, or a `CartoonStyle` object (refines `painted`) |
99
+ | `pitch` | degrees the camera looks down (a room camera's pitch). Heads are drawn at 30% of it so the nose never drops over the mouth |
100
+ | `anatomy` | an edited `CartoonAnatomy` (see SKILL.md, "Tune the anatomy") |
101
+
102
+ Preset styles:
103
+
104
+ - `modern` — natural figure about five heads tall (`proportions: "tv"`), big round eyes with dot
105
+ pupils (`eyes: "round"`), one thin even ink line (2.4), flat colours, no blush, four-finger hands
106
+ welded into the forearm.
107
+ - `painted` — the look's own proportions, lines in a dark tone of each colour (2.8 outlines,
108
+ thinner seams), cel shadows, tapered arms, fists at rest, oval eyes with a glint.
109
+ - `flat` — one near-black ink `#1b1b1b`, one line weight 2.4, no cel shadow, tube arms, open hands,
110
+ wide eyes, a slouch, a bigger head on a thinner neck.
111
+
112
+ `CartoonStyle` fields (each optional, unspecified fields come from `painted`):
113
+
114
+ | Field | Values |
115
+ |---|---|
116
+ | `ink` | one colour for every line (default: dark tone of each fill) |
117
+ | `shade` | boolean, cel shadows (default true) |
118
+ | `line` | one line weight for everything |
119
+ | `limbs` | `tapered` (default) `tube` |
120
+ | `hands` | `fist` (default) `open` — resting hand shape |
121
+ | `eyes` | `oval` `wide` `big` `round` |
122
+ | `posture` | `upright` (default) `slouch` |
123
+ | `proportions` | `normal` `bigHead` `cartoon` (about three heads tall) `tv` (about five) |
124
+ | `blush` | boolean |
125
+
126
+ The old "modern" look (big head, big eyes with glints, blush) is
127
+ `{ proportions: "cartoon", eyes: "big", blush: true }`.
128
+
129
+ ## Builds at a glance (default anatomy, before the style)
130
+
131
+ | build | hip height | torso | head radius | read as |
132
+ |---|---|---|---|---|
133
+ | `baby` | 50 | 54 | 38 | big head on a small round body |
134
+ | `child` | 150 | 96 | 58 | |
135
+ | `kid` | 192 | 110 | 56 | |
136
+ | `teen` | 236 | 134 | 51 | |
137
+ | `woman` | 250 | 148 | 46 | |
138
+ | `man` | 254 | 168 | 48 | broad shoulders |
139
+ | `big` | 250 | 196 | 47 | very wide, thick limbs |
140
+ | `elder` | 214 | 150 | 48 | shorter |
141
+
142
+ Measured heights of the example cast (modern style, `cartoonInfo().height`): woman ×1.05 ≈ 550,
143
+ kid ≈ 439, big ≈ 571, elder ≈ 500.
@@ -0,0 +1,62 @@
1
+ # What a kit character can do (controls, views, clips, anchors)
2
+
3
+ Read this when you script a character built by `cartoonCharacter` or `humanCharacter`, or when you
4
+ need exact names. The lists below were printed from the built documents (kit 0.2.x); confirm on your
5
+ version with `toon describe <file>.toon.json` — that output is the authority.
6
+
7
+ ## `cartoonCharacter` controls
8
+
9
+ | Control | Type | Values |
10
+ |---|---|---|
11
+ | `view` | pose | `front` `half` `q24` `profile` `q50` `q64` `q77` `side` `q112` `away` `q158` `back` |
12
+ | `head` | pose | any drawn angle, or a mirrored one: `~half` `~q24` `~profile` `~q50` `~q64` `~q77` `~side` `~q112` `~away` `~q158` (looks the other way); `null` follows the body's `view` |
13
+ | `emotion` | pose | `neutral` `sleep` `happy` `joy` `surprised` `sad` `smug` `scared` `angry` `dead` `determined` `calm` `excited` `annoyed` `gape` — or a weight blend `{ "happy": 0.5, "surprised": 0.5 }` |
14
+ | `jaw` | pose | `shut`, `gape`; weighted `{ "gape": 1 }` (big) to `{ "gape": 2 }` (unhinged, `GAPE_FULL`) |
15
+ | `mouth` | viseme | `A` `B` `C` `D` `E` `F` `G` `H` `X`, plus `gape` / `{ "gape": w }` (morphs only) — driven by `say` |
16
+ | `look` | aim | `[x, y]`, an actor or prop id, or `null` — driven by `lookAt` |
17
+ | `side` | pose | `right` / `left`, set by the scene from the actor's facing (only on rigs with asymmetric details) |
18
+
19
+ Views, in turning order. `profile` (36°, a three-quarter view facing right) is the main view; a
20
+ `view` change with a duration steps through the in-betweens, and the director plays the kit's
21
+ `turn` clip (a quick squeeze) on every view change.
22
+
23
+ | `front` | `half` | `q24` | `profile` | `q50` | `q64` | `q77` | `side` | `q112` | `away` | `q158` | `back` |
24
+ |---|---|---|---|---|---|---|---|---|---|---|---|
25
+ | 0° | 12° | 24° | 36° | 50° | 64° | 77° | 90° | 112° | 135° | 158° | 180° |
26
+
27
+ Use `front` for talking to the audience (clear the gaze with `lookAt: null`), `profile` for two
28
+ people talking, `side` / `q64` for runs (`q64` is the rig's `travel` view), `back` / `away` for
29
+ walking off. Facing left is the actor's `flip`, not a view.
30
+
31
+ ## Clips (`cartoonCharacter`)
32
+
33
+ - Locomotion (loop, with `stride`): `walk` `run` `sneak` `strut` `tired` `march` `scaredRun`
34
+ - Base: `idle` (loop it on `layer: -1`), `turn`
35
+ - Talk and gesture: `talk` `wave` `point` `pointUp` `present` `shrug` `think` `facepalm` `laugh`
36
+ `cry` `scared` `clap` `cheer` `dance` `groove` `sing`
37
+ - Props in the hands: `drink` `smoke` `phone` `texting` `textingTwo` `read` `carry` `hold`
38
+ `gamepad` `cue` `dribble` `toss`
39
+ - Body: `jump` `teeter` `flap` `roll` `ride`
40
+ - Fighting and falls: `stance` `power` `punch` `knocked` `down` `rise` (the last three are timed for
41
+ the scene's `fall` / `getUp` — use those actions, not the clips)
42
+
43
+ `humanCharacter` has the same set except `texting`, `carry`, `textingTwo`, `gamepad`, `cue`,
44
+ `groove`; its `view` has only `profile` and `front`; its emotions lack `annoyed` and `gape`.
45
+
46
+ ## Anchors (`cartoonCharacter`)
47
+
48
+ `head`, `face`, `top` (top of the head: hats, halos), `eye`, `ear`, `earB`, `mouth` (move with each
49
+ drawn angle and with the `head` control), `hand`, `handB`, `fist` (the hand anchors have `turn: 1`:
50
+ held props turn with the hand). `hip` defaults to the leg chains' joints.
51
+
52
+ ## Measuring for the director: `cartoonInfo(doc, look, opts?)`
53
+
54
+ Returns `RigInfo`: `height` (as drawn at rest in `profile`, hair and hats included), `extent`
55
+ (`front` / `back` reach from the origin: space neighbours by this, not by their feet), `depth`
56
+ (`front` / `back`, for lying down; `front` grows with `heavy`), `hand`, `shoulder`, `armLength`,
57
+ `backShoulder`, `hip`, `legLength`. Pass the same `style` you built with.
58
+
59
+ ## Gape (swallowing, screaming, yawning big)
60
+
61
+ `{ "action": "pose", "control": "jaw", "value": { "gape": 2 } }`, then `"shut"` (0.1 s closes
62
+ cleanly); or `emotion: "gape"`. Visemes add on top up to gape ≈ 1; keep `say` off while unhinged.