@algorisys/tinyfly 0.86.2 → 0.87.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 +6 -4
- package/bin/tinyfly.mjs +44 -6
- package/lib/addons/adapters.js +168 -120
- package/lib/addons/characters.js +2 -2
- package/lib/addons/maps.js +1 -1
- package/lib/addons/scene-3d-webgl.js +52 -49
- package/lib/addons/scene-3d.js +2 -2
- package/lib/addons/shading-o5T_v9DT.js +89 -0
- package/lib/addons/{sketch-CA8ZXhxI.js → sketch-CYPUbk3Q.js} +2 -2
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +4 -2
- package/lib/browser/tinyfly-scene-3d.iife.js +2 -2
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3161 -3102
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/headless/headless.js +162 -17
- package/lib/types/adapters/canvas/bloom.d.ts +33 -0
- package/lib/types/adapters/canvas/index.d.ts +2 -0
- package/lib/types/adapters/canvas/offscreen.d.ts +13 -0
- package/lib/types/browser/index.d.ts +2 -0
- package/lib/types/headless/index.d.ts +1 -0
- package/lib/types/headless/loop-check.d.ts +41 -0
- package/lib/types/headless/node-video.d.ts +8 -0
- package/lib/types/headless/video-scene.d.ts +7 -1
- package/lib/types/scene-3d/scene-types.d.ts +2 -1
- package/lib/types/scene-3d/webgl/gl-data.d.ts +1 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +1 -1
- package/package.json +1 -1
- package/lib/addons/shading-ByG9UXd0.js +0 -85
package/lib/addons/adapters.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { D as
|
|
3
|
-
import { createTrack as
|
|
4
|
-
import { p as
|
|
5
|
-
import {
|
|
6
|
-
function
|
|
1
|
+
import { h as D, e as C, i as I, a as U, b as W, p as N, t as H, g as V, c as O, q, F as z, s as j, d as Z } from "./dom-adapter-Cphr2HZn.js";
|
|
2
|
+
import { D as xe } from "./dom-adapter-Cphr2HZn.js";
|
|
3
|
+
import { createTrack as J, parsePath as B, mat4 as T } from "@algorisys/tinyfly";
|
|
4
|
+
import { p as K, s as Q } from "./sketch-CYPUbk3Q.js";
|
|
5
|
+
import { c as Ae, a as ke, b as Ee } from "./sketch-CYPUbk3Q.js";
|
|
6
|
+
function ee(r) {
|
|
7
7
|
const e = /* @__PURE__ */ new Map();
|
|
8
8
|
for (const { name: t, element: i } of r)
|
|
9
|
-
e.set(t,
|
|
9
|
+
e.set(t, g(i));
|
|
10
10
|
return { measurements: e };
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function te(r, e, t = {}) {
|
|
13
13
|
const i = t.duration ?? 600, s = t.easing ?? "ease-out", o = t.scale !== !1, a = t.idPrefix ?? "flip", n = [];
|
|
14
14
|
for (const { name: c, element: l } of e) {
|
|
15
15
|
const h = r.measurements.get(c);
|
|
16
16
|
if (!h) continue;
|
|
17
|
-
const f =
|
|
17
|
+
const f = g(l), p = h.left + h.width / 2 - (f.left + f.width / 2), u = h.top + h.height / 2 - (f.top + f.height / 2);
|
|
18
18
|
if ((p !== 0 || u !== 0) && n.push(
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
v(`${a}-${c}-x`, c, "x", p, 0, i, s),
|
|
20
|
+
v(`${a}-${c}-y`, c, "y", u, 0, i, s)
|
|
21
21
|
), o && f.width > 0 && f.height > 0) {
|
|
22
|
-
const d = h.width / f.width,
|
|
23
|
-
d !== 1 && n.push(
|
|
22
|
+
const d = h.width / f.width, m = h.height / f.height;
|
|
23
|
+
d !== 1 && n.push(v(`${a}-${c}-sx`, c, "scaleX", d, 1, i, s)), m !== 1 && n.push(v(`${a}-${c}-sy`, c, "scaleY", m, 1, i, s));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return n;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const i =
|
|
30
|
-
return e(),
|
|
28
|
+
function ye(r, e, t = {}) {
|
|
29
|
+
const i = ee(r);
|
|
30
|
+
return e(), te(i, r, t);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return
|
|
32
|
+
function v(r, e, t, i, s, o, a) {
|
|
33
|
+
return J({
|
|
34
34
|
id: r,
|
|
35
35
|
target: e,
|
|
36
36
|
property: t,
|
|
@@ -40,14 +40,14 @@ function T(r, e, t, i, s, o, a) {
|
|
|
40
40
|
]
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function g(r) {
|
|
44
44
|
const e = r;
|
|
45
45
|
if (typeof e.getBoundingClientRect != "function")
|
|
46
46
|
return { left: 0, top: 0, width: 0, height: 0 };
|
|
47
47
|
const t = e.getBoundingClientRect();
|
|
48
48
|
return { left: t.left, top: t.top, width: t.width, height: t.height };
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function L(r, e, t = {}) {
|
|
51
51
|
const i = t.highlight ?? "#ffffff", s = t.halfWidth ?? 0.12, o = -0.2 + r * 1.4, a = [{ offset: 0, color: e }], n = [
|
|
52
52
|
{ offset: o - s, color: e },
|
|
53
53
|
{ offset: o, color: i },
|
|
@@ -57,19 +57,19 @@ function I(r, e, t = {}) {
|
|
|
57
57
|
c.offset > 0 && c.offset < 1 && a.push(c);
|
|
58
58
|
return a.push({ offset: 1, color: e }), a.sort((c, l) => c.offset - l.offset), a;
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
function
|
|
60
|
+
const A = 12;
|
|
61
|
+
function x(r) {
|
|
62
62
|
const e = [];
|
|
63
63
|
let t, i = -1;
|
|
64
|
-
for (const s of
|
|
64
|
+
for (const s of B(r).segments) {
|
|
65
65
|
if (s.type === "L") {
|
|
66
66
|
(!t || i !== s.subpath) && (t = { kind: "line", points: [{ x: s.startX, y: s.startY }], length: 0 }, i = s.subpath, e.push(t)), t.points.push({ x: s.endX, y: s.endY }), t.length += s.length;
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
69
|
t = void 0;
|
|
70
70
|
const [o, a, n, c, l, h] = s.points, f = [];
|
|
71
|
-
for (let p = 0; p <=
|
|
72
|
-
const u = p /
|
|
71
|
+
for (let p = 0; p <= A; p++) {
|
|
72
|
+
const u = p / A, d = 1 - u;
|
|
73
73
|
f.push({
|
|
74
74
|
x: d * d * d * s.startX + 3 * d * d * u * o + 3 * d * u * u * n + u * u * u * l,
|
|
75
75
|
y: d * d * d * s.startY + 3 * d * d * u * a + 3 * d * u * u * c + u * u * u * h
|
|
@@ -79,15 +79,15 @@ function R(r) {
|
|
|
79
79
|
}
|
|
80
80
|
return e;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function ie(r, e, t, i, s = 0) {
|
|
83
83
|
const o = Math.max(0, Math.min(s, t / 2, i / 2));
|
|
84
|
-
if (o === 0) return
|
|
84
|
+
if (o === 0) return x(`M${r},${e} H${r + t} V${e + i} H${r} Z`);
|
|
85
85
|
const a = r + t, n = e + i;
|
|
86
|
-
return
|
|
86
|
+
return x(
|
|
87
87
|
`M${r + o},${e} H${a - o} A${o},${o} 0 0 1 ${a},${e + o} V${n - o} A${o},${o} 0 0 1 ${a - o},${n} H${r + o} A${o},${o} 0 0 1 ${r},${n - o} V${e + o} A${o},${o} 0 0 1 ${r + o},${e} Z`
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function S(r, e, t, i) {
|
|
91
91
|
const o = e.reduce((n, c) => n + c.length, 0) * Math.min(1, Math.max(0, t));
|
|
92
92
|
let a = 0;
|
|
93
93
|
i || r.beginPath();
|
|
@@ -98,16 +98,13 @@ function b(r, e, t, i) {
|
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
100
|
if (c <= 0) continue;
|
|
101
|
-
const l =
|
|
101
|
+
const l = K(n.points, c);
|
|
102
102
|
r.moveTo(l[0].x, l[0].y);
|
|
103
103
|
for (const h of l.slice(1)) r.lineTo(h.x, h.y);
|
|
104
104
|
}
|
|
105
105
|
i || r.stroke();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return typeof r == "object" && r !== null && "type" in r;
|
|
109
|
-
}
|
|
110
|
-
function ee(r, e, t) {
|
|
107
|
+
function F(r, e, t) {
|
|
111
108
|
if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
|
|
112
109
|
const i = r.canvas;
|
|
113
110
|
if (i?.ownerDocument) {
|
|
@@ -120,7 +117,10 @@ function ee(r, e, t) {
|
|
|
120
117
|
return null;
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
|
-
|
|
120
|
+
function we(r) {
|
|
121
|
+
return typeof r == "object" && r !== null && "type" in r;
|
|
122
|
+
}
|
|
123
|
+
class R {
|
|
124
124
|
targets = /* @__PURE__ */ new Map();
|
|
125
125
|
targetOrder = [];
|
|
126
126
|
// Store animation offsets separately - these are applied via ctx.translate() during rendering
|
|
@@ -185,12 +185,12 @@ class x {
|
|
|
185
185
|
if (!s) continue;
|
|
186
186
|
const o = this.aliases.get(t) ?? t, a = this.animationOffsets.get(o) ?? { x: 0, y: 0 };
|
|
187
187
|
for (const [n, c] of i)
|
|
188
|
-
if (
|
|
188
|
+
if (R.OFFSET_PROPERTIES.has(n) && typeof c == "number")
|
|
189
189
|
n === "x" || n === "motionPathX" ? a.x = c : (n === "y" || n === "motionPathY") && (a.y = c);
|
|
190
190
|
else if (s.type === "custom" && s.props && (n in s.props || s.acceptsProp?.(n)))
|
|
191
191
|
s.props[n] = c;
|
|
192
192
|
else {
|
|
193
|
-
const l =
|
|
193
|
+
const l = R.PROPERTY_MAP[n] ?? n;
|
|
194
194
|
s[l] = c;
|
|
195
195
|
}
|
|
196
196
|
this.animationOffsets.set(o, a);
|
|
@@ -218,13 +218,13 @@ class x {
|
|
|
218
218
|
* Render a single target.
|
|
219
219
|
*/
|
|
220
220
|
renderTarget(e, t, i) {
|
|
221
|
-
if (e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity),
|
|
222
|
-
const o =
|
|
223
|
-
if (t.backfaceVisibility === "hidden" &&
|
|
221
|
+
if (e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity), D(t)) {
|
|
222
|
+
const o = C(t, i, { x: this.getPivotX(t), y: this.getPivotY(t) });
|
|
223
|
+
if (t.backfaceVisibility === "hidden" && I(o)) {
|
|
224
224
|
e.restore();
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
U(o) ? (e.transform(...W(o)), this.drawContent(e, t)) : this.drawInPerspective(e, t, o), e.restore();
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
if ((i.x !== 0 || i.y !== 0) && e.translate(i.x, i.y), t.rotate !== void 0 || t.rotateX !== void 0 || t.rotateY !== void 0 || t.scale !== void 0 || t.scaleX !== void 0 || t.scaleY !== void 0 || t.skewX !== void 0 || t.skewY !== void 0) {
|
|
@@ -254,10 +254,10 @@ class x {
|
|
|
254
254
|
}
|
|
255
255
|
drawMesh(e, t, i) {
|
|
256
256
|
const s = this.contentBounds(e, t);
|
|
257
|
-
for (const o of
|
|
258
|
-
const a =
|
|
257
|
+
for (const o of N(i, s)) {
|
|
258
|
+
const a = H(o.source, o.target);
|
|
259
259
|
if (!a) continue;
|
|
260
|
-
const [n, c, l] =
|
|
260
|
+
const [n, c, l] = V(o.target, 1);
|
|
261
261
|
e.save(), e.beginPath(), e.moveTo(n.x, n.y), e.lineTo(c.x, c.y), e.lineTo(l.x, l.y), e.closePath(), e.clip(), e.transform(...a), this.drawContent(e, t), e.restore();
|
|
262
262
|
}
|
|
263
263
|
}
|
|
@@ -266,7 +266,7 @@ class x {
|
|
|
266
266
|
const t = e.canvas?.width ?? 0, i = e.canvas?.height ?? 0;
|
|
267
267
|
if (!(t > 0 && i > 0)) return null;
|
|
268
268
|
if (!this.layer || this.layer.width !== t || this.layer.height !== i) {
|
|
269
|
-
const o =
|
|
269
|
+
const o = F(e, t, i), a = o?.getContext("2d");
|
|
270
270
|
if (this.layer = o && a ? { canvas: o, ctx: a, width: t, height: i } : null, !this.layer) return null;
|
|
271
271
|
}
|
|
272
272
|
const s = this.layer.ctx;
|
|
@@ -288,7 +288,7 @@ class x {
|
|
|
288
288
|
i = { x: c, y: l, width: a, height: o * 1.4 };
|
|
289
289
|
} else if (t.type === "path") {
|
|
290
290
|
const o = [], a = [];
|
|
291
|
-
for (const n of
|
|
291
|
+
for (const n of B(t.d).segments) {
|
|
292
292
|
o.push(n.startX, n.endX), a.push(n.startY, n.endY);
|
|
293
293
|
for (let c = 0; c + 1 < n.points.length; c += 2)
|
|
294
294
|
o.push(n.points[c]), a.push(n.points[c + 1]);
|
|
@@ -307,7 +307,7 @@ class x {
|
|
|
307
307
|
*/
|
|
308
308
|
drawContent(e, t) {
|
|
309
309
|
t.fillStyle && (e.fillStyle = this.resolveFillStyle(e, t)), t.strokeStyle && (e.strokeStyle = t.strokeStyle), t.lineWidth !== void 0 && (e.lineWidth = t.lineWidth);
|
|
310
|
-
const i =
|
|
310
|
+
const i = O(t);
|
|
311
311
|
if (i && (e.filter = i), t.clipTop !== void 0 || t.clipRight !== void 0 || t.clipBottom !== void 0 || t.clipLeft !== void 0) {
|
|
312
312
|
const s = this.getTargetBounds(t), o = s.x + (t.clipLeft ?? 0) / 100 * s.width, a = s.x + s.width - (t.clipRight ?? 0) / 100 * s.width, n = s.y + (t.clipTop ?? 0) / 100 * s.height, c = s.y + s.height - (t.clipBottom ?? 0) / 100 * s.height;
|
|
313
313
|
e.beginPath(), e.rect(o, n, Math.max(0, a - o), Math.max(0, c - n)), e.clip();
|
|
@@ -404,7 +404,7 @@ class x {
|
|
|
404
404
|
renderOutlined(e, t, i, s) {
|
|
405
405
|
const o = Math.min(1, Math.max(0, t.drawOn ?? 1));
|
|
406
406
|
if (i && t.fillStyle && o >= 1 && i(), !t.strokeStyle || o <= 0) return;
|
|
407
|
-
const a = t.sketch ?
|
|
407
|
+
const a = t.sketch ? Q(e, t.sketch, this.time) : void 0;
|
|
408
408
|
a && (e.lineCap = t.lineCap ?? "round", e.lineJoin = t.lineJoin ?? "round"), s(o, a);
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
@@ -419,7 +419,7 @@ class x {
|
|
|
419
419
|
() => {
|
|
420
420
|
e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, i, s, o, a, t.borderRadius) : e.rect(i, s, o, a), e.fill();
|
|
421
421
|
},
|
|
422
|
-
(n, c) =>
|
|
422
|
+
(n, c) => S(e, ie(i, s, o, a, t.borderRadius), n, c)
|
|
423
423
|
);
|
|
424
424
|
}
|
|
425
425
|
e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, t.x, t.y, t.width, t.height, t.borderRadius) : e.rect(t.x, t.y, t.width, t.height), t.fillStyle && e.fill(), t.strokeStyle && e.stroke(), e.closePath();
|
|
@@ -459,7 +459,7 @@ class x {
|
|
|
459
459
|
if (e.font = `${o} ${i}px ${s}`, e.textAlign = t.textAlign ?? "left", e.textBaseline = t.textBaseline ?? "top", t.fillStyle) {
|
|
460
460
|
if (t.shine !== void 0 && typeof t.fillStyle == "string") {
|
|
461
461
|
const a = e.measureText(t.text).width, n = t.textAlign ?? "left", c = n === "center" ? t.x - a / 2 : n === "right" ? t.x - a : t.x, l = e.createLinearGradient(c, t.y, c + a, t.y);
|
|
462
|
-
for (const h of
|
|
462
|
+
for (const h of L(t.shine, t.fillStyle))
|
|
463
463
|
l.addColorStop(h.offset, h.color);
|
|
464
464
|
e.fillStyle = l;
|
|
465
465
|
}
|
|
@@ -480,7 +480,7 @@ class x {
|
|
|
480
480
|
e,
|
|
481
481
|
t,
|
|
482
482
|
void 0,
|
|
483
|
-
(o, a) =>
|
|
483
|
+
(o, a) => S(e, [{ kind: "line", points: i, length: s }], o, a)
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
486
|
e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(t.x2, t.y2), t.strokeStyle && e.stroke(), e.closePath();
|
|
@@ -496,7 +496,7 @@ class x {
|
|
|
496
496
|
e,
|
|
497
497
|
t,
|
|
498
498
|
() => e.fill(i),
|
|
499
|
-
(s, o) =>
|
|
499
|
+
(s, o) => S(e, x(t.d), s, o)
|
|
500
500
|
);
|
|
501
501
|
t.fillStyle && e.fill(i), t.strokeStyle && e.stroke(i);
|
|
502
502
|
}
|
|
@@ -507,12 +507,12 @@ class x {
|
|
|
507
507
|
if (!t.image) return;
|
|
508
508
|
t.opacity !== void 0 && (e.globalAlpha = t.opacity);
|
|
509
509
|
const { x: i, y: s, width: o, height: a } = t, n = t.objectFit ?? "fill", c = t.borderRadius ?? 0, l = t.image, h = l.naturalWidth || l.videoWidth || l.width || o, f = l.naturalHeight || l.videoHeight || l.height || a;
|
|
510
|
-
let p = i, u = s, d = o,
|
|
510
|
+
let p = i, u = s, d = o, m = a;
|
|
511
511
|
if (n !== "fill" && h > 0 && f > 0) {
|
|
512
|
-
const
|
|
513
|
-
d = h *
|
|
512
|
+
const y = n === "cover" ? Math.max(o / h, a / f) : Math.min(o / h, a / f);
|
|
513
|
+
d = h * y, m = f * y, p = i + (o - d) / 2, u = s + (a - m) / 2;
|
|
514
514
|
}
|
|
515
|
-
e.save(), e.beginPath(), c > 0 && typeof e.roundRect == "function" ? e.roundRect(i, s, o, a, c) : e.rect(i, s, o, a), e.clip(), e.drawImage(t.image, p, u, d,
|
|
515
|
+
e.save(), e.beginPath(), c > 0 && typeof e.roundRect == "function" ? e.roundRect(i, s, o, a, c) : e.rect(i, s, o, a), e.clip(), e.drawImage(t.image, p, u, d, m), e.restore();
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Render a custom target by calling its draw function in local coordinates.
|
|
@@ -620,7 +620,51 @@ class x {
|
|
|
620
620
|
});
|
|
621
621
|
}
|
|
622
622
|
}
|
|
623
|
-
|
|
623
|
+
function se(r, e) {
|
|
624
|
+
const t = r.length / 4, i = new Float32Array(t * 3), s = Math.min(0.999, Math.max(0, e));
|
|
625
|
+
for (let o = 0; o < t; o++) {
|
|
626
|
+
const a = r[o * 4] / 255, n = r[o * 4 + 1] / 255, c = r[o * 4 + 2] / 255, l = r[o * 4 + 3] / 255, h = Math.max(a, n, c);
|
|
627
|
+
if (h <= s) continue;
|
|
628
|
+
const f = (h - s) / (1 - s) * l / h;
|
|
629
|
+
i[o * 3] = a * f, i[o * 3 + 1] = n * f, i[o * 3 + 2] = c * f;
|
|
630
|
+
}
|
|
631
|
+
return i;
|
|
632
|
+
}
|
|
633
|
+
function k(r, e, t, i, s) {
|
|
634
|
+
const o = new Float32Array(r.length), a = s ? t : e, n = s ? e : t, c = (h, f) => (s ? h * e + f : f * e + h) * 3, l = i * 2 + 1;
|
|
635
|
+
for (let h = 0; h < a; h++)
|
|
636
|
+
for (let f = 0; f < 3; f++) {
|
|
637
|
+
let p = 0;
|
|
638
|
+
for (let u = -i; u <= i; u++) p += r[c(h, Math.min(n - 1, Math.max(0, u))) + f];
|
|
639
|
+
for (let u = 0; u < n; u++) {
|
|
640
|
+
o[c(h, u) + f] = p / l;
|
|
641
|
+
const d = r[c(h, Math.max(0, u - i)) + f], m = r[c(h, Math.min(n - 1, u + i + 1)) + f];
|
|
642
|
+
p += m - d;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return o;
|
|
646
|
+
}
|
|
647
|
+
function E(r, e, t, i) {
|
|
648
|
+
const s = Math.max(1, Math.round(i / Math.sqrt(3)));
|
|
649
|
+
let o = r;
|
|
650
|
+
for (let a = 0; a < 3; a++)
|
|
651
|
+
o = k(o, e, t, s, !0), o = k(o, e, t, s, !1);
|
|
652
|
+
return o;
|
|
653
|
+
}
|
|
654
|
+
function Te(r, e = {}) {
|
|
655
|
+
const t = r.canvas, i = t.width, s = t.height;
|
|
656
|
+
if (!(i > 0 && s > 0)) return;
|
|
657
|
+
const o = Math.max(1, Math.round(e.downsample ?? 4)), a = Math.max(1, Math.ceil(i / o)), n = Math.max(1, Math.ceil(s / o)), c = F(r, a, n), l = c?.getContext("2d");
|
|
658
|
+
if (!c || !l) return;
|
|
659
|
+
l.imageSmoothingEnabled = !0, l.drawImage(r.canvas, 0, 0, a, n);
|
|
660
|
+
const h = se(l.getImageData(0, 0, a, n).data, e.threshold ?? 0.55), f = (e.radius ?? Math.max(i, s) * 0.02) / o, p = E(h, a, n, f), u = E(h, a, n, f * 3), d = e.halo ?? 0.6, m = l.createImageData(a, n);
|
|
661
|
+
for (let y = 0; y < a * n; y++) {
|
|
662
|
+
for (let w = 0; w < 3; w++) m.data[y * 4 + w] = Math.round(Math.min(1, p[y * 3 + w] + u[y * 3 + w] * d) * 255);
|
|
663
|
+
m.data[y * 4 + 3] = 255;
|
|
664
|
+
}
|
|
665
|
+
l.putImageData(m, 0, 0), r.save(), r.setTransform(1, 0, 0, 1, 0, 0), r.globalCompositeOperation = "lighter", r.globalAlpha = Math.max(0, e.strength ?? 0.9), r.imageSmoothingEnabled = !0, r.drawImage(c, 0, 0, i, s), r.restore();
|
|
666
|
+
}
|
|
667
|
+
const M = "http://www.w3.org/2000/svg", oe = /* @__PURE__ */ new Set([
|
|
624
668
|
"fill",
|
|
625
669
|
"stroke",
|
|
626
670
|
"d",
|
|
@@ -640,7 +684,7 @@ const S = "http://www.w3.org/2000/svg", te = /* @__PURE__ */ new Set([
|
|
|
640
684
|
"height",
|
|
641
685
|
"viewBox",
|
|
642
686
|
"preserveAspectRatio"
|
|
643
|
-
]),
|
|
687
|
+
]), X = {
|
|
644
688
|
strokeWidth: "stroke-width",
|
|
645
689
|
strokeLinecap: "stroke-linecap",
|
|
646
690
|
strokeLinejoin: "stroke-linejoin",
|
|
@@ -651,7 +695,7 @@ const S = "http://www.w3.org/2000/svg", te = /* @__PURE__ */ new Set([
|
|
|
651
695
|
strokeOpacity: "stroke-opacity",
|
|
652
696
|
borderRadius: "rx"
|
|
653
697
|
// Map CSS borderRadius to SVG rx
|
|
654
|
-
},
|
|
698
|
+
}, ne = /* @__PURE__ */ new Set([
|
|
655
699
|
"x",
|
|
656
700
|
// Position x treated as translateX
|
|
657
701
|
"y",
|
|
@@ -672,8 +716,8 @@ const S = "http://www.w3.org/2000/svg", te = /* @__PURE__ */ new Set([
|
|
|
672
716
|
"motionPathX",
|
|
673
717
|
"motionPathY",
|
|
674
718
|
"motionPathRotate"
|
|
675
|
-
]),
|
|
676
|
-
class
|
|
719
|
+
]), re = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
|
|
720
|
+
class ve {
|
|
677
721
|
targets = /* @__PURE__ */ new Map();
|
|
678
722
|
/**
|
|
679
723
|
* Register an SVG element as an animation target.
|
|
@@ -717,10 +761,10 @@ class ye {
|
|
|
717
761
|
const o = {}, a = {}, n = {};
|
|
718
762
|
let c = !1;
|
|
719
763
|
for (const [l, h] of t)
|
|
720
|
-
l !== "drawOn" && (
|
|
764
|
+
l !== "drawOn" && (ne.has(l) ? i[l] = h : l === "quaternion" ? s = q(h) : l === "originX" || l === "originY" ? typeof h == "number" && (o[l] = h) : l === "perspective" ? typeof h == "number" && (i.perspective = h) : re.has(l) ? typeof h == "number" && (a[l] = h) : z.has(l) ? (n[l] = h, c = !0) : l === "text" ? typeof h == "string" && j(e, h) : l === "shine" ? typeof h == "number" && this.applyShine(e, h) : l === "opacity" ? (e.setAttribute("fill-opacity", String(h)), e.setAttribute("stroke-opacity", String(h))) : this.applyAttribute(e, l, h));
|
|
721
765
|
if (Object.keys(i).length > 0 || s) {
|
|
722
766
|
const l = this.buildCssTransformString(i, s);
|
|
723
|
-
e.style.transform = l,
|
|
767
|
+
e.style.transform = l, Z(e);
|
|
724
768
|
}
|
|
725
769
|
if (Object.keys(o).length > 0) {
|
|
726
770
|
const l = e.style;
|
|
@@ -731,7 +775,7 @@ class ye {
|
|
|
731
775
|
e.style.clipPath = `inset(${l}% ${h}% ${f}% ${p}%)`;
|
|
732
776
|
}
|
|
733
777
|
if (c) {
|
|
734
|
-
const l =
|
|
778
|
+
const l = O(n);
|
|
735
779
|
l && (e.style.filter = l);
|
|
736
780
|
}
|
|
737
781
|
}
|
|
@@ -767,23 +811,23 @@ class ye {
|
|
|
767
811
|
o.dataset.shineBase || (o.dataset.shineBase = e.getAttribute("fill") || "#000000");
|
|
768
812
|
const a = o.dataset.shineBase;
|
|
769
813
|
let n = i.querySelector("defs");
|
|
770
|
-
n || (n = s.createElementNS(
|
|
814
|
+
n || (n = s.createElementNS(M, "defs"), i.insertBefore(n, i.firstChild));
|
|
771
815
|
let c = o.dataset.shineGrad, l = c ? n.querySelector(`#${c}`) : null;
|
|
772
|
-
for (l || (c = `tinyfly-shine-${Math.random().toString(36).slice(2, 9)}`, o.dataset.shineGrad = c, l = s.createElementNS(
|
|
773
|
-
for (const h of
|
|
774
|
-
const f = s.createElementNS(
|
|
816
|
+
for (l || (c = `tinyfly-shine-${Math.random().toString(36).slice(2, 9)}`, o.dataset.shineGrad = c, l = s.createElementNS(M, "linearGradient"), l.setAttribute("id", c), n.appendChild(l)); l.firstChild; ) l.removeChild(l.firstChild);
|
|
817
|
+
for (const h of L(t, a)) {
|
|
818
|
+
const f = s.createElementNS(M, "stop");
|
|
775
819
|
f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), l.appendChild(f);
|
|
776
820
|
}
|
|
777
821
|
e.setAttribute("fill", `url(#${c})`);
|
|
778
822
|
}
|
|
779
823
|
applyAttribute(e, t, i) {
|
|
780
824
|
let s = t;
|
|
781
|
-
|
|
825
|
+
X[t] ? s = X[t] : oe.has(t) && (s = t);
|
|
782
826
|
const o = Array.isArray(i) ? i.join(" ") : String(i);
|
|
783
827
|
e.setAttribute(s, o);
|
|
784
828
|
}
|
|
785
829
|
}
|
|
786
|
-
const
|
|
830
|
+
const ae = `
|
|
787
831
|
attribute vec2 a_position;
|
|
788
832
|
attribute vec2 a_texCoord;
|
|
789
833
|
uniform mat4 u_matrix;
|
|
@@ -793,7 +837,7 @@ void main() {
|
|
|
793
837
|
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
794
838
|
v_texCoord = a_texCoord;
|
|
795
839
|
}
|
|
796
|
-
`,
|
|
840
|
+
`, ce = `
|
|
797
841
|
precision mediump float;
|
|
798
842
|
uniform vec4 u_color;
|
|
799
843
|
uniform sampler2D u_texture;
|
|
@@ -804,7 +848,7 @@ void main() {
|
|
|
804
848
|
vec4 color = u_useTexture ? texture2D(u_texture, v_texCoord) : u_color;
|
|
805
849
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
806
850
|
}
|
|
807
|
-
`,
|
|
851
|
+
`, le = /* @__PURE__ */ new Set([
|
|
808
852
|
"x",
|
|
809
853
|
"y",
|
|
810
854
|
"width",
|
|
@@ -825,7 +869,7 @@ void main() {
|
|
|
825
869
|
"motionPathY",
|
|
826
870
|
"motionPathRotate"
|
|
827
871
|
]);
|
|
828
|
-
class
|
|
872
|
+
class be {
|
|
829
873
|
gl;
|
|
830
874
|
program;
|
|
831
875
|
positionBuffer;
|
|
@@ -836,7 +880,7 @@ class me {
|
|
|
836
880
|
basePositions = /* @__PURE__ */ new Map();
|
|
837
881
|
locations;
|
|
838
882
|
constructor(e) {
|
|
839
|
-
this.gl = e, this.program =
|
|
883
|
+
this.gl = e, this.program = ue(e, ae, ce), this.locations = {
|
|
840
884
|
position: e.getAttribLocation(this.program, "a_position"),
|
|
841
885
|
texCoord: e.getAttribLocation(this.program, "a_texCoord"),
|
|
842
886
|
matrix: e.getUniformLocation(this.program, "u_matrix"),
|
|
@@ -844,7 +888,7 @@ class me {
|
|
|
844
888
|
texture: e.getUniformLocation(this.program, "u_texture"),
|
|
845
889
|
useTexture: e.getUniformLocation(this.program, "u_useTexture"),
|
|
846
890
|
opacity: e.getUniformLocation(this.program, "u_opacity")
|
|
847
|
-
}, this.positionBuffer =
|
|
891
|
+
}, this.positionBuffer = Y(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), this.texCoordBuffer = Y(e, [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]);
|
|
848
892
|
}
|
|
849
893
|
registerTarget(e, t) {
|
|
850
894
|
this.targets.set(e, t), this.basePositions.set(e, { x: t.x, y: t.y });
|
|
@@ -884,7 +928,7 @@ class me {
|
|
|
884
928
|
e.rotate = s;
|
|
885
929
|
return;
|
|
886
930
|
}
|
|
887
|
-
if (
|
|
931
|
+
if (le.has(i)) {
|
|
888
932
|
e[i] = s;
|
|
889
933
|
return;
|
|
890
934
|
}
|
|
@@ -894,19 +938,19 @@ class me {
|
|
|
894
938
|
/** Draw every registered target. */
|
|
895
939
|
render() {
|
|
896
940
|
const e = this.gl, { width: t, height: i } = e.canvas;
|
|
897
|
-
e.viewport(0, 0, t, i), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.enable(e.BLEND), e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA), e.useProgram(this.program),
|
|
941
|
+
e.viewport(0, 0, t, i), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.enable(e.BLEND), e.blendFunc(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA), e.useProgram(this.program), $(e, this.positionBuffer, this.locations.position), $(e, this.texCoordBuffer, this.locations.texCoord);
|
|
898
942
|
for (const [s, o] of this.targets)
|
|
899
943
|
this.drawTarget(s, o, t, i);
|
|
900
944
|
}
|
|
901
945
|
drawTarget(e, t, i, s) {
|
|
902
946
|
const o = this.gl;
|
|
903
|
-
if (t.backfaceVisibility === "hidden" &&
|
|
904
|
-
const a =
|
|
947
|
+
if (t.backfaceVisibility === "hidden" && I(G(t))) return;
|
|
948
|
+
const a = he(t, i, s);
|
|
905
949
|
if (o.uniformMatrix4fv(this.locations.matrix, !1, a), o.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
|
|
906
950
|
o.bindTexture(o.TEXTURE_2D, this.textureFor(e, t.texture)), o.uniform1i(this.locations.useTexture, 1), o.uniform1i(this.locations.texture, 0);
|
|
907
951
|
else {
|
|
908
952
|
o.uniform1i(this.locations.useTexture, 0);
|
|
909
|
-
const [n, c, l] =
|
|
953
|
+
const [n, c, l] = fe(t.fill ?? "#ffffff");
|
|
910
954
|
o.uniform4f(this.locations.color, n, c, l, 1);
|
|
911
955
|
}
|
|
912
956
|
o.drawArrays(o.TRIANGLES, 0, 6);
|
|
@@ -922,32 +966,32 @@ class me {
|
|
|
922
966
|
this.clearTargets(), this.gl.deleteProgram(this.program), this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteBuffer(this.texCoordBuffer);
|
|
923
967
|
}
|
|
924
968
|
}
|
|
925
|
-
function
|
|
926
|
-
const i = (r.scale ?? r.scaleX ?? 1) * r.width, s = (r.scale ?? r.scaleY ?? 1) * r.height, o = (r.originX ?? 50) / 100, a = (r.originY ?? 50) / 100, n = (r.rotate ?? 0) * Math.PI / 180, c = Math.cos(n), l = Math.sin(n), h = -o, f = -a, p = c * i, u = l * i, d = -l * s,
|
|
969
|
+
function Pe(r, e, t) {
|
|
970
|
+
const i = (r.scale ?? r.scaleX ?? 1) * r.width, s = (r.scale ?? r.scaleY ?? 1) * r.height, o = (r.originX ?? 50) / 100, a = (r.originY ?? 50) / 100, n = (r.rotate ?? 0) * Math.PI / 180, c = Math.cos(n), l = Math.sin(n), h = -o, f = -a, p = c * i, u = l * i, d = -l * s, m = c * s, y = r.x + p * h + d * f, w = r.y + u * h + m * f, b = 2 / e, P = -2 / t;
|
|
927
971
|
return new Float32Array([
|
|
928
|
-
p *
|
|
972
|
+
p * b,
|
|
929
973
|
u * P,
|
|
930
974
|
0,
|
|
931
|
-
d *
|
|
932
|
-
|
|
975
|
+
d * b,
|
|
976
|
+
m * P,
|
|
933
977
|
0,
|
|
934
|
-
|
|
935
|
-
|
|
978
|
+
y * b - 1,
|
|
979
|
+
w * P + 1,
|
|
936
980
|
1
|
|
937
981
|
]);
|
|
938
982
|
}
|
|
939
|
-
function
|
|
940
|
-
const e = (r.originX ?? 50) / 100, t = (r.originY ?? 50) / 100, i = { x: r.x, y: r.y }, s =
|
|
941
|
-
|
|
942
|
-
|
|
983
|
+
function G(r) {
|
|
984
|
+
const e = (r.originX ?? 50) / 100, t = (r.originY ?? 50) / 100, i = { x: r.x, y: r.y }, s = T.multiply(
|
|
985
|
+
T.translation([r.x, r.y, 0]),
|
|
986
|
+
T.multiply(T.scaling([r.width, r.height, 1]), T.translation([-e, -t, 0]))
|
|
943
987
|
);
|
|
944
|
-
return
|
|
988
|
+
return T.multiply(C(r, { x: 0, y: 0 }, i), s);
|
|
945
989
|
}
|
|
946
|
-
function
|
|
990
|
+
function he(r, e, t) {
|
|
947
991
|
const i = [2 / e, 0, 0, 0, 0, -2 / t, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1];
|
|
948
|
-
return new Float32Array(
|
|
992
|
+
return new Float32Array(T.multiply(i, G(r)));
|
|
949
993
|
}
|
|
950
|
-
function
|
|
994
|
+
function fe(r) {
|
|
951
995
|
const e = r.trim().replace("#", "");
|
|
952
996
|
return e.length === 3 ? [
|
|
953
997
|
Number.parseInt(e[0] + e[0], 16) / 255,
|
|
@@ -959,47 +1003,51 @@ function ce(r) {
|
|
|
959
1003
|
Number.parseInt(e.slice(4, 6), 16) / 255
|
|
960
1004
|
] : [1, 1, 1];
|
|
961
1005
|
}
|
|
962
|
-
function
|
|
1006
|
+
function ue(r, e, t) {
|
|
963
1007
|
const i = r.createProgram();
|
|
964
1008
|
if (!i) throw new Error("WebGLAdapter: could not create a program");
|
|
965
|
-
if (r.attachShader(i,
|
|
1009
|
+
if (r.attachShader(i, _(r, r.VERTEX_SHADER, e)), r.attachShader(i, _(r, r.FRAGMENT_SHADER, t)), r.linkProgram(i), !r.getProgramParameter(i, r.LINK_STATUS))
|
|
966
1010
|
throw new Error(`WebGLAdapter: program link failed — ${r.getProgramInfoLog(i)}`);
|
|
967
1011
|
return i;
|
|
968
1012
|
}
|
|
969
|
-
function
|
|
1013
|
+
function _(r, e, t) {
|
|
970
1014
|
const i = r.createShader(e);
|
|
971
1015
|
if (!i) throw new Error("WebGLAdapter: could not create a shader");
|
|
972
1016
|
if (r.shaderSource(i, t), r.compileShader(i), !r.getShaderParameter(i, r.COMPILE_STATUS))
|
|
973
1017
|
throw new Error(`WebGLAdapter: shader compile failed — ${r.getShaderInfoLog(i)}`);
|
|
974
1018
|
return i;
|
|
975
1019
|
}
|
|
976
|
-
function
|
|
1020
|
+
function Y(r, e) {
|
|
977
1021
|
const t = r.createBuffer();
|
|
978
1022
|
if (!t) throw new Error("WebGLAdapter: could not create a buffer");
|
|
979
1023
|
return r.bindBuffer(r.ARRAY_BUFFER, t), r.bufferData(r.ARRAY_BUFFER, new Float32Array(e), r.STATIC_DRAW), t;
|
|
980
1024
|
}
|
|
981
|
-
function
|
|
1025
|
+
function $(r, e, t) {
|
|
982
1026
|
t < 0 || (r.bindBuffer(r.ARRAY_BUFFER, e), r.enableVertexAttribArray(t), r.vertexAttribPointer(t, 2, r.FLOAT, !1, 0, 0));
|
|
983
1027
|
}
|
|
984
1028
|
export {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1029
|
+
R as CanvasAdapter,
|
|
1030
|
+
xe as DOMAdapter,
|
|
1031
|
+
ve as SVGAdapter,
|
|
1032
|
+
be as WebGLAdapter,
|
|
1033
|
+
Te as applyBloom,
|
|
1034
|
+
Ae as boilFrame,
|
|
1035
|
+
E as boxBlur,
|
|
1036
|
+
se as brightPass,
|
|
1037
|
+
te as buildFlipTracks,
|
|
1038
|
+
F as canvasLike,
|
|
1039
|
+
S as drawOutline,
|
|
1040
|
+
ye as flip,
|
|
1041
|
+
we as isGradient,
|
|
1042
|
+
fe as parseColor,
|
|
1043
|
+
K as partialPath,
|
|
1044
|
+
ke as pathLength,
|
|
1045
|
+
x as pathOutline,
|
|
1046
|
+
Ee as pointAlong,
|
|
1047
|
+
Pe as quadMatrix,
|
|
1048
|
+
he as quadMatrix3d,
|
|
1049
|
+
ee as recordFlipState,
|
|
1050
|
+
ie as rectOutline,
|
|
1051
|
+
j as setTextContent,
|
|
1052
|
+
Q as sketchPen
|
|
1005
1053
|
};
|
package/lib/addons/characters.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as xs } from "./sketch-
|
|
1
|
+
import { c as mn, s as Je, p as Rt, b as lt } from "./sketch-CYPUbk3Q.js";
|
|
2
|
+
import { a as xs } from "./sketch-CYPUbk3Q.js";
|
|
3
3
|
import { createRandom as yn, hashSeed as wn, getEasingFunction as Le, mat4 as N, vec3 as U, quat as yt } from "@algorisys/tinyfly";
|
|
4
4
|
import { f as wt, h as kn, a as Sn } from "./load-scene-vp14_Jj-.js";
|
|
5
5
|
function Ke(e, t, n) {
|
package/lib/addons/maps.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as B, p as K, a as v,
|
|
1
|
+
import { s as B, p as K, a as v, b as R } from "./sketch-CYPUbk3Q.js";
|
|
2
2
|
const T = 256, N = 85.05112878, O = (a) => Math.max(-N, Math.min(N, a));
|
|
3
3
|
function A(a, n) {
|
|
4
4
|
const e = Math.sin(O(n) * Math.PI / 180);
|