@algorisys/tinyfly 0.92.0 → 0.94.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.
- package/README.md +7 -6
- package/bin/tinyfly.mjs +34 -1
- package/docs/2d-animation-roadmap.md +191 -0
- package/docs/3d-rotations.md +164 -0
- package/docs/3d-support-plan.md +628 -0
- package/docs/DEPLOYMENT.md +414 -0
- package/docs/acting.md +529 -0
- package/docs/api-reference.md +2353 -0
- package/docs/camera.md +94 -0
- package/docs/cartoon-hands.md +96 -0
- package/docs/character-system-m1.md +218 -0
- package/docs/character-system-plan.md +384 -0
- package/docs/dance.md +315 -0
- package/docs/editor-guide.md +1249 -0
- package/docs/examples.md +765 -0
- package/docs/extending.md +168 -0
- package/docs/file-format.md +690 -0
- package/docs/getting-started.md +314 -0
- package/docs/grid-and-snapping.md +64 -0
- package/docs/gsap-compat.md +1241 -0
- package/docs/llm-guide.md +131 -0
- package/docs/maps.md +116 -0
- package/docs/onion-skinning.md +41 -0
- package/docs/pen-tool.md +65 -0
- package/docs/polygon-star.md +44 -0
- package/docs/scene-3d.md +299 -0
- package/docs/scroll-animation.md +314 -0
- package/docs/shape-morph.md +61 -0
- package/docs/sprite-sheet-export.md +54 -0
- package/docs/symbols-and-library.md +137 -0
- package/docs/teaching.md +348 -0
- package/docs/video-rendering.md +728 -0
- package/lib/addons/adapters.js +22 -18
- package/lib/addons/characters.js +3045 -2024
- package/lib/addons/target-properties-BtN9skb-.js +142 -0
- package/lib/browser/tinyfly.iife.js +9 -4
- package/lib/browser/tinyfly.js +6968 -5817
- package/lib/browser/tinyfly.umd.js +9 -4
- package/lib/engine/tinyfly-engine.js +286 -258
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +6 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/adapters/canvas/target-properties.d.ts +68 -0
- package/lib/types/characters/acting/beat-check.d.ts +102 -0
- package/lib/types/characters/acting/custom.d.ts +66 -0
- package/lib/types/characters/acting/gags.d.ts +10 -0
- package/lib/types/characters/acting/hand-path.d.ts +35 -0
- package/lib/types/characters/acting/index.d.ts +4 -0
- package/lib/types/characters/acting/persona.d.ts +93 -0
- package/lib/types/characters/acting/script.d.ts +75 -11
- package/lib/types/characters/capabilities.d.ts +61 -0
- package/lib/types/characters/code-panel.d.ts +201 -0
- package/lib/types/characters/figure-actions.d.ts +12 -0
- package/lib/types/characters/figure-props.d.ts +87 -0
- package/lib/types/characters/gaits.d.ts +8 -0
- package/lib/types/characters/index.d.ts +3 -0
- package/lib/types/characters/stick-figure.d.ts +9 -2
- package/lib/types/engine/authoring/did-you-mean.d.ts +14 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/llms-full.txt +12631 -0
- package/llms.txt +57 -0
- package/package.json +6 -2
- package/skills/tinyfly/SKILL.md +67 -0
- package/lib/addons/camera-C7bZOWMB.js +0 -33
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type ExpressionName, type PoseName, type StickFigureTarget, type StickPose, type StickStyle } from '../stick-figure';
|
|
2
|
+
import { type ActingOptions } from './acting';
|
|
3
|
+
import { type BeatProblem } from './beat-check';
|
|
4
|
+
import type { Cast } from './custom';
|
|
5
|
+
import { handPath, type HandPathOptions } from './hand-path';
|
|
6
|
+
import { type Beat, type ScriptResult } from './script';
|
|
7
|
+
import type { Track } from '../../engine/types';
|
|
8
|
+
/**
|
|
9
|
+
* A persona: one stick figure's look, acting and habits, in one value. Its
|
|
10
|
+
* figures look like it, its scripts act like it (its acting style, its gait
|
|
11
|
+
* for `go`, its usual face and stance, which `stand` returns to), and its own
|
|
12
|
+
* actions and gaits are known to its scripts, its checks and `describeTarget`.
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* const junior = persona({
|
|
16
|
+
* name: 'Junior',
|
|
17
|
+
* summary: 'A nervous junior developer',
|
|
18
|
+
* look: { color: '#2563eb', rubber: 0.6 },
|
|
19
|
+
* acting: 'full', gait: 'sneak', mood: 'worried',
|
|
20
|
+
* actions: { facepalm },
|
|
21
|
+
* })
|
|
22
|
+
* const hero = junior.figure({ x: 600, y: 300 })
|
|
23
|
+
* const script = junior.script('hero', [{ do: 'go', to: 300 }, { do: 'facepalm' }, { do: 'stand' }], { from: 600, ground: 300 })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Personas are plain values: make as many as the story needs, and put each
|
|
27
|
+
* one's figures in the scene under their own ids.
|
|
28
|
+
*/
|
|
29
|
+
export interface PersonaOptions extends Cast {
|
|
30
|
+
name: string;
|
|
31
|
+
/** One line: who this is */
|
|
32
|
+
summary?: string;
|
|
33
|
+
/** Feet to top of head, px (default 120) */
|
|
34
|
+
height?: number;
|
|
35
|
+
/** How it looks (the stick figure's style, without its height) */
|
|
36
|
+
look?: Omit<StickStyle, 'height'>;
|
|
37
|
+
/** How it acts: an acting style (default snappy) */
|
|
38
|
+
acting?: ActingOptions['style'];
|
|
39
|
+
/** How it walks when told to `go` somewhere: a built-in gait or one of its own (default walk) */
|
|
40
|
+
gait?: string;
|
|
41
|
+
/** Its usual face */
|
|
42
|
+
mood?: ExpressionName;
|
|
43
|
+
/** How it stands at rest: a named pose or joints (default the rest pose); `stand` returns here */
|
|
44
|
+
stance?: PoseName | Partial<StickPose>;
|
|
45
|
+
/** How much it moves its mouth when it talks (lip-sync energy, default 1) */
|
|
46
|
+
energy?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface Persona {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly summary: string;
|
|
51
|
+
/** Its own actions and gaits */
|
|
52
|
+
readonly cast: Cast;
|
|
53
|
+
/** Its resting pose, with its usual face */
|
|
54
|
+
readonly rest: StickPose;
|
|
55
|
+
readonly height: number;
|
|
56
|
+
/** A figure that looks like it, feet at x, y */
|
|
57
|
+
figure(at: {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
facing?: 1 | -1;
|
|
61
|
+
}): StickFigureTarget;
|
|
62
|
+
/** Beats compiled the way it acts (`from` and `ground` are where its figure was placed) */
|
|
63
|
+
script(target: string, beats: Beat[], options?: {
|
|
64
|
+
from?: number;
|
|
65
|
+
ground?: number;
|
|
66
|
+
facing?: 1 | -1;
|
|
67
|
+
}): ScriptResult;
|
|
68
|
+
/** Problems in beats written for it (its own actions count as known) */
|
|
69
|
+
check(beats: unknown): BeatProblem[];
|
|
70
|
+
/** Where its hand is over time, for things it carries */
|
|
71
|
+
handPath(target: string, tracks: Track[], options: Omit<HandPathOptions, 'style' | 'cast'>): ReturnType<typeof handPath>;
|
|
72
|
+
/** Who it is and what it can do, as data */
|
|
73
|
+
describe(): PersonaDescription;
|
|
74
|
+
}
|
|
75
|
+
export interface PersonaDescription {
|
|
76
|
+
name: string;
|
|
77
|
+
summary: string;
|
|
78
|
+
habits: {
|
|
79
|
+
height: number;
|
|
80
|
+
acting: string;
|
|
81
|
+
gait: string;
|
|
82
|
+
mood?: string;
|
|
83
|
+
stance: string;
|
|
84
|
+
};
|
|
85
|
+
/** Every action its beats can use, built-in and its own, a line each */
|
|
86
|
+
actions: Record<string, string>;
|
|
87
|
+
/** Its own actions and gaits, by name */
|
|
88
|
+
own: {
|
|
89
|
+
actions: string[];
|
|
90
|
+
gaits: string[];
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export declare function persona(options: PersonaOptions): Persona;
|
|
@@ -3,6 +3,7 @@ import { type ExpressionName, type PoseKey, type PoseName, type StickPose } from
|
|
|
3
3
|
import { type GaitName } from '../gaits';
|
|
4
4
|
import { type GagName } from './gags';
|
|
5
5
|
import { type SpokenLine } from './lip-sync';
|
|
6
|
+
import { type Cast } from './custom';
|
|
6
7
|
import type { ActingOptions } from './acting';
|
|
7
8
|
/**
|
|
8
9
|
* Beat scripts: a story written as what a character does, compiled into
|
|
@@ -25,14 +26,40 @@ import type { ActingOptions } from './acting';
|
|
|
25
26
|
* a named pose; gag beats splice in a gag; `say` lip-syncs a line. The poses
|
|
26
27
|
* then go through the acting pass, so the result winds up, overshoots and
|
|
27
28
|
* overlaps like any `actTracks()` output. Everything is plain keyframes.
|
|
29
|
+
*
|
|
30
|
+
* Beats can also act on things in the scene (a code panel's lines, a prop):
|
|
31
|
+
* `leap` jumps to a spot and lands on a new floor (`onto`, a scene y), `point`
|
|
32
|
+
* with a `target` aims the arm at it, and `swipe` sweeps an arm across it.
|
|
33
|
+
* Those beats report a `contact` time (and a `release`), so the thing they
|
|
34
|
+
* touch can react on the right frame:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const line = code.line(7)
|
|
38
|
+
* const script = scriptTracks('hero', [
|
|
39
|
+
* { do: 'leap', to: line.right + 30, onto: code.line(8).top },
|
|
40
|
+
* { do: 'point', target: line, say: 'Unreachable!' },
|
|
41
|
+
* { do: 'swipe', target: line },
|
|
42
|
+
* ], { from: 600, ground: 330, height: 110 })
|
|
43
|
+
* const swipe = script.beats[2]
|
|
44
|
+
* code.remove(7, { at: swipe.contact!, duration: swipe.release! - swipe.contact!, from: 'right' })
|
|
45
|
+
* ```
|
|
28
46
|
*/
|
|
29
47
|
/** The ways to get somewhere. */
|
|
30
48
|
export type GaitAction = GaitName;
|
|
31
49
|
/** Everything a beat can do. */
|
|
32
|
-
export type Action = GaitAction | PoseName | GagName | 'look' | 'say' | 'hold' | 'stand' | 'face' | 'zip';
|
|
50
|
+
export type Action = GaitAction | PoseName | GagName | 'look' | 'say' | 'hold' | 'stand' | 'face' | 'zip' | 'leap' | 'swipe' | 'grab' | 'throw' | 'kick' | 'put' | 'write' | 'push' | 'go';
|
|
51
|
+
/** Something in the scene a beat acts on: a point, or a box (a `CodeBox` fits). */
|
|
52
|
+
export interface BeatTarget {
|
|
53
|
+
/** The centre, scene px */
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
/** A box's left and right edges, for `swipe` (default the centre) */
|
|
57
|
+
left?: number;
|
|
58
|
+
right?: number;
|
|
59
|
+
}
|
|
33
60
|
export interface Beat {
|
|
34
|
-
/** What happens */
|
|
35
|
-
do: Action;
|
|
61
|
+
/** What happens: a built-in action, or one of the cast's own actions and gaits */
|
|
62
|
+
do: Action | (string & {});
|
|
36
63
|
/** When it starts, ms (default: when the beat before ends) */
|
|
37
64
|
at?: number;
|
|
38
65
|
/** How long it takes, ms (default: the action's own length) */
|
|
@@ -47,10 +74,27 @@ export interface Beat {
|
|
|
47
74
|
say?: string;
|
|
48
75
|
/** Joints to change on top of the action's pose */
|
|
49
76
|
pose?: Partial<StickPose>;
|
|
77
|
+
/**
|
|
78
|
+
* `point`, `swipe`, `grab`, `kick`, `put`: what to aim at; `throw`: where to
|
|
79
|
+
* throw toward; `write`: where it writes (its `left` to `right`); `push`: the
|
|
80
|
+
* thing it pushes, along to `to`
|
|
81
|
+
*/
|
|
82
|
+
target?: BeatTarget;
|
|
83
|
+
/**
|
|
84
|
+
* The floor it ends the beat on, scene y. `leap` lands on it; any other
|
|
85
|
+
* beat is carried there over the beat (a line it stands on moving up).
|
|
86
|
+
*/
|
|
87
|
+
onto?: number;
|
|
50
88
|
}
|
|
51
|
-
export interface ScriptOptions extends ActingOptions {
|
|
89
|
+
export interface ScriptOptions extends ActingOptions, Cast {
|
|
90
|
+
/** The gait `go` walks in (a built-in or one of `gaits`; default walk) */
|
|
91
|
+
gait?: string;
|
|
92
|
+
/** The stance `stand` returns to (default rest) */
|
|
93
|
+
rest?: StickPose;
|
|
52
94
|
/** Scene x the figure was placed at (its `x` track is an offset from here; default 0) */
|
|
53
95
|
from?: number;
|
|
96
|
+
/** Scene y of its feet as placed (its `y` track is an offset from here; default 0) */
|
|
97
|
+
ground?: number;
|
|
54
98
|
/** Figure height, px, for stride length (default 300, the stick figure's) */
|
|
55
99
|
height?: number;
|
|
56
100
|
/** Which way it faces at the start (default 1, screen-right) */
|
|
@@ -69,20 +113,36 @@ export interface ScriptResult {
|
|
|
69
113
|
lines: SpokenLine[];
|
|
70
114
|
/** The key poses, before acting */
|
|
71
115
|
keys: PoseKey[];
|
|
72
|
-
/** When each beat starts and ends, ms */
|
|
73
|
-
beats:
|
|
74
|
-
start: number;
|
|
75
|
-
end: number;
|
|
76
|
-
}>;
|
|
116
|
+
/** When each beat starts and ends, ms, and when an acting beat touches its target and lets go */
|
|
117
|
+
beats: ScriptBeatSpan[];
|
|
77
118
|
/** Effects to draw, with when and where (scene x on the ground): dust where a zip leaves and where a take lands */
|
|
78
119
|
effects: ScriptEffect[];
|
|
79
120
|
}
|
|
121
|
+
export interface ScriptBeatSpan {
|
|
122
|
+
start: number;
|
|
123
|
+
end: number;
|
|
124
|
+
/**
|
|
125
|
+
* `leap`: when it lands. `point`: when the arm arrives. `swipe`: when the
|
|
126
|
+
* hand reaches the target. `grab`: when the hand closes on it. `kick`: when
|
|
127
|
+
* the foot meets it. `throw`: when it lets go. `put`: when the hand sets it
|
|
128
|
+
* down. `write`: when the pen touches. `push`: when the hands meet it.
|
|
129
|
+
*/
|
|
130
|
+
contact?: number;
|
|
131
|
+
/**
|
|
132
|
+
* `swipe`: when the hand has crossed the target. `point`: when the beat
|
|
133
|
+
* ends. `throw`: when it lets go. `write`: when the writing is done. `push`:
|
|
134
|
+
* when it has been pushed to `to`.
|
|
135
|
+
*/
|
|
136
|
+
release?: number;
|
|
137
|
+
}
|
|
80
138
|
/** A cartoon effect a script asks for: draw it with `drawDustPuff` (progress from `time`, over `length` ms). */
|
|
81
139
|
export interface ScriptEffect {
|
|
82
140
|
kind: 'dust';
|
|
83
141
|
time: number;
|
|
84
142
|
/** Scene x on the ground */
|
|
85
143
|
x: number;
|
|
144
|
+
/** Scene y of the floor it is on */
|
|
145
|
+
y: number;
|
|
86
146
|
/** How long it shows, ms */
|
|
87
147
|
length: number;
|
|
88
148
|
}
|
|
@@ -90,5 +150,9 @@ export interface ScriptEffect {
|
|
|
90
150
|
export declare const GAIT_CYCLE_MS: Record<GaitName, number>;
|
|
91
151
|
/** How long a line takes to say, ms. */
|
|
92
152
|
export declare function speechDuration(text: string): number;
|
|
93
|
-
/**
|
|
94
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Compile beats into tracks on `target` (a `stickFigureTarget`). Throws when a
|
|
155
|
+
* beat has an unknown action, mood, joint or field, or misses a field its
|
|
156
|
+
* action needs: the message names what was probably meant (see `checkBeats`).
|
|
157
|
+
*/
|
|
158
|
+
export declare function scriptTracks(target: string, written: Beat[], options?: ScriptOptions): ScriptResult;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type PropertyInfo } from '../adapters/canvas/target-properties';
|
|
2
|
+
import type { Cast } from './acting/custom';
|
|
3
|
+
export interface Capabilities {
|
|
4
|
+
version?: string;
|
|
5
|
+
timing: string;
|
|
6
|
+
easings: {
|
|
7
|
+
named: string[];
|
|
8
|
+
parametric: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
trackKinds: Record<string, string>;
|
|
11
|
+
canvasProperties: Record<string, PropertyInfo & {
|
|
12
|
+
types: readonly string[];
|
|
13
|
+
}>;
|
|
14
|
+
stickFigure: {
|
|
15
|
+
poseFields: Record<string, PropertyInfo>;
|
|
16
|
+
props: Record<string, PropertyInfo>;
|
|
17
|
+
handFields: Record<string, PropertyInfo>;
|
|
18
|
+
poses: string[];
|
|
19
|
+
expressions: string[];
|
|
20
|
+
gags: Record<string, number>;
|
|
21
|
+
gaits: string[];
|
|
22
|
+
actingStyles: string[];
|
|
23
|
+
beatFields: readonly string[];
|
|
24
|
+
actions: Record<string, {
|
|
25
|
+
summary: string;
|
|
26
|
+
needs?: string[];
|
|
27
|
+
uses?: string[];
|
|
28
|
+
}>;
|
|
29
|
+
dances: Record<string, string[]>;
|
|
30
|
+
flips: Record<string, string>;
|
|
31
|
+
handShapes: string[];
|
|
32
|
+
mudras: string[];
|
|
33
|
+
};
|
|
34
|
+
/** Making your own: actions, gaits and personas */
|
|
35
|
+
custom: {
|
|
36
|
+
api: Record<string, string>;
|
|
37
|
+
actions: Record<string, {
|
|
38
|
+
summary: string;
|
|
39
|
+
needs?: string[];
|
|
40
|
+
}>;
|
|
41
|
+
gaits: Record<string, string>;
|
|
42
|
+
};
|
|
43
|
+
character: {
|
|
44
|
+
poses: string[];
|
|
45
|
+
expressions: string[];
|
|
46
|
+
gags: string[];
|
|
47
|
+
};
|
|
48
|
+
codePanel: {
|
|
49
|
+
languages: readonly string[];
|
|
50
|
+
removeStyles: readonly string[];
|
|
51
|
+
anchors: Record<string, string>;
|
|
52
|
+
edits: Record<string, string>;
|
|
53
|
+
};
|
|
54
|
+
cameraShots: Record<string, string>;
|
|
55
|
+
teach: Record<string, string>;
|
|
56
|
+
cli: Record<string, string>;
|
|
57
|
+
}
|
|
58
|
+
/** The catalog; pass a cast (or a persona's `cast`) to list its own actions and gaits too. */
|
|
59
|
+
export declare function capabilities(version?: string, cast?: Cast): Capabilities;
|
|
60
|
+
/** The catalog as markdown, for people and language models. */
|
|
61
|
+
export declare function capabilitiesMarkdown(version?: string, cast?: Cast): string;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { CustomTarget } from '../adapters/canvas/canvas-adapter';
|
|
2
|
+
import type { EasingType, Track } from '../engine/types';
|
|
3
|
+
/**
|
|
4
|
+
* A code listing as a scene object characters can act on: they stand on its
|
|
5
|
+
* lines, point at its tokens and swipe lines away.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const code = codePanel({ code: source, language: 'go', x: 40, y: 30 })
|
|
9
|
+
* const line = code.line(7) // where line 7 is: stand on line.top, point at its centre
|
|
10
|
+
* const word = code.token(7, 'Println') // where a word on it is
|
|
11
|
+
* code.highlight(7, { at: 1200 }) // timed edits, in ms
|
|
12
|
+
* code.remove(7, { at: 2400, duration: 300, from: 'right' })
|
|
13
|
+
* const scene = { targets: { code: code.target, hero }, tracks: [...code.tracks('code'), ...script.tracks] }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Layout is fixed-width arithmetic (characters are `charWidth` em wide, lines
|
|
17
|
+
* `lineHeight` em apart), never measured from a font, so anchors are the same
|
|
18
|
+
* in a browser, a worker or a build script. Lines are numbered from 1, as an
|
|
19
|
+
* editor numbers them. Edits are recorded on the panel and written out by
|
|
20
|
+
* `tracks()` as plain keyframes on the panel's props: `line.N.highlight`,
|
|
21
|
+
* `line.N.strike`, `line.N.wipe`, `line.N.reveal` and `line.N.shift`.
|
|
22
|
+
*
|
|
23
|
+
* Words can come loose: `piece(n, text)` makes a word a piece that can be
|
|
24
|
+
* carried (`follow` a path, such as a hand's), thrown or kicked away
|
|
25
|
+
* (`fling`), moved (`move`), and replaced by typing new text into its place
|
|
26
|
+
* (`write`), or dropped into another line (`drop`). Pieces animate
|
|
27
|
+
* `piece.K.x`, `.y` (offsets from home), `.rotate`, `.opacity`, `.write` and
|
|
28
|
+
* `.away` (its old place closing). New text can be typed into a line
|
|
29
|
+
* (`insert`); an insert or a drop opens room in its line (`insert.K.open`,
|
|
30
|
+
* `insert.K.type`).
|
|
31
|
+
*/
|
|
32
|
+
export type CodeLanguage = 'go' | 'rust' | 'csharp' | 'javascript' | 'typescript' | 'python' | 'plain';
|
|
33
|
+
export interface CodeTheme {
|
|
34
|
+
background: string;
|
|
35
|
+
gutter: string;
|
|
36
|
+
text: string;
|
|
37
|
+
keyword: string;
|
|
38
|
+
string: string;
|
|
39
|
+
number: string;
|
|
40
|
+
comment: string;
|
|
41
|
+
highlight: string;
|
|
42
|
+
strike: string;
|
|
43
|
+
font: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const CODE_THEME: CodeTheme;
|
|
46
|
+
export interface CodePanelOptions {
|
|
47
|
+
code: string;
|
|
48
|
+
language?: CodeLanguage;
|
|
49
|
+
/** Top-left corner of the panel, scene px */
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
/** px (default 16) */
|
|
53
|
+
fontSize?: number;
|
|
54
|
+
/** Line spacing, em (default 1.6) */
|
|
55
|
+
lineHeight?: number;
|
|
56
|
+
/** Width of a character, em (default 0.6, which most monospace fonts are) */
|
|
57
|
+
charWidth?: number;
|
|
58
|
+
/** Inside the panel's edge, px (default 12) */
|
|
59
|
+
padding?: number;
|
|
60
|
+
/** Show line numbers (default true) */
|
|
61
|
+
lineNumbers?: boolean;
|
|
62
|
+
/** Panel width, px (default: fits the longest line) */
|
|
63
|
+
width?: number;
|
|
64
|
+
/** Lines that start hidden, to be typed in with `type()` */
|
|
65
|
+
hidden?: number[];
|
|
66
|
+
theme?: Partial<CodeTheme>;
|
|
67
|
+
}
|
|
68
|
+
/** A place on the panel, scene px. Stand on `top`; point at `x`, `y` (the centre). */
|
|
69
|
+
export interface CodeBox {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
left: number;
|
|
73
|
+
right: number;
|
|
74
|
+
top: number;
|
|
75
|
+
bottom: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
}
|
|
79
|
+
export interface CodeEditOptions {
|
|
80
|
+
/** When the edit starts, ms */
|
|
81
|
+
at: number;
|
|
82
|
+
/** ms (default 300) */
|
|
83
|
+
duration?: number;
|
|
84
|
+
easing?: EasingType;
|
|
85
|
+
}
|
|
86
|
+
/** How a removed line goes: wiped away, knocked off the panel, or out of focus. */
|
|
87
|
+
export type CodeRemoveStyle = 'wipe' | 'fly' | 'blur';
|
|
88
|
+
export declare const REMOVE_STYLES: readonly CodeRemoveStyle[];
|
|
89
|
+
export interface CodeRemoveOptions extends CodeEditOptions {
|
|
90
|
+
/** `wipe` (default) erases it from one side; `fly` knocks it off the panel, blurring as it goes; `blur` fades it out of focus where it is */
|
|
91
|
+
style?: CodeRemoveStyle;
|
|
92
|
+
/** The side the wipe starts from, or the side `fly` knocks it from (default left: it flies right) */
|
|
93
|
+
from?: 'left' | 'right';
|
|
94
|
+
/** How long the lines below take to close the gap, ms (default 250) */
|
|
95
|
+
close?: number;
|
|
96
|
+
}
|
|
97
|
+
/** A word that can come loose from its line: made by `piece()`. */
|
|
98
|
+
export interface CodePiece {
|
|
99
|
+
/** Its key in the panel's props (`piece.K.x`…) */
|
|
100
|
+
readonly id: number;
|
|
101
|
+
readonly line: number;
|
|
102
|
+
readonly column: number;
|
|
103
|
+
readonly text: string;
|
|
104
|
+
/** Where it sits in its line */
|
|
105
|
+
readonly home: CodeBox;
|
|
106
|
+
}
|
|
107
|
+
/** A point at a time, scene px: a path for a piece to follow (see `handPath`). */
|
|
108
|
+
export interface TimedPoint {
|
|
109
|
+
time: number;
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
}
|
|
113
|
+
export interface CodeFlingOptions {
|
|
114
|
+
/** When it leaves, ms */
|
|
115
|
+
at: number;
|
|
116
|
+
/** px/ms (default: how fast it was moving along its `follow` path at `at`, or up and to the right) */
|
|
117
|
+
velocity?: {
|
|
118
|
+
x: number;
|
|
119
|
+
y: number;
|
|
120
|
+
};
|
|
121
|
+
/** Turns, degrees per ms (default 0.6, signed by the throw's direction) */
|
|
122
|
+
spin?: number;
|
|
123
|
+
/** px/ms² (default 0.0016) */
|
|
124
|
+
gravity?: number;
|
|
125
|
+
/** How long it flies before it is gone, ms (default 900) */
|
|
126
|
+
duration?: number;
|
|
127
|
+
}
|
|
128
|
+
export interface CodePanel {
|
|
129
|
+
/** The canvas target that draws the panel; put it in the scene's targets */
|
|
130
|
+
readonly target: CustomTarget;
|
|
131
|
+
readonly lines: readonly string[];
|
|
132
|
+
/** The whole panel */
|
|
133
|
+
readonly box: CodeBox;
|
|
134
|
+
/** Where line `n`'s text is (its width is the text's, at least one character). At `time`, after the gaps of removed lines have closed. */
|
|
135
|
+
line(n: number, time?: number): CodeBox;
|
|
136
|
+
/** Where the `occurrence`th `text` on line `n` is (default the first) */
|
|
137
|
+
token(n: number, text: string, occurrence?: number, time?: number): CodeBox;
|
|
138
|
+
/** Tint a line, or clear it with `on: false` */
|
|
139
|
+
highlight(n: number | number[], options: CodeEditOptions & {
|
|
140
|
+
on?: boolean;
|
|
141
|
+
}): CodePanel;
|
|
142
|
+
/** Strike a line through, left to right */
|
|
143
|
+
strike(n: number | number[], options: CodeEditOptions): CodePanel;
|
|
144
|
+
/** Wipe lines away, then close the gap: the lines below move up */
|
|
145
|
+
remove(n: number | number[], options: CodeRemoveOptions): CodePanel;
|
|
146
|
+
/** Type a hidden line in, character by character */
|
|
147
|
+
type(n: number, options: CodeEditOptions): CodePanel;
|
|
148
|
+
/** Make the `occurrence`th `text` on line `n` a piece that can come loose */
|
|
149
|
+
piece(n: number, text: string, occurrence?: number): CodePiece;
|
|
150
|
+
/** Carry a piece along a path of scene points (its centre follows them) */
|
|
151
|
+
follow(piece: CodePiece, path: TimedPoint[]): CodePanel;
|
|
152
|
+
/** Throw or kick a piece away: it flies on a ballistic arc, spinning, and fades */
|
|
153
|
+
fling(piece: CodePiece, options: CodeFlingOptions): CodePanel;
|
|
154
|
+
/** Move a piece's centre to a scene point (back home: its `home` centre) */
|
|
155
|
+
move(piece: CodePiece, options: CodeEditOptions & {
|
|
156
|
+
to: {
|
|
157
|
+
x: number;
|
|
158
|
+
y: number;
|
|
159
|
+
};
|
|
160
|
+
}): CodePanel;
|
|
161
|
+
/** Type new text into a piece's place in its line; the rest of the line makes room */
|
|
162
|
+
write(piece: CodePiece, text: string, options: CodeEditOptions): CodePanel;
|
|
163
|
+
/**
|
|
164
|
+
* A place in line `n`: `width` characters (default 1) starting at `column`
|
|
165
|
+
* (0 is before its first character, its length just past its end), after
|
|
166
|
+
* any room inserts before it have opened. Aim a `put` or a `write` here.
|
|
167
|
+
*/
|
|
168
|
+
spot(n: number, column: number, width?: number, time?: number): CodeBox;
|
|
169
|
+
/** Type new text into line `n` before `column`; the rest of the line makes room as it is typed */
|
|
170
|
+
insert(n: number, column: number, text: string, options: CodeEditOptions): CodePanel;
|
|
171
|
+
/**
|
|
172
|
+
* Put a piece into line `n` before `column`: it moves there as the line
|
|
173
|
+
* opens room for it, and its old place closes. Into its own line, it slides
|
|
174
|
+
* along (linear by default) and the text it passes closes up behind it.
|
|
175
|
+
*/
|
|
176
|
+
drop(piece: CodePiece, n: number, column: number, options: CodeEditOptions): CodePanel;
|
|
177
|
+
/** Where a piece dropped into line `n` before `column` would land (its own line closes up behind it) */
|
|
178
|
+
landing(piece: CodePiece, n: number, column: number, time?: number): CodeBox;
|
|
179
|
+
/**
|
|
180
|
+
* A figure's tracks with it carried along by the line it stands on: while
|
|
181
|
+
* its feet are on a line's top (as laid out, before any gaps closed), its
|
|
182
|
+
* `y` moves with that line. `ground` is the script's `ground`.
|
|
183
|
+
*/
|
|
184
|
+
ride(tracks: Track[], target: string, options: {
|
|
185
|
+
ground: number;
|
|
186
|
+
every?: number;
|
|
187
|
+
}): Track[];
|
|
188
|
+
/** The recorded edits as tracks on `target` (the panel's key in the scene) */
|
|
189
|
+
tracks(target: string): Track[];
|
|
190
|
+
}
|
|
191
|
+
export declare function codePanel(options: CodePanelOptions): CodePanel;
|
|
192
|
+
/** What a code panel's methods do, for its `about` and the capability catalog. */
|
|
193
|
+
export declare const CODE_PANEL_EDITS: Record<string, string>;
|
|
194
|
+
export interface CodeToken {
|
|
195
|
+
text: string;
|
|
196
|
+
kind: 'text' | 'keyword' | 'string' | 'number' | 'comment';
|
|
197
|
+
}
|
|
198
|
+
/** The languages a code panel colours. */
|
|
199
|
+
export declare const CODE_LANGUAGES: CodeLanguage[];
|
|
200
|
+
/** Split one line into coloured runs: strings, line comments, numbers, keywords and the rest. */
|
|
201
|
+
export declare function codeTokens(line: string, language: CodeLanguage): CodeToken[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the stick figure finds the list of actions it can be given. The list
|
|
3
|
+
* comes from the beat scripts (gaits, poses, gags and acting beats), which
|
|
4
|
+
* are built on the figure, so the figure cannot import them without a cycle.
|
|
5
|
+
* The acting module registers the list here when it loads (the characters
|
|
6
|
+
* entry always loads it), and the figure's `about.actions` reads it then.
|
|
7
|
+
*/
|
|
8
|
+
import type { Cast } from './acting/custom';
|
|
9
|
+
/** Called once by the acting module. */
|
|
10
|
+
export declare function provideFigureActions(list: (cast?: Cast) => Record<string, string>): void;
|
|
11
|
+
/** The actions a stick figure can be given (with a cast's own), a line each (empty until the acting module has loaded). */
|
|
12
|
+
export declare function figureActions(cast?: Cast): Record<string, string>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { PropertyInfo } from '../adapters/canvas/target-properties';
|
|
2
|
+
/** Every pose field (`StickPose`). */
|
|
3
|
+
export declare const STICK_POSE_FIELDS: {
|
|
4
|
+
lean: PropertyInfo;
|
|
5
|
+
bend: PropertyInfo;
|
|
6
|
+
headTilt: PropertyInfo;
|
|
7
|
+
leftShoulder: PropertyInfo;
|
|
8
|
+
rightShoulder: PropertyInfo;
|
|
9
|
+
leftElbow: PropertyInfo;
|
|
10
|
+
rightElbow: PropertyInfo;
|
|
11
|
+
leftHip: PropertyInfo;
|
|
12
|
+
rightHip: PropertyInfo;
|
|
13
|
+
leftKnee: PropertyInfo;
|
|
14
|
+
rightKnee: PropertyInfo;
|
|
15
|
+
leftWrist: PropertyInfo;
|
|
16
|
+
rightWrist: PropertyInfo;
|
|
17
|
+
leftAnkle: PropertyInfo;
|
|
18
|
+
rightAnkle: PropertyInfo;
|
|
19
|
+
leftFootOut: PropertyInfo;
|
|
20
|
+
rightFootOut: PropertyInfo;
|
|
21
|
+
mouth: PropertyInfo;
|
|
22
|
+
smile: PropertyInfo;
|
|
23
|
+
mouthWidth: {
|
|
24
|
+
description: string;
|
|
25
|
+
unit: string;
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
};
|
|
29
|
+
blink: PropertyInfo;
|
|
30
|
+
leftEye: {
|
|
31
|
+
description: string;
|
|
32
|
+
unit: string;
|
|
33
|
+
min: number;
|
|
34
|
+
max: number;
|
|
35
|
+
};
|
|
36
|
+
rightEye: {
|
|
37
|
+
description: string;
|
|
38
|
+
unit: string;
|
|
39
|
+
min: number;
|
|
40
|
+
max: number;
|
|
41
|
+
};
|
|
42
|
+
leftBrow: PropertyInfo;
|
|
43
|
+
rightBrow: PropertyInfo;
|
|
44
|
+
browTilt: PropertyInfo;
|
|
45
|
+
lookX: PropertyInfo;
|
|
46
|
+
lookY: PropertyInfo;
|
|
47
|
+
stretch: {
|
|
48
|
+
description: string;
|
|
49
|
+
unit: string;
|
|
50
|
+
min: number;
|
|
51
|
+
max: number;
|
|
52
|
+
};
|
|
53
|
+
turn: PropertyInfo;
|
|
54
|
+
sit: PropertyInfo;
|
|
55
|
+
spin: PropertyInfo;
|
|
56
|
+
rise: {
|
|
57
|
+
description: string;
|
|
58
|
+
unit: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/** The figure target's props besides the pose. */
|
|
62
|
+
export declare const STICK_FIGURE_EXTRAS: {
|
|
63
|
+
walk: {
|
|
64
|
+
description: string;
|
|
65
|
+
unit: string;
|
|
66
|
+
};
|
|
67
|
+
walking: PropertyInfo;
|
|
68
|
+
gait: {
|
|
69
|
+
description: string;
|
|
70
|
+
kind: "string";
|
|
71
|
+
};
|
|
72
|
+
talk: PropertyInfo;
|
|
73
|
+
rubber: PropertyInfo;
|
|
74
|
+
facing: {
|
|
75
|
+
description: string;
|
|
76
|
+
unit: string;
|
|
77
|
+
min: number;
|
|
78
|
+
max: number;
|
|
79
|
+
};
|
|
80
|
+
beat: {
|
|
81
|
+
description: string;
|
|
82
|
+
unit: string;
|
|
83
|
+
};
|
|
84
|
+
dancing: PropertyInfo;
|
|
85
|
+
};
|
|
86
|
+
/** A cartoon hand's pose fields (`hand.left.<field>` / `hand.right.<field>` props when the style has hands). */
|
|
87
|
+
export declare const HAND_FIELDS: Record<string, PropertyInfo>;
|
|
@@ -51,6 +51,7 @@ export interface Gait {
|
|
|
51
51
|
* - `strut`: chest out, head high, a swagger.
|
|
52
52
|
* - `tired`: slumped, dragging, arms hanging.
|
|
53
53
|
* - `run`: leaning in, knees high, arms pumping, off the ground between steps.
|
|
54
|
+
* - `shove`: short steady steps that leave the body and arms alone, for pushing something along.
|
|
54
55
|
*/
|
|
55
56
|
export declare const GAITS: {
|
|
56
57
|
walk: {
|
|
@@ -124,6 +125,13 @@ export declare const GAITS: {
|
|
|
124
125
|
bounce: number;
|
|
125
126
|
squash: number;
|
|
126
127
|
};
|
|
128
|
+
shove: {
|
|
129
|
+
swing: number;
|
|
130
|
+
knee: number;
|
|
131
|
+
arm: number;
|
|
132
|
+
elbow: number;
|
|
133
|
+
lean: number;
|
|
134
|
+
};
|
|
127
135
|
};
|
|
128
136
|
export type GaitName = keyof typeof GAITS;
|
|
129
137
|
/** A gait by name or as data; an unknown name is the plain walk. */
|
|
@@ -14,6 +14,7 @@ export { characterObjects } from './scene-objects';
|
|
|
14
14
|
export * from '../adapters/canvas/sketch';
|
|
15
15
|
export * from '../adapters/canvas/camera';
|
|
16
16
|
export * from './erase';
|
|
17
|
+
export * from './code-panel';
|
|
17
18
|
export * from '../adapters/canvas/polyline';
|
|
18
19
|
export * from './hand';
|
|
19
20
|
export * from './character';
|
|
@@ -24,3 +25,5 @@ export { createPen, ellipsePoints, type Pen, type Look, type PencilOptions, type
|
|
|
24
25
|
export { basicOutfit, type BasicOutfitOptions } from './wardrobe/basic-outfit';
|
|
25
26
|
export * from './hands';
|
|
26
27
|
export * from './acting';
|
|
28
|
+
export * from './capabilities';
|
|
29
|
+
export { describeTarget, checkTracks, animatableProperties, CANVAS_PROPERTIES, type PropertyInfo, type TargetAbout, type TargetDescription, type TrackProblem } from '../adapters/canvas/target-properties';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Cast } from './acting/custom';
|
|
1
2
|
import type { CustomTarget } from '../adapters/canvas';
|
|
2
3
|
import type { FrameInfo } from '../headless/video-scene';
|
|
3
4
|
import type { EasingType, Track } from '../engine/types';
|
|
@@ -149,6 +150,8 @@ export declare const POSES: {
|
|
|
149
150
|
crouch: StickPose;
|
|
150
151
|
sit: StickPose;
|
|
151
152
|
jump: StickPose;
|
|
153
|
+
duck: StickPose;
|
|
154
|
+
lie: StickPose;
|
|
152
155
|
sideSplit: StickPose;
|
|
153
156
|
frontSplit: StickPose;
|
|
154
157
|
};
|
|
@@ -409,9 +412,9 @@ export type Dancer = (beat: number) => DanceFrame;
|
|
|
409
412
|
* cycle (by `walking`), a dance (by `dancing`) and the chatter of `talk`
|
|
410
413
|
* folded in, and the dance's hand shapes.
|
|
411
414
|
*/
|
|
412
|
-
export declare function resolveStickFrame(props: StickFigureProps, time: number, dance?: Dancer): DanceFrame;
|
|
415
|
+
export declare function resolveStickFrame(props: StickFigureProps, time: number, dance?: Dancer, gaits?: Cast['gaits']): DanceFrame;
|
|
413
416
|
/** The pose of {@link resolveStickFrame}. */
|
|
414
|
-
export declare function resolveStickPose(props: StickFigureProps, time: number, dance?: Dancer): StickPose;
|
|
417
|
+
export declare function resolveStickPose(props: StickFigureProps, time: number, dance?: Dancer, gaits?: Cast['gaits']): StickPose;
|
|
415
418
|
/** Prop names for a hand's pose fields on a stick-figure target: `hand.left.index.curl`, … */
|
|
416
419
|
export declare const handProp: (side: StickSide, field: string) => string;
|
|
417
420
|
export interface StickFigureTargetOptions {
|
|
@@ -426,6 +429,8 @@ export interface StickFigureTargetOptions {
|
|
|
426
429
|
* (see `dancer()` and `danceTracks()`). Its hand shapes show when the style has `hands`.
|
|
427
430
|
*/
|
|
428
431
|
dance?: Dancer;
|
|
432
|
+
/** Your own actions and gaits (see `defineAction`, `defineGait`): it draws the gaits, and lists the actions in `about` */
|
|
433
|
+
cast?: Cast;
|
|
429
434
|
}
|
|
430
435
|
/** A `custom` target made by {@link stickFigureTarget}. */
|
|
431
436
|
export interface StickFigureTarget extends CustomTarget {
|
|
@@ -433,6 +438,8 @@ export interface StickFigureTarget extends CustomTarget {
|
|
|
433
438
|
readonly figureStyle: StickStyle;
|
|
434
439
|
/** The dance it plays, if any */
|
|
435
440
|
readonly figureDance?: Dancer;
|
|
441
|
+
/** Its cast's own gaits, if any */
|
|
442
|
+
readonly figureGaits?: Cast['gaits'];
|
|
436
443
|
}
|
|
437
444
|
/**
|
|
438
445
|
* A `custom` canvas target that draws a stick figure. Its props are the pose
|