@anime-studio/director 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dener Fernandes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # @anime-studio/director
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@anime-studio/director)](https://www.npmjs.com/package/@anime-studio/director)
4
+ [![CI](https://github.com/denerFernandes/animeStudio/actions/workflows/ci.yml/badge.svg)](https://github.com/denerFernandes/animeStudio/actions/workflows/ci.yml)
5
+ [![MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/denerFernandes/animeStudio/blob/master/LICENSE)
6
+
7
+ Part of [animeStudio](https://github.com/denerFernandes/animeStudio), a deterministic 2D/2.5D cartoon animation engine: characters are
8
+ SVG art bound to skeletons, scenes are JSON documents, and every frame is a pure function of the
9
+ documents and the time.
10
+
11
+ Stages whole episodes: give it a staging (sets, marks, who is where), timed lines and a kit of characters, and it writes the scenes — blocking, walks, gestures, looks and camera.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @anime-studio/core @anime-studio/kit @anime-studio/director
17
+ # or
18
+ pnpm add @anime-studio/core @anime-studio/kit @anime-studio/director
19
+ ```
20
+
21
+ Requires Node.js 22 or later (or a modern browser / bundler). The packages are ES modules with
22
+ TypeScript types included.
23
+
24
+ ## Usage
25
+
26
+ See the [director guide](https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md).
27
+
28
+ ## Documentation
29
+
30
+ - [Getting started and features](https://github.com/denerFernandes/animeStudio#readme)
31
+ - [Format specification](https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md)
32
+ - [API reference](https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md)
33
+ - [Authoring guide for AI agents](https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md)
34
+ - [Changelog](https://github.com/denerFernandes/animeStudio/blob/master/CHANGELOG.md)
35
+
36
+ ## License
37
+
38
+ MIT © Dener Fernandes
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Photos and photo albums: a moment of a block rendered as a photo on paper (a print with photo
3
+ * corners or a Polaroid, aged, with a handwritten caption), and an album lying open whose pages turn
4
+ * and which closes on its cover. Everything is drawn as SVG markup for props of the scene.
5
+ */
6
+ export type PhotoFrame = "print" | "polaroid";
7
+ export type PhotoLook = "faded" | "sepia" | "flash" | "plain";
8
+ export interface PhotoStyle {
9
+ /** Picture size (px, the photo's own, not counting the border). */
10
+ size: [number, number];
11
+ frame?: PhotoFrame;
12
+ /** 0 (new) … 1 (old: yellowed, faded, the colours gone towards sepia). */
13
+ age?: number;
14
+ look?: PhotoLook;
15
+ /** Handwritten: on the Polaroid's wide bottom border, or on the page under a print. Kept within the picture's width (smaller, on two lines if long). */
16
+ caption?: string;
17
+ /** The caption's ink under a print (default blue; in an album, white pencil on a dark page). */
18
+ ink?: string;
19
+ /** The whole scene frame's size (default 1920 × 1080): the picture is cropped from its middle. */
20
+ source?: [number, number];
21
+ /** Part of the frame to show: [x, y, w, h] in its pixels (default the middle, at the photo's aspect). */
22
+ crop?: [number, number, number, number];
23
+ }
24
+ /** Handwriting (a cursive face, falling back to the system's). */
25
+ export declare const HANDWRITING = "'Caveat','Patrick Hand','Comic Sans MS','Segoe Print',cursive";
26
+ /**
27
+ * A photo: `frame` (the frozen frame's markup, in a `source`-sized space) cropped to the picture,
28
+ * aged, on its paper. Drawn with the picture's top-left at (0, 0); returns the markup and the size
29
+ * of the whole paper (the border and, for a print, the caption below it).
30
+ */
31
+ export declare function photoMarkup(frame: string, o: PhotoStyle, id: string): {
32
+ markup: string;
33
+ size: [number, number];
34
+ };
35
+ /** Relative luminance (0 black … 1 white) of a #rgb / #rrggbb colour. */
36
+ export declare function luminance(hex: string): number;
37
+ /**
38
+ * Markup as a standalone picture: an `<image>` holding it as an SVG document (a data URI). The
39
+ * browser decodes it once and reuses it frame after frame, where inline markup — a whole frozen
40
+ * scene — would be rebuilt every frame; its ids are its own.
41
+ */
42
+ export declare function pictureMarkup(markup: string, size: [number, number], at?: [number, number]): string;
43
+ /** A photo on a page: a moment of a block, where it goes on the page (its top-left), tilted. */
44
+ export interface AlbumPhoto extends Omit<PhotoStyle, "source"> {
45
+ id?: string;
46
+ /** The block photographed (an `insert: true` block staged for it) and the moment. */
47
+ block: string;
48
+ at: {
49
+ line: number;
50
+ word?: string;
51
+ end?: boolean;
52
+ offset?: number;
53
+ };
54
+ /**
55
+ * Top-left of the photo (its paper, caption and tilt) on the page, px from that page's top-left
56
+ * corner. Kept on the page (moved in, or made smaller if larger than it). Without it, the photos
57
+ * without one share the page, one under the other, each as large as fits.
58
+ */
59
+ place?: [number, number];
60
+ rotation?: number;
61
+ }
62
+ /** One side of a page: its photos and stuck-on notes. */
63
+ export interface AlbumSide {
64
+ photos?: AlbumPhoto[];
65
+ paper?: string;
66
+ notes?: {
67
+ text: string;
68
+ at: [number, number];
69
+ size?: number;
70
+ rotation?: number;
71
+ }[];
72
+ }
73
+ /**
74
+ * An album lying open on a surface: spreads (left and right sides; the first left is the inside of
75
+ * the cover), turned one by one (`flips`), closed on its cover (`close`).
76
+ */
77
+ export interface Album {
78
+ id: string;
79
+ /** The spine's middle (scene px) and a page's size. */
80
+ at: [number, number];
81
+ page: [number, number];
82
+ spreads: {
83
+ left?: AlbumSide;
84
+ right?: AlbumSide;
85
+ }[];
86
+ /** The front cover: a kit.graphics name or SVG markup, drawn over a right page's area (x 0…w, y 0…h). */
87
+ cover: string;
88
+ /** The pages' colour (default a black album page; a side's own `paper` wins). */
89
+ paper?: string;
90
+ /** Colour of the binding (default a brown leather). */
91
+ binding?: string;
92
+ flips?: {
93
+ line: number;
94
+ word?: string;
95
+ end?: boolean;
96
+ offset?: number;
97
+ }[];
98
+ close?: {
99
+ line: number;
100
+ word?: string;
101
+ end?: boolean;
102
+ offset?: number;
103
+ };
104
+ /** Seconds a page takes to turn (default 0.7). */
105
+ turn?: number;
106
+ }
107
+ /** A page side's art: paper, photos (already drawn), notes. Drawn from x0 (−w for a left page) to x0 + w. */
108
+ export declare function sideMarkup(side: AlbumSide | undefined, page: [number, number], left: boolean, photos: string[], id: string): string;
109
+ //# sourceMappingURL=album.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"album.d.ts","sourceRoot":"","sources":["../src/album.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAC9C,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,IAAI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C,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxE,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,6GAA6G;AAC7G,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAsBnI"}
package/dist/album.js ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Photos and photo albums: a moment of a block rendered as a photo on paper (a print with photo
3
+ * corners or a Polaroid, aged, with a handwritten caption), and an album lying open whose pages turn
4
+ * and which closes on its cover. Everything is drawn as SVG markup for props of the scene.
5
+ */
6
+ const r = (n) => Math.round(n * 100) / 100;
7
+ const esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
8
+ /** Handwriting (a cursive face, falling back to the system's). */
9
+ export const HANDWRITING = "'Caveat','Patrick Hand','Comic Sans MS','Segoe Print',cursive";
10
+ /**
11
+ * A photo: `frame` (the frozen frame's markup, in a `source`-sized space) cropped to the picture,
12
+ * aged, on its paper. Drawn with the picture's top-left at (0, 0); returns the markup and the size
13
+ * of the whole paper (the border and, for a print, the caption below it).
14
+ */
15
+ export function photoMarkup(frame, o, id) {
16
+ const [w, h] = o.size;
17
+ const [W, H] = o.source ?? [1920, 1080];
18
+ const age = Math.max(0, Math.min(1, o.age ?? 0.4));
19
+ const kind = o.frame ?? "print";
20
+ // Crop: the middle of the frame at the picture's aspect.
21
+ let crop = o.crop;
22
+ if (!crop) {
23
+ const a = w / h;
24
+ const cw = Math.min(W, H * a), ch = cw / a;
25
+ crop = [(W - cw) / 2, (H - ch) / 2, cw, ch];
26
+ }
27
+ const b = kind === "polaroid" ? w * 0.06 : w * 0.035;
28
+ const bottom = kind === "polaroid" ? w * 0.26 : b;
29
+ const pw = w + b * 2, ph = h + b + bottom;
30
+ // Age: colours towards sepia and washed out (a colour matrix), a warm yellow over it, a vignette.
31
+ const s = age * 0.75;
32
+ const sep = [0.393, 0.769, 0.189, 0.349, 0.686, 0.168, 0.272, 0.534, 0.131];
33
+ const m = [0, 1, 2].flatMap((row) => [0, 1, 2].map((col) => r((row === col ? 1 - s : 0) + sep[row * 3 + col] * s)));
34
+ const wash = r(age * 0.12);
35
+ const look = o.look ?? (age > 0.6 ? "sepia" : "faded");
36
+ const sepia = look === "sepia" ? 1 : look === "plain" ? 0 : 0.5;
37
+ const filter = look === "plain" && age === 0 ? "" :
38
+ `<filter id="${id}-age" color-interpolation-filters="sRGB"><feColorMatrix type="matrix" values="${m[0]} ${m[1]} ${m[2]} 0 ${wash} ${m[3]} ${m[4]} ${m[5]} 0 ${wash} ${m[6]} ${m[7]} ${m[8]} 0 ${r(wash * 0.6)} 0 0 0 1 0"/></filter>`;
39
+ const defs = `<defs>${filter}<clipPath id="${id}-clip"><rect width="${r(w)}" height="${r(h)}"/></clipPath>` +
40
+ `<radialGradient id="${id}-vig" cx="50%" cy="50%" r="70%"><stop offset="0.55" stop-color="#000" stop-opacity="0"/><stop offset="1" stop-color="#2a1a08" stop-opacity="${r(0.25 + age * 0.3)}"/></radialGradient>` +
41
+ `<radialGradient id="${id}-flash" cx="50%" cy="42%" r="55%"><stop offset="0" stop-color="#fff" stop-opacity="0.55"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></radialGradient></defs>`;
42
+ const picture = `<g clip-path="url(#${id}-clip)"><g${filter ? ` filter="url(#${id}-age)"` : ""}>` +
43
+ `<svg width="${r(w)}" height="${r(h)}" viewBox="${r(crop[0])} ${r(crop[1])} ${r(crop[2])} ${r(crop[3])}" preserveAspectRatio="xMidYMid slice">${frame}</svg></g>` +
44
+ `<rect width="${r(w)}" height="${r(h)}" fill="#e9c27a" opacity="${r(age * 0.22 * sepia + age * 0.08)}" style="mix-blend-mode:multiply"/>` +
45
+ (look === "flash" ? `<rect width="${r(w)}" height="${r(h)}" fill="url(#${id}-flash)" style="mix-blend-mode:screen"/>` : "") +
46
+ `<rect width="${r(w)}" height="${r(h)}" fill="url(#${id}-vig)"/></g>`;
47
+ const paperColor = age > 0.5 ? "#f3ead2" : "#fbf8ef";
48
+ let out = defs;
49
+ // The paper (its shadow on the page under it).
50
+ out += `<rect x="${r(-b + 4)}" y="${r(-b + 5)}" width="${r(pw)}" height="${r(ph)}" fill="#000" opacity="0.22"/>`;
51
+ out += `<rect x="${r(-b)}" y="${r(-b)}" width="${r(pw)}" height="${r(ph)}" fill="${paperColor}" stroke="#d8cfb6" stroke-width="1.2"/>`;
52
+ out += picture;
53
+ if (kind === "print") {
54
+ // Photo corners holding it on the page.
55
+ const c = Math.min(w, h) * 0.12;
56
+ const corner = (x, y, sx, sy) => `<path d="M${r(x)} ${r(y)} l${r(sx * c)} 0 l${r(-sx * c)} ${r(sy * c)} Z" fill="#1d1a17" opacity="0.88"/>`;
57
+ out += corner(-b, -b, 1, 1) + corner(w + b, -b, -1, 1) + corner(-b, h + b, 1, -1) + corner(w + b, h + b, -1, -1);
58
+ }
59
+ let size = [pw, ph];
60
+ if (o.caption) {
61
+ // The caption never runs wider than the picture: a smaller hand, then two lines, and each line
62
+ // held to the picture's width (textLength squeezes it whatever handwriting face is installed).
63
+ const room = w * 0.92;
64
+ const want = kind === "polaroid" ? bottom * 0.42 : Math.max(16, w * 0.085);
65
+ const lines = captionLines(o.caption, want, room);
66
+ const two = lines.length > 1;
67
+ const fs = Math.min(two ? want * 0.82 : want, fitSize(lines, room));
68
+ const lh = fs * 1.05;
69
+ const y0 = kind === "polaroid" ? h + bottom * (two ? 0.42 : 0.62) : h + b + fs * 1.15;
70
+ const tspans = lines.map((t, i) => {
71
+ const est = textWidth(t, fs);
72
+ const len = est > room * 0.7 ? ` textLength="${r(Math.min(est, room))}" lengthAdjust="spacingAndGlyphs"` : "";
73
+ return `<tspan x="${r(w / 2)}" y="${r(y0 + i * lh)}"${len}>${esc(t)}</tspan>`;
74
+ }).join("");
75
+ const color = kind === "polaroid" ? "#2b3a75" : o.ink ?? "#2b3a75";
76
+ out += `<text text-anchor="middle" font-family="${HANDWRITING}" font-size="${r(fs)}" fill="${color}" transform="rotate(-1.5 ${r(w / 2)} ${r(y0)})">${tspans}</text>`;
77
+ if (kind === "print")
78
+ size = [pw, ph + fs * 0.4 + lh * lines.length];
79
+ }
80
+ return { markup: `<g transform="translate(${r(b)} ${r(b)})">${out}</g>`, size };
81
+ }
82
+ /** Relative luminance (0 black … 1 white) of a #rgb / #rrggbb colour. */
83
+ export function luminance(hex) {
84
+ let h = hex.replace("#", "");
85
+ if (h.length === 3)
86
+ h = [...h].map((c) => c + c).join("");
87
+ const v = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255).map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
88
+ return Number.isFinite(v[0]) ? 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2] : 0.5;
89
+ }
90
+ /**
91
+ * Markup as a standalone picture: an `<image>` holding it as an SVG document (a data URI). The
92
+ * browser decodes it once and reuses it frame after frame, where inline markup — a whole frozen
93
+ * scene — would be rebuilt every frame; its ids are its own.
94
+ */
95
+ export function pictureMarkup(markup, size, at = [0, 0]) {
96
+ const [w, h] = size.map((v) => Math.ceil(v));
97
+ const doc = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${h}" viewBox="${r(at[0])} ${r(at[1])} ${w} ${h}">${markup}</svg>`;
98
+ const b64 = typeof Buffer !== "undefined" ? Buffer.from(doc, "utf8").toString("base64") : btoa(unescape(encodeURIComponent(doc)));
99
+ return `<image x="${r(at[0])}" y="${r(at[1])}" width="${w}" height="${h}" href="data:image/svg+xml;base64,${b64}"/>`;
100
+ }
101
+ /** A generous width for handwriting (wider faces than Caveat may stand in for it). */
102
+ const textWidth = (t, fs) => t.length * fs * 0.52;
103
+ /** The largest size at which every line fits `room`. */
104
+ const fitSize = (lines, room) => Math.min(...lines.map((t) => room / Math.max(1, t.length * 0.52)));
105
+ /** One line, or two split at the space nearest the middle when one line would be too small to read. */
106
+ function captionLines(text, fs, room) {
107
+ if (textWidth(text, fs) <= room || textWidth(text, fs * 0.7) <= room)
108
+ return [text];
109
+ const mid = text.length / 2;
110
+ let cut = -1;
111
+ for (let i = 0; i < text.length; i++)
112
+ if (text[i] === " " && (cut < 0 || Math.abs(i - mid) < Math.abs(cut - mid)))
113
+ cut = i;
114
+ return cut < 0 ? [text] : [text.slice(0, cut), text.slice(cut + 1)];
115
+ }
116
+ /** A page side's art: paper, photos (already drawn), notes. Drawn from x0 (−w for a left page) to x0 + w. */
117
+ export function sideMarkup(side, page, left, photos, id) {
118
+ const [w, h] = page;
119
+ const x0 = left ? -w : 0;
120
+ const paper = side?.paper ?? "#2f2a26";
121
+ // Black album pages, a gutter shadow along the spine.
122
+ // Everything on the page stays on it (clipped to the page: nothing spills onto the table or shows
123
+ // from a page under another).
124
+ let out = `<defs><linearGradient id="${id}-gutter" x1="${left ? 1 : 0}" y1="0" x2="${left ? 0 : 1}" y2="0"><stop offset="0" stop-color="#000" stop-opacity="0.45"/><stop offset="0.12" stop-color="#000" stop-opacity="0"/></linearGradient><clipPath id="${id}-page"><rect x="${r(x0)}" y="0" width="${r(w)}" height="${r(h)}"/></clipPath></defs>`;
125
+ out += `<rect x="${r(x0)}" y="0" width="${r(w)}" height="${r(h)}" fill="${paper}" stroke="#1c1916" stroke-width="2"/>`;
126
+ out += `<g clip-path="url(#${id}-page)">`;
127
+ out += photos.join("");
128
+ for (const n of side?.notes ?? []) {
129
+ // A note stays on its page: a smaller hand when it would run past the edge.
130
+ const room = Math.max(40, w - n.at[0] - 16);
131
+ const fs = Math.min(n.size ?? 34, room / Math.max(1, n.text.length * 0.52));
132
+ const est = textWidth(n.text, fs);
133
+ const len = est > room * 0.7 ? ` textLength="${r(Math.min(est, room))}" lengthAdjust="spacingAndGlyphs"` : "";
134
+ const ink = luminance(paper) < 0.45 ? "#f4eedc" : "#2b3a75";
135
+ out += `<text x="${r(x0 + n.at[0])}" y="${r(n.at[1])}"${len} font-family="${HANDWRITING}" font-size="${r(fs)}" fill="${ink}" transform="rotate(${n.rotation ?? -3} ${r(x0 + n.at[0])} ${r(n.at[1])})">${esc(n.text)}</text>`;
136
+ }
137
+ out += `</g><rect x="${r(x0)}" y="0" width="${r(w)}" height="${r(h)}" fill="url(#${id}-gutter)"/>`;
138
+ return out;
139
+ }
140
+ //# sourceMappingURL=album.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"album.js","sourceRoot":"","sources":["../src/album.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsBH,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACnD,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAChG,kEAAkE;AAClE,MAAM,CAAC,MAAM,WAAW,GAAG,+DAA+D,CAAC;AAE3F;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,CAAa,EAAE,EAAU;IAClE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACtB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IA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2
+ /** A compact catalogue of what a staging can use (for an AI prompt). */
3
+ export declare function describeKit(kit: Kit): {
4
+ cast: {
5
+ [k: string]: {
6
+ name: string;
7
+ aliases?: string[] | undefined;
8
+ clips: string[];
9
+ emotions: string[];
10
+ views: string[];
11
+ canFly: boolean;
12
+ wear: Record<string, string[]>;
13
+ };
14
+ };
15
+ sets: {
16
+ [k: string]: {
17
+ marks: string[];
18
+ furniture: {
19
+ [k: string]: string;
20
+ };
21
+ seats: {
22
+ [k: string]: {
23
+ seat: number | undefined;
24
+ lie: boolean;
25
+ } | {
26
+ lie?: undefined;
27
+ seat: number | undefined;
28
+ };
29
+ };
30
+ depth: boolean;
31
+ fixtures: {
32
+ [k: string]: string[];
33
+ };
34
+ fixtureClips: {
35
+ [k: string]: string[];
36
+ };
37
+ };
38
+ };
39
+ props: string[];
40
+ vehicles: string[];
41
+ /** Furniture kinds: can one sit (seat anchor) and/or lie (bed anchor) on it, and its wardrobe. */
42
+ furniture: {
43
+ [k: string]: {
44
+ sit: boolean;
45
+ lie: boolean;
46
+ wear: Record<string, string[]>;
47
+ };
48
+ };
49
+ /** Vehicles the cast can ride (rig with a "seat" anchor) and their wardrobe (e.g. training wheels). */
50
+ rides: {
51
+ [k: string]: {
52
+ wear: Record<string, string[]>;
53
+ };
54
+ };
55
+ fx: ("anger" | "aura" | "birds" | "burst" | "caption" | "dust" | "exclaim" | "focusLines" | "ghost" | "gloom" | "hearts" | "impact" | "impactFrame" | "lightbulb" | "notes" | "question" | "sparkle" | "speedLines" | "stars" | "surprise" | "sweat" | "zzz")[];
56
+ cameras: string[];
57
+ actions: string[];
58
+ lightMoods: string[];
59
+ };
60
+ //# sourceMappingURL=describe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAInC,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG;IAGhC,IAAI;;;;;;;;;;;IAiBJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;IAyBJ,KAAK;IACL,QAAQ;IACR,kGAAkG;IAClG,SAAS;;;;;;;IAMT,uGAAuG;IACvG,KAAK;;;;;IAKL,EAAE;IACF,OAAO;IACP,OAAO;IACP,UAAU;EAEb"}
@@ -0,0 +1,58 @@
1
+ import { FX_TYPES } from "@anime-studio/core";
2
+ import { ACTIONS, CAMERAS, MOODS, wardrobeOf } from "./direct.js";
3
+ /** A compact catalogue of what a staging can use (for an AI prompt). */
4
+ export function describeKit(kit) {
5
+ const doc = (id) => kit.characters[id];
6
+ return {
7
+ cast: Object.fromEntries(Object.entries(kit.cast).map(([id, c]) => {
8
+ const d = doc(id);
9
+ return [
10
+ id,
11
+ {
12
+ name: c.name,
13
+ ...(c.aliases?.length ? { aliases: c.aliases } : {}),
14
+ clips: Object.keys(d?.clips ?? {}).filter((k) => !["idle", "turn", "walkDepth"].includes(k)),
15
+ emotions: Object.keys(d?.controls?.emotion?.poses ?? {}),
16
+ views: Object.keys(d?.controls?.view?.poses ?? { profile: 1 }),
17
+ canFly: !!d?.meta?.canFly || !!d?.clips?.fly,
18
+ wear: wardrobeOf(d),
19
+ },
20
+ ];
21
+ })),
22
+ sets: Object.fromEntries(Object.entries(kit.sets).map(([id, s]) => [
23
+ id,
24
+ {
25
+ marks: Object.keys(s.marks),
26
+ // Places to sit drawn in the set (height above the ground), and the ones to lie on.
27
+ // Furniture that is part of the set (id → kind): sit / lie on it with `on: id`.
28
+ furniture: Object.fromEntries((s.furniture ?? []).map((f) => [f.id, f.kind])),
29
+ seats: Object.fromEntries(Object.entries(s.marks).filter(([, m]) => m.seat !== undefined).map(([id, m]) => [id, m.lie ? { seat: m.seat, lie: true } : { seat: m.seat }])),
30
+ depth: s.ground.far !== undefined,
31
+ fixtures: Object.fromEntries((s.fixtures ?? []).map((f) => {
32
+ const part = (f.channel ?? "parts.light.variant").split(".")[1];
33
+ const variants = doc(f.character)?.parts?.find((p) => p.id === part)?.variants;
34
+ return [f.id, variants ? Object.keys(variants) : []];
35
+ })),
36
+ // Clips a `fixture` beat can play on each fixture (a door's `open` / `close`): every clip of
37
+ // its rig but the one it loops by itself.
38
+ fixtureClips: Object.fromEntries((s.fixtures ?? []).map((f) => [f.id, Object.keys(doc(f.character)?.clips ?? {}).filter((c) => c !== (f.clip ?? "loop"))])),
39
+ },
40
+ ])),
41
+ props: Object.keys(kit.props),
42
+ vehicles: Object.keys(kit.vehicles ?? {}),
43
+ /** Furniture kinds: can one sit (seat anchor) and/or lie (bed anchor) on it, and its wardrobe. */
44
+ furniture: Object.fromEntries(Object.entries(kit.furniture ?? {}).map(([kind, f]) => {
45
+ const anchors = doc(f.character)?.anchors ?? {};
46
+ return [kind, { sit: !!anchors.seat, lie: !!(anchors.bed ?? anchors.seat), wear: wardrobeOf(doc(f.character)) }];
47
+ })),
48
+ /** Vehicles the cast can ride (rig with a "seat" anchor) and their wardrobe (e.g. training wheels). */
49
+ rides: Object.fromEntries(Object.entries(kit.vehicles ?? {})
50
+ .filter(([, v]) => doc(v.character)?.anchors?.seat)
51
+ .map(([kind, v]) => [kind, { wear: wardrobeOf(doc(v.character)) }])),
52
+ fx: [...FX_TYPES],
53
+ cameras: CAMERAS,
54
+ actions: ACTIONS,
55
+ lightMoods: Object.keys(MOODS),
56
+ };
57
+ }
58
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAK/D,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,GAAQ;IAClC,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,GAAG,CAAC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GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;QACnH,CAAC,CAAC,CACH;QACD,uGAAuG;QACvG,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;aAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAuD,EAAE,OAAO,EAAE,IAAI,CAAC;aACzG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CACtE;QACD,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC;QACjB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,90 @@
1
+ import { type MouthCue } from "@anime-studio/core";
2
+ import type { Block, Directed, Issue, Kit, Line, Staging, When } from "./types.js";
3
+ /**
4
+ * IK moves along arcs (`animation.arcs`): every pair of `set`s moving one chain's target on both
5
+ * axes (`ik.<id>.x` and `.y`, same actor, moment and duration, eased) gets a key halfway, pushed
6
+ * across the chord by `arcs × 0.3 × |chord|` away from the chain's root (unknown, or on the chord's
7
+ * line: upwards; a vertical chord there: forwards), as the scene's reach blends do. The two halves
8
+ * keep the move's sineInOut along the chord and meet at the midpoint at its speed (cubic-bezier
9
+ * eases per axis), so the hand flows through it. `joints` gives the chain's root and rest tip
10
+ * (character space). A pair taking over a move still under way, or taken over itself, is left straight.
11
+ */
12
+ export declare function arcIk<A extends Record<string, unknown> & {
13
+ at: number;
14
+ action: string;
15
+ }>(script: A[], arcs: number, joints: (actor: string, chain: string) => {
16
+ rest?: [number, number];
17
+ root?: [number, number];
18
+ } | undefined): A[];
19
+ /**
20
+ * Wardrobe controls of a rig (outfits, accessories): the pose controls listed in `meta.wardrobe`,
21
+ * or, without that list, every pose control except `view` and `emotion`.
22
+ */
23
+ export declare function wardrobeOf(doc: unknown): Record<string, string[]>;
24
+ export declare function closest(word: string, options: string[]): string;
25
+ /** Lighting presets for `light { mood }`: grade colour/opacity and the sun's height. */
26
+ export declare const MOODS: Record<string, {
27
+ grade: string;
28
+ opacity: number;
29
+ ambient?: {
30
+ color: string;
31
+ opacity: number;
32
+ };
33
+ }>;
34
+ export declare class Timeline {
35
+ readonly lines: Line[];
36
+ constructor(lines: Line[]);
37
+ start(i: number): number;
38
+ get end(): number;
39
+ /**
40
+ * Episode time of a `When`. An unknown line throws; a word the line does not have (or a line
41
+ * without word timings) falls back to the line's start (or end) and is reported to `miss`.
42
+ */
43
+ at(w: When, miss?: (message: string) => void): number;
44
+ blockStart(b: Block): number;
45
+ blockEnd(b: Block): number;
46
+ }
47
+ /** Volume of a music envelope at a time (linear between its keys). */
48
+ export declare function volumeAt(keys: [number, number][], t: number): number;
49
+ /** Mouth cues of a line from its word timings (relative to the line start). */
50
+ export declare function lineCues(l: Line): MouthCue[];
51
+ /** Every beat action (`do`). */
52
+ export declare const ACTIONS: string[];
53
+ /** Camera shot types. */
54
+ /** Camera types. */
55
+ export declare const CAMERAS: string[];
56
+ /**
57
+ * Gestures that read from the front as hand positions, not arm swings: where the near hand goes,
58
+ * relative to the face centre (in face heights: +x towards the near side, +y down).
59
+ */
60
+ export declare const FRONT_GESTURES: Record<string, {
61
+ hand: [number, number];
62
+ both?: boolean;
63
+ hold: number;
64
+ }>;
65
+ /**
66
+ * Turns a staging (blocks of continuous action, beats timed to lines and words, cuts and texts)
67
+ * into a toon-sequence with one scene per block. Pure: runs in the browser and in node.
68
+ */
69
+ export declare function direct(staging: Staging, lines: Line[], kit: Kit): Directed;
70
+ /** direct() + document validation + continuity checks. */
71
+ /**
72
+ * `strict`: the motion checks sample every frame instead of every tenth of a second (slower; run it
73
+ * before a render).
74
+ */
75
+ export interface CheckOptions {
76
+ strict?: boolean;
77
+ }
78
+ export declare function check(staging: Staging, lines: Line[], kit: Kit, opts?: CheckOptions): Issue[];
79
+ /** A 2D affine matrix [a, b, c, d, e, f] (SVG's: x' = a·x + c·y + e, y' = b·x + d·y + f). */
80
+ type Affine = [number, number, number, number, number, number];
81
+ /** An SVG `transform` attribute as one matrix (translate, scale, rotate(a[, cx, cy]), matrix, skewX, skewY; applied left to right). */
82
+ export declare function parseTransform(src: string | undefined): Affine;
83
+ /**
84
+ * Rough boxes of the shapes of an SVG drawing (absolute paths, polygons, rects, circles, ellipses)
85
+ * in its own coordinates, after the `transform`s of the groups they are in and their own (a gate
86
+ * drawn moved by a `<g transform>` is measured where it is drawn).
87
+ */
88
+ export declare function markupBoxes(svg: string): [number, number, number, number][];
89
+ export {};
90
+ //# sourceMappingURL=direct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direct.d.ts","sourceRoot":"","sources":["../src/direct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EA4BF,MAAM,oBAAoB,CAAC;AAGxC,OAAO,KAAK,EAAmB,KAAK,EAAkC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAgC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAqB/J;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK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