@algorisys/tinyfly 0.101.0 → 0.103.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 +17 -6
- package/bin/tinyfly.mjs +9 -3
- package/docs/DEPLOYMENT.md +2 -0
- package/docs/api-reference.md +61 -0
- package/docs/dance.md +150 -1
- package/docs/editor-guide.md +11 -4
- package/docs/examples.md +22 -1
- package/docs/getting-started.md +1 -1
- package/docs/gsap-compat.md +1 -1
- package/docs/llm-guide.md +38 -3
- package/docs/maps.md +2 -2
- package/docs/scene-3d.md +138 -6
- package/docs/teaching.md +1 -1
- package/docs/video-rendering.md +44 -1
- package/lib/addons/adapters.js +168 -123
- package/lib/addons/characters.js +5802 -5506
- package/lib/addons/scene-3d-webgl.js +30 -30
- package/lib/addons/scene-3d.js +650 -341
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +2 -2
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +14 -14
- package/lib/browser/tinyfly.js +5798 -5467
- package/lib/browser/tinyfly.umd.js +14 -14
- package/lib/engine/tinyfly-engine.js +1207 -1172
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +150 -6
- package/lib/types/adapters/canvas/framing.d.ts +27 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/characters/capabilities.d.ts +1 -0
- package/lib/types/characters/character-script-3d.d.ts +34 -4
- package/lib/types/characters/dance-circle.d.ts +59 -0
- package/lib/types/characters/dance-contact.d.ts +52 -0
- package/lib/types/characters/human-dance.d.ts +86 -0
- package/lib/types/characters/index.d.ts +5 -1
- package/lib/types/characters/rig/reach.d.ts +6 -3
- package/lib/types/characters/staging-3d.d.ts +56 -0
- package/lib/types/engine/authoring/framing.d.ts +48 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/headless/audio-mix.d.ts +40 -0
- package/lib/types/headless/ffmpeg-args.d.ts +2 -0
- package/lib/types/headless/frame-renderer.d.ts +7 -1
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/node-audio.d.ts +19 -0
- package/lib/types/headless/node-video.d.ts +2 -0
- package/lib/types/headless/video-scene.d.ts +12 -0
- package/lib/types/scene-3d/index.d.ts +3 -0
- package/lib/types/scene-3d/lighting.d.ts +58 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +5 -1
- package/lib/types/scene-3d/scene-3d-adapter.d.ts +2 -0
- package/lib/types/scene-3d/scene-types.d.ts +14 -2
- package/lib/types/scene-3d/shots.d.ts +162 -0
- package/lib/types/scene-3d/software-renderer.d.ts +40 -0
- package/llms-full.txt +474 -23
- package/llms.txt +29 -29
- package/package.json +1 -1
- package/skills/tinyfly/SKILL.md +32 -1
- package/lib/types/characters/polyline.d.ts +0 -12
- package/lib/types/characters/sketch.d.ts +0 -54
- package/lib/types/compat/gsap/playhead-crossings.d.ts +0 -47
package/llms.txt
CHANGED
|
@@ -13,47 +13,47 @@ Key facts:
|
|
|
13
13
|
- For language models: read the capability catalog first (`npx @algorisys/tinyfly capabilities`, or the end of llms-full.txt). It is generated from the library, so every name in it (poses, expressions, gags, gaits, beat actions, canvas properties, code-panel edits) is accepted, and names not in it are rejected with the name probably meant. Check beat scripts with `npx @algorisys/tinyfly check beats.json`, tracks with `checkTracks(tracks, targets)`, and ask any target what it animates with `describeTarget(target)`. The npm package ships `docs/`, `llms.txt`, `llms-full.txt` and an agent skill (`skills/tinyfly/SKILL.md`); `docs/llm-guide.md` describes the workflow.
|
|
14
14
|
- Source: https://github.com/algorisys-oss/tinyfly. License: MIT.
|
|
15
15
|
|
|
16
|
-
All documentation and the interactive course in a single file: [llms-full.txt](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
16
|
+
All documentation and the interactive course in a single file: [llms-full.txt](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/llms-full.txt)
|
|
17
17
|
|
|
18
18
|
## Start here
|
|
19
19
|
|
|
20
|
-
- [Getting Started](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
21
|
-
- [GSAP Compatibility](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
22
|
-
- [Code Examples](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
23
|
-
- [Building Animations with an LLM](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
20
|
+
- [Getting Started](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/getting-started.md): What tinyfly is, making a first animation in the editor, and using it from code, a script tag or the CDN.
|
|
21
|
+
- [GSAP Compatibility](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/gsap-compat.md): The GSAP-style API (`live.to`, `tf.timeline`): supported vars, motion paths, morphSVG, text, inertia, Draggable, Flip, and where it differs from GSAP.
|
|
22
|
+
- [Code Examples](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/examples.md): Recipes with the engine API: fades, loops, colour and bezier easing, loading JSON, canvas and SVG rendering, multi-scene sequences, motion paths and script-tag embeds; a festive garba/dandiya scene with partner contacts, circle travel and spins, also rendered to video.
|
|
23
|
+
- [Building Animations with an LLM](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/llm-guide.md): For assistants and the people setting them up: read the capability catalog (`tinyfly capabilities`), ask targets what they animate (`describeTarget`), check beats and tracks with did-you-mean errors (`tinyfly check`, `checkTracks`), render stills to look at, and the agent skill shipped in the package.
|
|
24
24
|
|
|
25
25
|
## Reference
|
|
26
26
|
|
|
27
|
-
- [API Reference](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
28
|
-
- [File Format](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
27
|
+
- [API Reference](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/api-reference.md): Every public engine, player and adapter API: Timeline, tracks, keyframes, easing, drivers, serialization and exports.
|
|
28
|
+
- [File Format](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/file-format.md): The JSON animation format: timelines, every track kind, keyframes, easing and the project file — for generating or consuming animations.
|
|
29
29
|
|
|
30
30
|
## Editor features
|
|
31
31
|
|
|
32
|
-
- [Editor Guide](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
33
|
-
- [Shape Morphing](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
34
|
-
- [Pen Tool](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
35
|
-
- [Polygons & Stars](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
36
|
-
- [Grid & Snapping](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
37
|
-
- [Onion Skinning](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
38
|
-
- [Sprite-sheet Export](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
32
|
+
- [Editor Guide](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/editor-guide.md): Every panel and feature of the visual editor, from elements and keyframes to text and inertia tracks, preview and export.
|
|
33
|
+
- [Shape Morphing](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/shape-morph.md): Tweening one path into another, including shapes with different point counts and several subpaths.
|
|
34
|
+
- [Pen Tool](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/pen-tool.md): Drawing custom paths point by point with straight segments and bezier curves.
|
|
35
|
+
- [Polygons & Stars](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/polygon-star.md): Parametric polygon and star shapes that stay editable while animating like any path.
|
|
36
|
+
- [Grid & Snapping](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/grid-and-snapping.md): The grid overlay, snapping to grid, elements and artboard centre, and alignment guides.
|
|
37
|
+
- [Onion Skinning](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/onion-skinning.md): Ghost frames before and after the playhead for judging arcs and easing.
|
|
38
|
+
- [Sprite-sheet Export](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/sprite-sheet-export.md): Exporting frames as a PNG grid plus JSON metadata for game engines and canvas players.
|
|
39
39
|
|
|
40
40
|
## Guides
|
|
41
41
|
|
|
42
|
-
- [Scroll Animation](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
43
|
-
- [Props: Everyday Objects with Behaviours](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
44
|
-
- [Teaching Animations](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
45
|
-
- [Rendering Video from Code](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
46
|
-
- [Animated Maps](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
47
|
-
- [Cartoon Hands](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
48
|
-
- [Character Appearance](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
49
|
-
- [Cartoon Acting](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
50
|
-
- [Dance and Flips](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
51
|
-
- [3D Scenes](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
52
|
-
- [3D Transforms and Rotations](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
53
|
-
- [Extending tinyfly](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
54
|
-
- [Deployment](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
42
|
+
- [Scroll Animation](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/scroll-animation.md): Scroll-driven and play-when-visible animation with ScrollDriver and VisibilityDriver.
|
|
43
|
+
- [Props: Everyday Objects with Behaviours](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/props.md): Cars, trucks, buses, tractors, carts, train carriages, bikes, motorbikes, trees, houses, a helicopter and a plane: 3D rigs drawn with the characters’ pens (clean, pencil) that turn toward the camera, with beats acted through the 12 principles (anticipation, squash and stretch, follow-through, an exaggeration dial), wheels that roll exactly, effects, and figures riding them.
|
|
44
|
+
- [Teaching Animations](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/teaching.md): Step-through explanatory figures: markers, captions in several languages, the teaching player, step controls, one-script declarative embeds, tinyfly/teach diagram primitives, and validate / render for build pipelines.
|
|
45
|
+
- [Rendering Video from Code](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/video-rendering.md): Rendering a scene to MP4 without a browser: `tinyfly video`, custom canvas targets drawn by code, timing from narration and recorded voice-over, the stick-figure character, SRT/WebVTT captions, stills, porting Cairo scripts, and a benchmark against pycairo.
|
|
46
|
+
- [Animated Maps](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/maps.md): Maps that animate: a camera that flies in to a city, pins that drop in, routes that draw themselves while a marker travels them, on OpenStreetMap tiles or an offline world outline (also in pencil), in the browser and in headless video.
|
|
47
|
+
- [Cartoon Hands](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/cartoon-hands.md): A hand you can pose: a palm and five fingers in 3D, posed by numbers (curls, thumb, spread, wrist turn), ready-made shapes from a fist to a pencil grip, left and right, four or five fingers, in clean, pencil and silhouette looks; the animator's hand and character gloves are built on it.
|
|
48
|
+
- [Character Appearance](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/character-appearance.md): Hair (34 styles), facial hair (20), glasses, hats and ears for the v2 character as plain data on the head, so they turn with it through all eight views; builds (child, tall, short…), a recurring cast (castMember), expressions with blush, tears and sweat, everyday poses, held items (mug, phone, bags, umbrella, parcel) and two characters’ hands meeting (meetHands: handshake, high five, hand-over).
|
|
49
|
+
- [Cartoon Acting](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/acting.md): actTracks(): the same key poses, acted: anticipation, overshoot and settle, overlapping joints, eyes that lead and blink, moving holds and jump squash, in full, snappy or limited styles; gags as data (take, double take, wind-up); a line of action (bend); gaits with personality; lip-sync from text (Latin and Devanagari); beat scripts compiled to acted tracks; your own actions (defineAction), gaits (defineGait) and personas (persona()); acting on code (codePanel lines and words as anchors: leap onto a line, point at it, swipe it away wiped, knocked off or blurred; grab, throw, kick, carry and drop words, push them along their line, write new text in by hand; ride a line as gaps close); camera shots (push in, cut, shake, follow); the cartoon zip; speed lines, dust puffs and impact stars; drawing on twos (a timeline setting); acting, gags, walks and lines in the editor.
|
|
50
|
+
- [Dance and Flips](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/dance.md): The stick figure dances disco, hip hop, breaking, jazz, K-pop, Bollywood, Bhangra, Bharatanatyam (with mudras), the Charleston, tap and popping, and does flips, leaps and splits; native v2 garba (two/three clap) and dandiya add body-local routines, circle formations, world foot plants, paired stick-tip contacts and signed spins; JSON bakes, timing, contact limits and editor menus.
|
|
51
|
+
- [3D Scenes](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/scene-3d.md): @algorisys/tinyfly/scene-3d: cameras, lights and meshes as JSON, in metres, animated by tracks at <scene>/<object> (cuts with activeCamera), drawn on a 2D canvas with flat, smooth or toon shading, ink outlines and fog, in browsers, Workers and Node (MP4 with tinyfly video); v2 characters in pen or solid looks, scripted native dances, timed signed spins and circle formations with foot contacts.
|
|
52
|
+
- [3D Transforms and Rotations](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/3d-rotations.md): CSS-style 3D for flat elements in every renderer (rotateX, rotateY, z, perspective, backface visibility; true perspective on Canvas and WebGL, matching CSS within a pixel), one documented transform order, the editor's 3D fields; smooth quaternion rotations with interpolation: "slerp"; the vec3, quat and mat4 helpers; format version 2.
|
|
53
|
+
- [Extending tinyfly](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/extending.md): Writing a render adapter, animating any object with live and the ticker, custom and parametric eases, stagger offsets, adding a track kind, and contributing gallery examples.
|
|
54
|
+
- [Deployment](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/docs/DEPLOYMENT.md): Building and hosting the editor, and serving the player bundles.
|
|
55
55
|
|
|
56
56
|
## Optional
|
|
57
57
|
|
|
58
|
-
- [README](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
59
|
-
- [Release notes](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.
|
|
58
|
+
- [README](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/README.md): Feature overview, project layout and development setup.
|
|
59
|
+
- [Release notes](https://raw.githubusercontent.com/algorisys-oss/tinyfly/v0.103.0/release-notes/README.md): What changed in each version.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algorisys/tinyfly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.103.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Lightweight, API-driven animation engine and editor. The engine is framework-agnostic and runs in browsers, Web Workers, and Node.",
|
|
6
6
|
"license": "MIT",
|
package/skills/tinyfly/SKILL.md
CHANGED
|
@@ -56,6 +56,34 @@ names.
|
|
|
56
56
|
surfaces). Places name items by id: declare them first (`items`, `data`).
|
|
57
57
|
- A figure that starts on the right walking left needs `facing: -1` in the
|
|
58
58
|
script options.
|
|
59
|
+
- For native garba or dandiya, use `humanDanceFrame(style, beat, base)` or
|
|
60
|
+
`humanDanceTracks(target, { style, bpm, beats })`; heading stays independent
|
|
61
|
+
of local limb motion. `danceCircleAt` / `danceCircleTracks` coordinate a
|
|
62
|
+
circle's travel, facing, spins and foot plants. Sparse custom keys use base,
|
|
63
|
+
human/hand rest or zero defaults across the loop. Contacts always alternate
|
|
64
|
+
left/right each integer beat, starting left, with stance through 0.6;
|
|
65
|
+
custom keys do not change this. Use `plantFeet: false` and your own
|
|
66
|
+
`plantDanceFoot` contacts for different footwork. Circle bakes require
|
|
67
|
+
`beats`, default to 120 BPM and reject `count` different from target count.
|
|
68
|
+
Render with the same base pose and build: unchanged pose fields are omitted.
|
|
69
|
+
Close whole orbits/routines with whole extra body revolutions too.
|
|
70
|
+
Zero-roll circle bakes
|
|
71
|
+
use `rotateY`; nonzero `pose.roll` keeps heading in pose `turn` (quarter-turns),
|
|
72
|
+
includes roll, and sets `rotateY: 0`, preserving yaw before roll and grounding.
|
|
73
|
+
Supply roll when baking and apply all tracks without adding heading twice.
|
|
74
|
+
Apply both pose and position
|
|
75
|
+
from `plantDanceFoot`; ankle/toe IK preserves authored `leg.*.rotate` hip turn-out.
|
|
76
|
+
`meetDandiya` gives paired strike poses and world-space
|
|
77
|
+
grip/tip segments, with unreachable contacts reported. Construct contact
|
|
78
|
+
characters from the rendered dancers' options to match proportions,
|
|
79
|
+
line width and hands. Scripted dance entry and hand pose transitions use
|
|
80
|
+
`HAND_REST` for missing hand fields, preserving relaxed hands through holds
|
|
81
|
+
and explicit zero values. In a 3D script use
|
|
82
|
+
`{ do: 'spin', turns: 2, for: 1500 }` for full revolutions: `face` takes the
|
|
83
|
+
shortest route, so facing 360° does not spin. A scripted dance stays in
|
|
84
|
+
place; `for` alone derives beats at the BPM, while `beats` with `for` fits
|
|
85
|
+
those beats into the duration. Stick drawing and paired IK are separate
|
|
86
|
+
from native frames and circle bakes. See `docs/dance.md`.
|
|
59
87
|
- A figure changes a prop's state through `propSurface(propTarget(…))`
|
|
60
88
|
(`switch` / `set` on `control:door`, `control:lights`; aim at `anchor:NAME`
|
|
61
89
|
or `part:ID`). Walk figures on a prop's front line (a house's
|
|
@@ -72,7 +100,10 @@ names.
|
|
|
72
100
|
`style: 'stick'` draws props as line art. In a 3D scene, place props with
|
|
73
101
|
`rotation: [0, deg, 0]` (`rotateY` is a track) and script them with
|
|
74
102
|
`propScript3D` (`to: [x, z]` metres), not `propScript` (screen px);
|
|
75
|
-
characters there with `characterScript3D`, riders with
|
|
103
|
+
characters there with `characterScript3D` (`say`, `look` too), riders with
|
|
104
|
+
`propRide3D`. A film: `shotTracks` + `transitionAt` / `drawTransition`,
|
|
105
|
+
`cameraMoveTracks`, `lightingPreset`, `ground`, `shadow: true`, `renderMix`;
|
|
106
|
+
`depthBuffer: true` when shapes cut through each other.
|
|
76
107
|
- Give a v2 `character()` its look as options, not drawing code: `build`,
|
|
77
108
|
`hair` (`'bob'` or `{ style, color, length }`), `facialHair`, `glasses`,
|
|
78
109
|
`hat`, `ears: true`, `face: { teeth, tongue }`, `feet: 'flat' | 'pointed' |
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Point } from './sketch';
|
|
2
|
-
/**
|
|
3
|
-
* Polyline helpers measured by length, so `progress` 0..1 means "this much of
|
|
4
|
-
* the way along", whatever the spacing of the points. Drawing on, erasing and
|
|
5
|
-
* the hand that follows a stroke all use them.
|
|
6
|
-
*/
|
|
7
|
-
/** Total length of a polyline. */
|
|
8
|
-
export declare function pathLength(points: Point[]): number;
|
|
9
|
-
/** The start of a polyline, up to `progress` (0..1) of its length. */
|
|
10
|
-
export declare function partialPath(points: Point[], progress: number): Point[];
|
|
11
|
-
/** Where along a polyline `progress` (0..1) of its length is. */
|
|
12
|
-
export declare function pointAlong(points: Point[], progress: number): Point;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hand-drawn strokes for canvas drawing: each line is drawn a few times, a
|
|
3
|
-
* little off and a little bowed, the way a pencil line is. "Line boil" redraws
|
|
4
|
-
* the wobble a few times a second, so a still drawing looks alive.
|
|
5
|
-
*
|
|
6
|
-
* The wobble comes from a seeded generator keyed to the seed, the boil frame
|
|
7
|
-
* and the stroke's place in the drawing order, never from Math.random, so the
|
|
8
|
-
* same time always draws the same lines: a frame rendered twice, in a browser
|
|
9
|
-
* or headless, is identical.
|
|
10
|
-
*
|
|
11
|
-
* Every stroke takes a `progress` (0..1) to draw it on, as a pencil would: the
|
|
12
|
-
* part drawn so far lies exactly on the finished stroke, so it grows without
|
|
13
|
-
* jumping.
|
|
14
|
-
*/
|
|
15
|
-
export interface SketchStyle {
|
|
16
|
-
/** Largest wobble, px (default 2) */
|
|
17
|
-
roughness?: number;
|
|
18
|
-
/** Strokes per line: 1 is clean, 2 or 3 look sketched (default 2) */
|
|
19
|
-
passes?: number;
|
|
20
|
-
/** Redraws per second; 0 holds the wobble still (default 8, about "on threes" at 24 fps) */
|
|
21
|
-
boil?: number;
|
|
22
|
-
/** Seed for the wobble, so two drawings with the same style do not boil in step (default 1) */
|
|
23
|
-
seed?: number;
|
|
24
|
-
}
|
|
25
|
-
export interface Point {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
}
|
|
29
|
-
/** Which redraw is showing at `time` ms. */
|
|
30
|
-
export declare function boilFrame(time: number, boil: number): number;
|
|
31
|
-
/**
|
|
32
|
-
* Strokes in the context's current stroke style and line width. Each stroke's
|
|
33
|
-
* wobble is seeded by its place in the drawing order, so draw them in the same
|
|
34
|
-
* order every frame; a stroke drawn on partway wobbles exactly as it will when
|
|
35
|
-
* it is finished, and does not disturb the strokes after it.
|
|
36
|
-
*/
|
|
37
|
-
export interface SketchPen {
|
|
38
|
-
/** A line through the points, each segment slightly bowed; `progress` draws it on (default 1) */
|
|
39
|
-
line(points: Point[], progress?: number): void;
|
|
40
|
-
/**
|
|
41
|
-
* A smooth curve through the points (a limb drawn as a curve). The wobble
|
|
42
|
-
* is spread along the whole curve rather than added at every point, so a
|
|
43
|
-
* finely sampled curve stays smooth instead of turning lumpy.
|
|
44
|
-
*/
|
|
45
|
-
curve(points: Point[], progress?: number): void;
|
|
46
|
-
/** A circle whose end overshoots its start, as a quick pencil circle does */
|
|
47
|
-
circle(cx: number, cy: number, r: number, progress?: number): void;
|
|
48
|
-
/** An ellipse drawn the same way as `circle` */
|
|
49
|
-
ellipse(cx: number, cy: number, rx: number, ry: number, progress?: number): void;
|
|
50
|
-
/** A small random offset, up to `scale` × roughness, for nudging details (a face) with the boil */
|
|
51
|
-
nudge(scale?: number): Point;
|
|
52
|
-
}
|
|
53
|
-
/** A pen whose wobble is fixed for the boil frame showing at `time` ms. */
|
|
54
|
-
export declare function sketchPen(ctx: CanvasRenderingContext2D, style: SketchStyle, time: number): SketchPen;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which points in time a playhead passed between two frames — the pure part of
|
|
3
|
-
* timeline callbacks (`call`, `addPause`, per-tween `onStart` / `onComplete`,
|
|
4
|
-
* `onRepeat`).
|
|
5
|
-
*
|
|
6
|
-
* A frame moves the playhead from one place to another, possibly across loop
|
|
7
|
-
* boundaries: a plain repeat wraps back to the start, a yoyo turns around. The
|
|
8
|
-
* movement is split into passes, and each pass reports the event times inside it
|
|
9
|
-
* in the order they were crossed:
|
|
10
|
-
*
|
|
11
|
-
* - forward, `(from, to]` — an event exactly where the playhead already was has
|
|
12
|
-
* fired before; a pass that starts a loop (or a first play) includes its start;
|
|
13
|
-
* - reverse, `[to, from)`.
|
|
14
|
-
*/
|
|
15
|
-
export type Direction = 'forward' | 'reverse';
|
|
16
|
-
export interface Playhead {
|
|
17
|
-
/** Milliseconds within the current loop */
|
|
18
|
-
time: number;
|
|
19
|
-
/** Loops completed */
|
|
20
|
-
iteration: number;
|
|
21
|
-
direction: Direction;
|
|
22
|
-
/** The playhead is at the very start of a pass, so an event at its position has not fired */
|
|
23
|
-
fresh?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export type Crossing = {
|
|
26
|
-
kind: 'event';
|
|
27
|
-
index: number;
|
|
28
|
-
direction: Direction;
|
|
29
|
-
} | {
|
|
30
|
-
kind: 'repeat';
|
|
31
|
-
};
|
|
32
|
-
export interface CrossingResult {
|
|
33
|
-
crossings: Crossing[];
|
|
34
|
-
/** Every stretch of time covered, in order, as [from, to] (to < from when reversing) */
|
|
35
|
-
passes: Array<[number, number]>;
|
|
36
|
-
}
|
|
37
|
-
export interface LoopShape {
|
|
38
|
-
duration: number;
|
|
39
|
-
/** Yoyo: every other loop plays backwards */
|
|
40
|
-
alternate: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* The frame ended waiting out a repeat delay at a boundary. A plain repeat has
|
|
43
|
-
* not wrapped yet, so the last pass (the new loop) has not started.
|
|
44
|
-
*/
|
|
45
|
-
holding?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare function playheadCrossings(times: readonly number[], from: Playhead, to: Playhead, shape: LoopShape): CrossingResult;
|