@algorisys/tinyfly 0.89.0 → 0.91.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 +5 -5
- package/lib/addons/adapters.js +24 -19
- package/lib/addons/camera-C7bZOWMB.js +33 -0
- package/lib/addons/characters.js +1929 -1622
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +4882 -4484
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +16 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +216 -203
- package/lib/engine/tinyfly-engine.js +849 -783
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +39 -3
- package/lib/player/tinyfly-player.es.js +183 -170
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/camera.d.ts +46 -0
- package/lib/types/adapters/canvas/index.d.ts +1 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/characters/acting/index.d.ts +2 -0
- package/lib/types/characters/acting/lip-sync.d.ts +115 -0
- package/lib/types/characters/acting/script.d.ts +94 -0
- package/lib/types/characters/gaits.d.ts +141 -0
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/stick-figure.d.ts +15 -0
- package/lib/types/engine/authoring/camera-shots.d.ts +73 -0
- package/lib/types/engine/authoring/index.d.ts +1 -0
- package/lib/types/engine/core/timeline.d.ts +3 -0
- package/lib/types/engine/types.d.ts +6 -0
- package/lib/types/headless/video-scene.d.ts +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ A lightweight, API-driven animation engine and visual editor for creating high-p
|
|
|
61
61
|
- **The drawing hand** - `drawnPathTarget()` draws a sketched stroke on from a `draw` track while a cartoon hand holds the pencil at its end in a writing grip; the same hand can hold the eraser. `handAt()` gives one hand for a whole scene: it follows each stroke, lifts and glides to the next, and enters and leaves the page
|
|
62
62
|
- **Erasing** - An eraser rubs out part of a target (`erasable()`, animated by an `erase` track) or of anything drawn in code (`withErased()`); clip-based, so it works in the browser and headless alike
|
|
63
63
|
- **Cartoon hands** - A hand rig in 3D, drawn flat: thumb and fingers posed by numbers (`index.curl`, `thumb.across`, `spread`, `turn`), ready-made shapes (fist, point, thumbs-up, peace, OK, pinch, wave, pencil grip…), left and right, four or five fingers, in every look; the animator's hand and (opt-in) character gloves are built on it. See [docs/cartoon-hands.md](docs/cartoon-hands.md)
|
|
64
|
-
- **Cartoon acting** - `actTracks()` turns the same key poses into acted motion: wind-ups, overshoot that settles or wobbles, joints that overlap (hips lead, wrists drag), eyes that dart ahead and blink on head turns, moving holds and jump squash, in `full`, `snappy` or `limited` styles. Gags come as data (`gag('take')`, double take, wind-up, tremble). It also adds speed lines from earlier frames (`drawStickSmear()`), dust puffs, impact stars, and drawing on twos for video (`drawingRate`). Output is plain keyframes. See [docs/acting.md](docs/acting.md)
|
|
64
|
+
- **Cartoon acting** - `actTracks()` turns the same key poses into acted motion: wind-ups, overshoot that settles or wobbles, joints that overlap (hips lead, wrists drag), eyes that dart ahead and blink on head turns, moving holds and jump squash, in `full`, `snappy` or `limited` styles. Gags come as data (`gag('take')`, double take, wind-up, tremble). A line of action (`bend`) curves the spine, and gaits have personality (bouncy, double bounce, sneak, strut, tired, run). Lip-sync works from text, Latin or Devanagari. `scriptTracks()` compiles a story written as beats (`{ do: 'walk', to: 640 }`, `{ do: 'take' }`, `{ do: 'say', say: '…' }`) into all of it. `cameraTracks()` films it with push-ins, cuts, shakes and follows. The cartoon zip (`{ do: 'zip' }`) has the legs wheel in place before it is gone. In the editor, a Character's **Acting** section acts its keyed poses in a style and adds gags, walks in a gait and lip-synced lines, with drawing on twos as a timeline setting. It also adds speed lines from earlier frames (`drawStickSmear()`), dust puffs, impact stars, and drawing on twos for video (`drawingRate`). Output is plain keyframes. See [docs/acting.md](docs/acting.md)
|
|
65
65
|
- **Pencil story example** - `examples/pencil-story-hindi/index.html` tells a short Hindi story (प्यासा राहगीर, the thirsty traveller) Pencilmation-style with the browser bundle alone: the hand draws the scene and writes the narration, then rubs out the pot
|
|
66
66
|
- **Captions** - `toSRT()` / `toWebVTT()` from narration cues or from a timeline's markers
|
|
67
67
|
|
|
@@ -236,7 +236,7 @@ GSAP-shaped functions at the top level. Teaching embeds are included: add
|
|
|
236
236
|
itself.
|
|
237
237
|
|
|
238
238
|
```html
|
|
239
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
239
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.91.0/cdn/tinyfly.iife.js"></script>
|
|
240
240
|
<script>
|
|
241
241
|
tinyfly.to('.box', { x: 200, rotate: 90, duration: 1, ease: 'power2.out' })
|
|
242
242
|
|
|
@@ -272,7 +272,7 @@ A teaching figure needs no code at all:
|
|
|
272
272
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON with markers… }</script>
|
|
273
273
|
<figcaption>Appending to a full slice</figcaption>
|
|
274
274
|
</figure>
|
|
275
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
275
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.91.0/cdn/tinyfly.iife.js" data-tinyfly-auto></script>
|
|
276
276
|
```
|
|
277
277
|
|
|
278
278
|
See [Teaching Animations](docs/teaching.md).
|
|
@@ -371,7 +371,7 @@ Without a build step, the player bundle puts the same functions on a `tinyfly` g
|
|
|
371
371
|
<div data-tinyfly="box" style="width: 60px; height: 60px; background: #4a9eff;"></div>
|
|
372
372
|
</div>
|
|
373
373
|
|
|
374
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
374
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.91.0/cdn/tinyfly-player.iife.js"></script>
|
|
375
375
|
<script>
|
|
376
376
|
tinyfly.play('#animation', './animation.json', { loop: -1 })
|
|
377
377
|
</script>
|
|
@@ -480,7 +480,7 @@ Or skip the code entirely with declarative embeds (see [Teaching Animations](doc
|
|
|
480
480
|
<svg viewBox="0 0 720 200">…</svg>
|
|
481
481
|
<script type="application/json" data-tinyfly-timeline>{ …timeline JSON… }</script>
|
|
482
482
|
</figure>
|
|
483
|
-
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.
|
|
483
|
+
<script src="https://cdn.jsdelivr.net/gh/algorisys-oss/tinyfly@v0.91.0/cdn/tinyfly-embed.iife.js" data-tinyfly-auto></script>
|
|
484
484
|
```
|
|
485
485
|
|
|
486
486
|
### Audio / Video Sync
|
package/lib/addons/adapters.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { h as U, e as _, i as O, a as W, b as N, p as H, t as V, g as z, c as B, q, F as j, s as Z, d as J } from "./dom-adapter-Cphr2HZn.js";
|
|
2
|
-
import { D as
|
|
2
|
+
import { D as Xe } from "./dom-adapter-Cphr2HZn.js";
|
|
3
3
|
import { createTrack as Q, parsePath as L, ribbon as K, ribbonHeadCap as ee, mat4 as b } from "@algorisys/tinyfly";
|
|
4
4
|
import { p as te, s as ie } from "./sketch-CYPUbk3Q.js";
|
|
5
|
-
import { c as
|
|
5
|
+
import { c as $e, a as Ye, b as _e } from "./sketch-CYPUbk3Q.js";
|
|
6
|
+
import { I as Be, a as Le, c as Fe, b as De } from "./camera-C7bZOWMB.js";
|
|
6
7
|
function oe(n) {
|
|
7
8
|
const e = /* @__PURE__ */ new Map();
|
|
8
9
|
for (const { name: t, element: i } of n)
|
|
@@ -47,7 +48,7 @@ function F(n) {
|
|
|
47
48
|
const t = e.getBoundingClientRect();
|
|
48
49
|
return { left: t.left, top: t.top, width: t.width, height: t.height };
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function D(n, e, t = {}) {
|
|
51
52
|
const i = t.highlight ?? "#ffffff", o = t.halfWidth ?? 0.12, s = -0.2 + n * 1.4, a = [{ offset: 0, color: e }], r = [
|
|
52
53
|
{ offset: s - o, color: e },
|
|
53
54
|
{ offset: s, color: i },
|
|
@@ -459,7 +460,7 @@ class R {
|
|
|
459
460
|
if (e.font = `${s} ${i}px ${o}`, e.textAlign = t.textAlign ?? "left", e.textBaseline = t.textBaseline ?? "top", t.fillStyle) {
|
|
460
461
|
if (t.shine !== void 0 && typeof t.fillStyle == "string") {
|
|
461
462
|
const a = e.measureText(t.text).width, r = t.textAlign ?? "left", c = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, l = e.createLinearGradient(c, t.y, c + a, t.y);
|
|
462
|
-
for (const h of
|
|
463
|
+
for (const h of D(t.shine, t.fillStyle))
|
|
463
464
|
l.addColorStop(h.offset, h.color);
|
|
464
465
|
e.fillStyle = l;
|
|
465
466
|
}
|
|
@@ -644,7 +645,7 @@ function E(n, e, t, i, o) {
|
|
|
644
645
|
}
|
|
645
646
|
return s;
|
|
646
647
|
}
|
|
647
|
-
function
|
|
648
|
+
function C(n, e, t, i) {
|
|
648
649
|
const o = Math.max(1, Math.round(i / Math.sqrt(3)));
|
|
649
650
|
let s = n;
|
|
650
651
|
for (let a = 0; a < 3; a++)
|
|
@@ -657,7 +658,7 @@ function xe(n, e = {}) {
|
|
|
657
658
|
const s = Math.max(1, Math.round(e.downsample ?? 4)), a = Math.max(1, Math.ceil(i / s)), r = Math.max(1, Math.ceil(o / s)), c = g(n, a, r), l = c?.getContext("2d");
|
|
658
659
|
if (!c || !l) return;
|
|
659
660
|
l.imageSmoothingEnabled = !0, l.drawImage(n.canvas, 0, 0, a, r);
|
|
660
|
-
const h = re(l.getImageData(0, 0, a, r).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, o) * 0.02) / s, m =
|
|
661
|
+
const h = re(l.getImageData(0, 0, a, r).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, o) * 0.02) / s, m = C(h, a, r, f), u = C(h, a, r, f * 3), p = e.halo ?? 0.6, d = l.createImageData(a, r);
|
|
661
662
|
for (let y = 0; y < a * r; y++) {
|
|
662
663
|
for (let w = 0; w < 3; w++) d.data[y * 4 + w] = Math.round(Math.min(1, m[y * 3 + w] + u[y * 3 + w] * p) * 255);
|
|
663
664
|
d.data[y * 4 + 3] = 255;
|
|
@@ -742,7 +743,7 @@ const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
|
|
|
742
743
|
"height",
|
|
743
744
|
"viewBox",
|
|
744
745
|
"preserveAspectRatio"
|
|
745
|
-
]),
|
|
746
|
+
]), X = {
|
|
746
747
|
strokeWidth: "stroke-width",
|
|
747
748
|
strokeLinecap: "stroke-linecap",
|
|
748
749
|
strokeLinejoin: "stroke-linejoin",
|
|
@@ -872,7 +873,7 @@ class Ae {
|
|
|
872
873
|
r || (r = o.createElementNS(S, "defs"), i.insertBefore(r, i.firstChild));
|
|
873
874
|
let c = s.dataset.shineGrad, l = c ? r.querySelector(`#${c}`) : null;
|
|
874
875
|
for (l || (c = `tinyfly-shine-${Math.random().toString(36).slice(2, 9)}`, s.dataset.shineGrad = c, l = o.createElementNS(S, "linearGradient"), l.setAttribute("id", c), r.appendChild(l)); l.firstChild; ) l.removeChild(l.firstChild);
|
|
875
|
-
for (const h of
|
|
876
|
+
for (const h of D(t, a)) {
|
|
876
877
|
const f = o.createElementNS(S, "stop");
|
|
877
878
|
f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), l.appendChild(f);
|
|
878
879
|
}
|
|
@@ -880,7 +881,7 @@ class Ae {
|
|
|
880
881
|
}
|
|
881
882
|
applyAttribute(e, t, i) {
|
|
882
883
|
let o = t;
|
|
883
|
-
|
|
884
|
+
X[t] ? o = X[t] : he.has(t) && (o = t);
|
|
884
885
|
const s = Array.isArray(i) ? i.join(" ") : String(i);
|
|
885
886
|
e.setAttribute(o, s);
|
|
886
887
|
}
|
|
@@ -946,7 +947,7 @@ class ge {
|
|
|
946
947
|
texture: e.getUniformLocation(this.program, "u_texture"),
|
|
947
948
|
useTexture: e.getUniformLocation(this.program, "u_useTexture"),
|
|
948
949
|
opacity: e.getUniformLocation(this.program, "u_opacity")
|
|
949
|
-
}, this.positionBuffer =
|
|
950
|
+
}, this.positionBuffer = $(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), this.texCoordBuffer = $(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]);
|
|
950
951
|
}
|
|
951
952
|
registerTarget(e, t) {
|
|
952
953
|
this.targets.set(e, t), this.basePositions.set(e, { x: t.x, y: t.y });
|
|
@@ -1002,7 +1003,7 @@ class ge {
|
|
|
1002
1003
|
}
|
|
1003
1004
|
drawTarget(e, t, i, o) {
|
|
1004
1005
|
const s = this.gl;
|
|
1005
|
-
if (t.backfaceVisibility === "hidden" && O(
|
|
1006
|
+
if (t.backfaceVisibility === "hidden" && O(G(t))) return;
|
|
1006
1007
|
const a = ye(t, i, o);
|
|
1007
1008
|
if (s.uniformMatrix4fv(this.locations.matrix, !1, a), s.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
|
|
1008
1009
|
s.bindTexture(s.TEXTURE_2D, this.textureFor(e, t.texture)), s.uniform1i(this.locations.useTexture, 1), s.uniform1i(this.locations.texture, 0);
|
|
@@ -1038,7 +1039,7 @@ function ke(n, e, t) {
|
|
|
1038
1039
|
1
|
|
1039
1040
|
]);
|
|
1040
1041
|
}
|
|
1041
|
-
function
|
|
1042
|
+
function G(n) {
|
|
1042
1043
|
const e = (n.originX ?? 50) / 100, t = (n.originY ?? 50) / 100, i = { x: n.x, y: n.y }, o = b.multiply(
|
|
1043
1044
|
b.translation([n.x, n.y, 0]),
|
|
1044
1045
|
b.multiply(b.scaling([n.width, n.height, 1]), b.translation([-e, -t, 0]))
|
|
@@ -1047,7 +1048,7 @@ function D(n) {
|
|
|
1047
1048
|
}
|
|
1048
1049
|
function ye(n, e, t) {
|
|
1049
1050
|
const i = [2 / e, 0, 0, 0, 0, -2 / t, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1];
|
|
1050
|
-
return new Float32Array(b.multiply(i,
|
|
1051
|
+
return new Float32Array(b.multiply(i, G(n)));
|
|
1051
1052
|
}
|
|
1052
1053
|
function we(n) {
|
|
1053
1054
|
const e = n.trim().replace("#", "");
|
|
@@ -1064,18 +1065,18 @@ function we(n) {
|
|
|
1064
1065
|
function be(n, e, t) {
|
|
1065
1066
|
const i = n.createProgram();
|
|
1066
1067
|
if (!i) throw new Error("WebGLAdapter: could not create a program");
|
|
1067
|
-
if (n.attachShader(i,
|
|
1068
|
+
if (n.attachShader(i, I(n, n.VERTEX_SHADER, e)), n.attachShader(i, I(n, n.FRAGMENT_SHADER, t)), n.linkProgram(i), !n.getProgramParameter(i, n.LINK_STATUS))
|
|
1068
1069
|
throw new Error(`WebGLAdapter: program link failed — ${n.getProgramInfoLog(i)}`);
|
|
1069
1070
|
return i;
|
|
1070
1071
|
}
|
|
1071
|
-
function
|
|
1072
|
+
function I(n, e, t) {
|
|
1072
1073
|
const i = n.createShader(e);
|
|
1073
1074
|
if (!i) throw new Error("WebGLAdapter: could not create a shader");
|
|
1074
1075
|
if (n.shaderSource(i, t), n.compileShader(i), !n.getShaderParameter(i, n.COMPILE_STATUS))
|
|
1075
1076
|
throw new Error(`WebGLAdapter: shader compile failed — ${n.getShaderInfoLog(i)}`);
|
|
1076
1077
|
return i;
|
|
1077
1078
|
}
|
|
1078
|
-
function
|
|
1079
|
+
function $(n, e) {
|
|
1079
1080
|
const t = n.createBuffer();
|
|
1080
1081
|
if (!t) throw new Error("WebGLAdapter: could not create a buffer");
|
|
1081
1082
|
return n.bindBuffer(n.ARRAY_BUFFER, t), n.bufferData(n.ARRAY_BUFFER, new Float32Array(e), n.STATIC_DRAW), t;
|
|
@@ -1085,14 +1086,18 @@ function Y(n, e, t) {
|
|
|
1085
1086
|
}
|
|
1086
1087
|
export {
|
|
1087
1088
|
R as CanvasAdapter,
|
|
1088
|
-
|
|
1089
|
+
Xe as DOMAdapter,
|
|
1090
|
+
Be as IDENTITY_CAMERA,
|
|
1089
1091
|
Ae as SVGAdapter,
|
|
1090
1092
|
ge as WebGLAdapter,
|
|
1091
1093
|
xe as applyBloom,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
+
Le as applyCamera,
|
|
1095
|
+
$e as boilFrame,
|
|
1096
|
+
C as boxBlur,
|
|
1094
1097
|
re as brightPass,
|
|
1095
1098
|
se as buildFlipTracks,
|
|
1099
|
+
Fe as cameraFromValues,
|
|
1100
|
+
De as cameraPoint,
|
|
1096
1101
|
g as canvasLike,
|
|
1097
1102
|
M as drawOutline,
|
|
1098
1103
|
Re as drawTrail,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const r = { x: 0, y: 0, scale: 1, rotate: 0, shakeX: 0, shakeY: 0, shakeRotate: 0 };
|
|
2
|
+
function k(t) {
|
|
3
|
+
const a = (s) => {
|
|
4
|
+
const h = t?.get(s);
|
|
5
|
+
return typeof h == "number" ? h : r[s];
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
x: a("x"),
|
|
9
|
+
y: a("y"),
|
|
10
|
+
scale: a("scale"),
|
|
11
|
+
rotate: a("rotate"),
|
|
12
|
+
shakeX: a("shakeX"),
|
|
13
|
+
shakeY: a("shakeY"),
|
|
14
|
+
shakeRotate: a("shakeRotate")
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function l(t, a, s) {
|
|
18
|
+
const h = s.width / 2, e = s.height / 2, c = 1 + 2 * Math.max(Math.abs(a.shakeX), Math.abs(a.shakeY)) / Math.max(1, Math.min(s.width, s.height));
|
|
19
|
+
t.translate(h + a.x + a.shakeX, e + a.y + a.shakeY), t.rotate((a.rotate + a.shakeRotate) * Math.PI / 180), t.scale(a.scale * c, a.scale * c), t.translate(-h, -e);
|
|
20
|
+
}
|
|
21
|
+
function M(t, a, s) {
|
|
22
|
+
const h = a.width / 2, e = a.height / 2, o = (t.rotate + t.shakeRotate) * Math.PI / 180, c = (s.x - h) * t.scale, n = (s.y - e) * t.scale;
|
|
23
|
+
return {
|
|
24
|
+
x: h + t.x + t.shakeX + c * Math.cos(o) - n * Math.sin(o),
|
|
25
|
+
y: e + t.y + t.shakeY + c * Math.sin(o) + n * Math.cos(o)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
r as I,
|
|
30
|
+
l as a,
|
|
31
|
+
M as b,
|
|
32
|
+
k as c
|
|
33
|
+
};
|