@algorisys/tinyfly 0.90.0 → 0.92.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 +179 -205
- package/lib/addons/camera-C7bZOWMB.js +33 -0
- package/lib/addons/characters.js +1410 -1290
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +2716 -2593
- 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 +287 -278
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- 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/characters/acting/script.d.ts +12 -1
- package/lib/types/characters/index.d.ts +2 -0
- package/lib/types/characters/species/human-motion.d.ts +45 -0
- package/lib/types/characters/species/human.d.ts +2 -0
- package/lib/types/engine/core/timeline.d.ts +3 -0
- package/lib/types/engine/types.d.ts +6 -0
- package/package.json +1 -1
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
|
|
3
|
-
import { createTrack as Q, parsePath as L, ribbon as K, ribbonHeadCap as ee, mat4 as
|
|
2
|
+
import { D as Xe } from "./dom-adapter-Cphr2HZn.js";
|
|
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)
|
|
@@ -11,25 +12,25 @@ function oe(n) {
|
|
|
11
12
|
}
|
|
12
13
|
function se(n, e, t = {}) {
|
|
13
14
|
const i = t.duration ?? 600, o = t.easing ?? "ease-out", s = t.scale !== !1, a = t.idPrefix ?? "flip", r = [];
|
|
14
|
-
for (const { name:
|
|
15
|
-
const h = n.measurements.get(
|
|
15
|
+
for (const { name: c, element: l } of e) {
|
|
16
|
+
const h = n.measurements.get(c);
|
|
16
17
|
if (!h) continue;
|
|
17
|
-
const f = F(
|
|
18
|
+
const f = F(l), m = h.left + h.width / 2 - (f.left + f.width / 2), u = h.top + h.height / 2 - (f.top + f.height / 2);
|
|
18
19
|
if ((m !== 0 || u !== 0) && r.push(
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
T(`${a}-${c}-x`, c, "x", m, 0, i, o),
|
|
21
|
+
T(`${a}-${c}-y`, c, "y", u, 0, i, o)
|
|
21
22
|
), s && f.width > 0 && f.height > 0) {
|
|
22
23
|
const p = h.width / f.width, d = h.height / f.height;
|
|
23
|
-
p !== 1 && r.push(
|
|
24
|
+
p !== 1 && r.push(T(`${a}-${c}-sx`, c, "scaleX", p, 1, i, o)), d !== 1 && r.push(T(`${a}-${c}-sy`, c, "scaleY", d, 1, i, o));
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
return r;
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function Me(n, e, t = {}) {
|
|
29
30
|
const i = oe(n);
|
|
30
31
|
return e(), se(i, n, t);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function T(n, e, t, i, o, s, a) {
|
|
33
34
|
return Q({
|
|
34
35
|
id: n,
|
|
35
36
|
target: e,
|
|
@@ -53,11 +54,11 @@ function D(n, e, t = {}) {
|
|
|
53
54
|
{ offset: s, color: i },
|
|
54
55
|
{ offset: s + o, color: e }
|
|
55
56
|
];
|
|
56
|
-
for (const
|
|
57
|
-
|
|
58
|
-
return a.push({ offset: 1, color: e }), a.sort((
|
|
57
|
+
for (const c of r)
|
|
58
|
+
c.offset > 0 && c.offset < 1 && a.push(c);
|
|
59
|
+
return a.push({ offset: 1, color: e }), a.sort((c, l) => c.offset - l.offset), a;
|
|
59
60
|
}
|
|
60
|
-
const
|
|
61
|
+
const k = 12;
|
|
61
62
|
function x(n) {
|
|
62
63
|
const e = [];
|
|
63
64
|
let t, i = -1;
|
|
@@ -67,12 +68,12 @@ function x(n) {
|
|
|
67
68
|
continue;
|
|
68
69
|
}
|
|
69
70
|
t = void 0;
|
|
70
|
-
const [s, a, r,
|
|
71
|
-
for (let m = 0; m <=
|
|
72
|
-
const u = m /
|
|
71
|
+
const [s, a, r, c, l, h] = o.points, f = [];
|
|
72
|
+
for (let m = 0; m <= k; m++) {
|
|
73
|
+
const u = m / k, p = 1 - u;
|
|
73
74
|
f.push({
|
|
74
|
-
x: p * p * p * o.startX + 3 * p * p * u * s + 3 * p * u * u * r + u * u * u *
|
|
75
|
-
y: p * p * p * o.startY + 3 * p * p * u * a + 3 * p * u * u *
|
|
75
|
+
x: p * p * p * o.startX + 3 * p * p * u * s + 3 * p * u * u * r + u * u * u * l,
|
|
76
|
+
y: p * p * p * o.startY + 3 * p * p * u * a + 3 * p * u * u * c + u * u * u * h
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
e.push({ kind: "curve", points: f, length: o.length });
|
|
@@ -87,24 +88,24 @@ function ne(n, e, t, i, o = 0) {
|
|
|
87
88
|
`M${n + s},${e} H${a - s} A${s},${s} 0 0 1 ${a},${e + s} V${r - s} A${s},${s} 0 0 1 ${a - s},${r} H${n + s} A${s},${s} 0 0 1 ${n},${r - s} V${e + s} A${s},${s} 0 0 1 ${n + s},${e} Z`
|
|
88
89
|
);
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
-
const s = e.reduce((r,
|
|
91
|
+
function M(n, e, t, i) {
|
|
92
|
+
const s = e.reduce((r, c) => r + c.length, 0) * Math.min(1, Math.max(0, t));
|
|
92
93
|
let a = 0;
|
|
93
94
|
i || n.beginPath();
|
|
94
95
|
for (const r of e) {
|
|
95
|
-
const
|
|
96
|
+
const c = r.length === 0 ? s >= a ? 1 : 0 : Math.min(1, Math.max(0, (s - a) / r.length));
|
|
96
97
|
if (a += r.length, i) {
|
|
97
|
-
r.kind === "curve" ? i.curve(r.points,
|
|
98
|
+
r.kind === "curve" ? i.curve(r.points, c) : i.line(r.points, c);
|
|
98
99
|
continue;
|
|
99
100
|
}
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
n.moveTo(
|
|
103
|
-
for (const h of
|
|
101
|
+
if (c <= 0) continue;
|
|
102
|
+
const l = te(r.points, c);
|
|
103
|
+
n.moveTo(l[0].x, l[0].y);
|
|
104
|
+
for (const h of l.slice(1)) n.lineTo(h.x, h.y);
|
|
104
105
|
}
|
|
105
106
|
i || n.stroke();
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function g(n, e, t) {
|
|
108
109
|
if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
|
|
109
110
|
const i = n.canvas;
|
|
110
111
|
if (i?.ownerDocument) {
|
|
@@ -117,7 +118,7 @@ function A(n, e, t) {
|
|
|
117
118
|
return null;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
+
function Se(n) {
|
|
121
122
|
return typeof n == "object" && n !== null && "type" in n;
|
|
122
123
|
}
|
|
123
124
|
class R {
|
|
@@ -184,14 +185,14 @@ class R {
|
|
|
184
185
|
const o = this.targets.get(t);
|
|
185
186
|
if (!o) continue;
|
|
186
187
|
const s = this.aliases.get(t) ?? t, a = this.animationOffsets.get(s) ?? { x: 0, y: 0 };
|
|
187
|
-
for (const [r,
|
|
188
|
-
if (R.OFFSET_PROPERTIES.has(r) && typeof
|
|
189
|
-
r === "x" || r === "motionPathX" ? a.x =
|
|
188
|
+
for (const [r, c] of i)
|
|
189
|
+
if (R.OFFSET_PROPERTIES.has(r) && typeof c == "number")
|
|
190
|
+
r === "x" || r === "motionPathX" ? a.x = c : (r === "y" || r === "motionPathY") && (a.y = c);
|
|
190
191
|
else if (o.type === "custom" && o.props && (r in o.props || o.acceptsProp?.(r)))
|
|
191
|
-
o.props[r] =
|
|
192
|
+
o.props[r] = c;
|
|
192
193
|
else {
|
|
193
|
-
const
|
|
194
|
-
o[
|
|
194
|
+
const l = R.PROPERTY_MAP[r] ?? r;
|
|
195
|
+
o[l] = c;
|
|
195
196
|
}
|
|
196
197
|
this.animationOffsets.set(s, a);
|
|
197
198
|
}
|
|
@@ -230,10 +231,10 @@ class R {
|
|
|
230
231
|
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) {
|
|
231
232
|
const s = this.getPivotX(t), a = this.getPivotY(t);
|
|
232
233
|
e.translate(s, a), t.rotate !== void 0 && e.rotate(t.rotate * Math.PI / 180);
|
|
233
|
-
let r = t.scaleX ?? 1,
|
|
234
|
-
if (t.rotateX !== void 0 && (
|
|
235
|
-
const
|
|
236
|
-
e.transform(1, Math.tan(h), Math.tan(
|
|
234
|
+
let r = t.scaleX ?? 1, c = t.scaleY ?? 1;
|
|
235
|
+
if (t.rotateX !== void 0 && (c *= Math.cos(t.rotateX * Math.PI / 180)), t.rotateY !== void 0 && (r *= Math.cos(t.rotateY * Math.PI / 180)), t.scale !== void 0 ? e.scale(t.scale, t.scale) : (r !== 1 || c !== 1) && e.scale(r, c), t.skewX !== void 0 || t.skewY !== void 0) {
|
|
236
|
+
const l = (t.skewX ?? 0) * Math.PI / 180, h = (t.skewY ?? 0) * Math.PI / 180;
|
|
237
|
+
e.transform(1, Math.tan(h), Math.tan(l), 1, 0, 0);
|
|
237
238
|
}
|
|
238
239
|
e.translate(-s, -a);
|
|
239
240
|
}
|
|
@@ -257,8 +258,8 @@ class R {
|
|
|
257
258
|
for (const s of H(i, o)) {
|
|
258
259
|
const a = V(s.source, s.target);
|
|
259
260
|
if (!a) continue;
|
|
260
|
-
const [r,
|
|
261
|
-
e.save(), e.beginPath(), e.moveTo(r.x, r.y), e.lineTo(
|
|
261
|
+
const [r, c, l] = z(s.target, 1);
|
|
262
|
+
e.save(), e.beginPath(), e.moveTo(r.x, r.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
263
|
}
|
|
263
264
|
}
|
|
264
265
|
/** A cleared offscreen canvas the size of `ctx`'s, reused frame to frame; null where none can be made. */
|
|
@@ -266,7 +267,7 @@ class R {
|
|
|
266
267
|
const t = e.canvas?.width ?? 0, i = e.canvas?.height ?? 0;
|
|
267
268
|
if (!(t > 0 && i > 0)) return null;
|
|
268
269
|
if (!this.layer || this.layer.width !== t || this.layer.height !== i) {
|
|
269
|
-
const s =
|
|
270
|
+
const s = g(e, t, i), a = s?.getContext("2d");
|
|
270
271
|
if (this.layer = s && a ? { canvas: s, ctx: a, width: t, height: i } : null, !this.layer) return null;
|
|
271
272
|
}
|
|
272
273
|
const o = this.layer.ctx;
|
|
@@ -284,18 +285,18 @@ class R {
|
|
|
284
285
|
e.save(), e.font = `${t.fontWeight ?? 400} ${s}px ${t.fontFamily ?? "sans-serif"}`;
|
|
285
286
|
const a = e.measureText(t.text).width;
|
|
286
287
|
e.restore();
|
|
287
|
-
const r = t.textAlign ?? "left",
|
|
288
|
-
i = { x:
|
|
288
|
+
const r = t.textAlign ?? "left", c = r === "center" ? t.x - a / 2 : r === "right" ? t.x - a : t.x, l = (t.textBaseline ?? "top") === "top" ? t.y : t.y - s;
|
|
289
|
+
i = { x: c, y: l, width: a, height: s * 1.4 };
|
|
289
290
|
} else if (t.type === "path") {
|
|
290
291
|
const s = [], a = [];
|
|
291
292
|
for (const r of L(t.d).segments) {
|
|
292
293
|
s.push(r.startX, r.endX), a.push(r.startY, r.endY);
|
|
293
|
-
for (let
|
|
294
|
-
s.push(r.points[
|
|
294
|
+
for (let c = 0; c + 1 < r.points.length; c += 2)
|
|
295
|
+
s.push(r.points[c]), a.push(r.points[c + 1]);
|
|
295
296
|
}
|
|
296
297
|
if (s.length > 0) {
|
|
297
|
-
const r = Math.min(...s),
|
|
298
|
-
i = { x: t.x + r, y: t.y +
|
|
298
|
+
const r = Math.min(...s), c = Math.min(...a);
|
|
299
|
+
i = { x: t.x + r, y: t.y + c, width: Math.max(...s) - r, height: Math.max(...a) - c };
|
|
299
300
|
}
|
|
300
301
|
}
|
|
301
302
|
const o = (t.lineWidth ?? 1) + 2 + 3 * Math.max(t.blur ?? 0, t.glow ?? 0, t.shadowBlur ?? 0) + Math.max(Math.abs(t.shadowX ?? 0), Math.abs(t.shadowY ?? 0));
|
|
@@ -309,8 +310,8 @@ class R {
|
|
|
309
310
|
t.fillStyle && (e.fillStyle = this.resolveFillStyle(e, t)), t.strokeStyle && (e.strokeStyle = t.strokeStyle), t.lineWidth !== void 0 && (e.lineWidth = t.lineWidth);
|
|
310
311
|
const i = B(t);
|
|
311
312
|
if (i && (e.filter = i), t.clipTop !== void 0 || t.clipRight !== void 0 || t.clipBottom !== void 0 || t.clipLeft !== void 0) {
|
|
312
|
-
const o = this.getTargetBounds(t), s = o.x + (t.clipLeft ?? 0) / 100 * o.width, a = o.x + o.width - (t.clipRight ?? 0) / 100 * o.width, r = o.y + (t.clipTop ?? 0) / 100 * o.height,
|
|
313
|
-
e.beginPath(), e.rect(s, r, Math.max(0, a - s), Math.max(0,
|
|
313
|
+
const o = this.getTargetBounds(t), s = o.x + (t.clipLeft ?? 0) / 100 * o.width, a = o.x + o.width - (t.clipRight ?? 0) / 100 * o.width, r = o.y + (t.clipTop ?? 0) / 100 * o.height, c = o.y + o.height - (t.clipBottom ?? 0) / 100 * o.height;
|
|
314
|
+
e.beginPath(), e.rect(s, r, Math.max(0, a - s), Math.max(0, c - r)), e.clip();
|
|
314
315
|
}
|
|
315
316
|
switch (t.type) {
|
|
316
317
|
case "rect":
|
|
@@ -350,7 +351,7 @@ class R {
|
|
|
350
351
|
* Create a canvas linear gradient from a LinearGradient definition.
|
|
351
352
|
*/
|
|
352
353
|
createLinearGradient(e, t, i) {
|
|
353
|
-
const o = (t.angle - 90) * (Math.PI / 180), s = i.x + i.width / 2, a = i.y + i.height / 2, r = Math.max(i.width, i.height),
|
|
354
|
+
const o = (t.angle - 90) * (Math.PI / 180), s = i.x + i.width / 2, a = i.y + i.height / 2, r = Math.max(i.width, i.height), c = s - Math.cos(o) * r / 2, l = a - Math.sin(o) * r / 2, h = s + Math.cos(o) * r / 2, f = a + Math.sin(o) * r / 2, m = e.createLinearGradient(c, l, h, f);
|
|
354
355
|
for (const u of t.stops)
|
|
355
356
|
m.addColorStop(u.offset, u.color);
|
|
356
357
|
return m;
|
|
@@ -360,8 +361,8 @@ class R {
|
|
|
360
361
|
*/
|
|
361
362
|
createRadialGradient(e, t, i) {
|
|
362
363
|
const o = i.x + i.width * t.centerX, s = i.y + i.height * t.centerY, a = Math.max(i.width, i.height) * t.radius, r = e.createRadialGradient(o, s, 0, o, s, a);
|
|
363
|
-
for (const
|
|
364
|
-
r.addColorStop(
|
|
364
|
+
for (const c of t.stops)
|
|
365
|
+
r.addColorStop(c.offset, c.color);
|
|
365
366
|
return r;
|
|
366
367
|
}
|
|
367
368
|
/**
|
|
@@ -419,7 +420,7 @@ class R {
|
|
|
419
420
|
() => {
|
|
420
421
|
e.beginPath(), t.borderRadius && t.borderRadius > 0 ? this.roundRect(e, i, o, s, a, t.borderRadius) : e.rect(i, o, s, a), e.fill();
|
|
421
422
|
},
|
|
422
|
-
(r,
|
|
423
|
+
(r, c) => M(e, ne(i, o, s, a, t.borderRadius), r, c)
|
|
423
424
|
);
|
|
424
425
|
}
|
|
425
426
|
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();
|
|
@@ -458,10 +459,10 @@ class R {
|
|
|
458
459
|
const i = t.fontSize ?? 16, o = t.fontFamily ?? "sans-serif", s = t.fontWeight ?? 400;
|
|
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
|
-
const a = e.measureText(t.text).width, r = t.textAlign ?? "left",
|
|
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
463
|
for (const h of D(t.shine, t.fillStyle))
|
|
463
|
-
|
|
464
|
-
e.fillStyle =
|
|
464
|
+
l.addColorStop(h.offset, h.color);
|
|
465
|
+
e.fillStyle = l;
|
|
465
466
|
}
|
|
466
467
|
e.fillText(t.text, t.x, t.y);
|
|
467
468
|
}
|
|
@@ -480,7 +481,7 @@ class R {
|
|
|
480
481
|
e,
|
|
481
482
|
t,
|
|
482
483
|
void 0,
|
|
483
|
-
(s, a) =>
|
|
484
|
+
(s, a) => M(e, [{ kind: "line", points: i, length: o }], s, a)
|
|
484
485
|
);
|
|
485
486
|
}
|
|
486
487
|
e.beginPath(), e.moveTo(t.x, t.y), e.lineTo(t.x2, t.y2), t.strokeStyle && e.stroke(), e.closePath();
|
|
@@ -496,7 +497,7 @@ class R {
|
|
|
496
497
|
e,
|
|
497
498
|
t,
|
|
498
499
|
() => e.fill(i),
|
|
499
|
-
(o, s) =>
|
|
500
|
+
(o, s) => M(e, x(t.d), o, s)
|
|
500
501
|
);
|
|
501
502
|
t.fillStyle && e.fill(i), t.strokeStyle && e.stroke(i);
|
|
502
503
|
}
|
|
@@ -506,13 +507,13 @@ class R {
|
|
|
506
507
|
renderImage(e, t) {
|
|
507
508
|
if (!t.image) return;
|
|
508
509
|
t.opacity !== void 0 && (e.globalAlpha = t.opacity);
|
|
509
|
-
const { x: i, y: o, width: s, height: a } = t, r = t.objectFit ?? "fill",
|
|
510
|
+
const { x: i, y: o, width: s, height: a } = t, r = t.objectFit ?? "fill", c = t.borderRadius ?? 0, l = t.image, h = l.naturalWidth || l.videoWidth || l.width || s, f = l.naturalHeight || l.videoHeight || l.height || a;
|
|
510
511
|
let m = i, u = o, p = s, d = a;
|
|
511
512
|
if (r !== "fill" && h > 0 && f > 0) {
|
|
512
513
|
const y = r === "cover" ? Math.max(s / h, a / f) : Math.min(s / h, a / f);
|
|
513
514
|
p = h * y, d = f * y, m = i + (s - p) / 2, u = o + (a - d) / 2;
|
|
514
515
|
}
|
|
515
|
-
e.save(), e.beginPath(),
|
|
516
|
+
e.save(), e.beginPath(), c > 0 && typeof e.roundRect == "function" ? e.roundRect(i, o, s, a, c) : e.rect(i, o, s, a), e.clip(), e.drawImage(t.image, m, u, p, d), e.restore();
|
|
516
517
|
}
|
|
517
518
|
/**
|
|
518
519
|
* Render a custom target by calling its draw function in local coordinates.
|
|
@@ -623,58 +624,58 @@ class R {
|
|
|
623
624
|
function re(n, e) {
|
|
624
625
|
const t = n.length / 4, i = new Float32Array(t * 3), o = Math.min(0.999, Math.max(0, e));
|
|
625
626
|
for (let s = 0; s < t; s++) {
|
|
626
|
-
const a = n[s * 4] / 255, r = n[s * 4 + 1] / 255,
|
|
627
|
+
const a = n[s * 4] / 255, r = n[s * 4 + 1] / 255, c = n[s * 4 + 2] / 255, l = n[s * 4 + 3] / 255, h = Math.max(a, r, c);
|
|
627
628
|
if (h <= o) continue;
|
|
628
|
-
const f = (h - o) / (1 - o) *
|
|
629
|
-
i[s * 3] = a * f, i[s * 3 + 1] = r * f, i[s * 3 + 2] =
|
|
629
|
+
const f = (h - o) / (1 - o) * l / h;
|
|
630
|
+
i[s * 3] = a * f, i[s * 3 + 1] = r * f, i[s * 3 + 2] = c * f;
|
|
630
631
|
}
|
|
631
632
|
return i;
|
|
632
633
|
}
|
|
633
|
-
function
|
|
634
|
-
const s = new Float32Array(n.length), a = o ? t : e, r = o ? e : t,
|
|
634
|
+
function E(n, e, t, i, o) {
|
|
635
|
+
const s = new Float32Array(n.length), a = o ? t : e, r = o ? e : t, c = (h, f) => (o ? h * e + f : f * e + h) * 3, l = i * 2 + 1;
|
|
635
636
|
for (let h = 0; h < a; h++)
|
|
636
637
|
for (let f = 0; f < 3; f++) {
|
|
637
638
|
let m = 0;
|
|
638
|
-
for (let u = -i; u <= i; u++) m += n[
|
|
639
|
+
for (let u = -i; u <= i; u++) m += n[c(h, Math.min(r - 1, Math.max(0, u))) + f];
|
|
639
640
|
for (let u = 0; u < r; u++) {
|
|
640
|
-
s[
|
|
641
|
-
const p = n[
|
|
641
|
+
s[c(h, u) + f] = m / l;
|
|
642
|
+
const p = n[c(h, Math.max(0, u - i)) + f], d = n[c(h, Math.min(r - 1, u + i + 1)) + f];
|
|
642
643
|
m += d - p;
|
|
643
644
|
}
|
|
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++)
|
|
651
|
-
s =
|
|
652
|
+
s = E(s, e, t, o, !0), s = E(s, e, t, o, !1);
|
|
652
653
|
return s;
|
|
653
654
|
}
|
|
654
|
-
function
|
|
655
|
+
function xe(n, e = {}) {
|
|
655
656
|
const t = n.canvas, i = t.width, o = t.height;
|
|
656
657
|
if (!(i > 0 && o > 0)) return;
|
|
657
|
-
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)),
|
|
658
|
-
if (!
|
|
659
|
-
|
|
660
|
-
const h = re(
|
|
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");
|
|
659
|
+
if (!c || !l) return;
|
|
660
|
+
l.imageSmoothingEnabled = !0, l.drawImage(n.canvas, 0, 0, a, r);
|
|
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
|
-
for (let
|
|
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;
|
|
664
665
|
}
|
|
665
|
-
|
|
666
|
+
l.putImageData(d, 0, 0), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalCompositeOperation = "lighter", n.globalAlpha = Math.max(0, e.strength ?? 0.9), n.imageSmoothingEnabled = !0, n.drawImage(c, 0, 0, i, o), n.restore();
|
|
666
667
|
}
|
|
667
|
-
function
|
|
668
|
+
function Re(n, e, t) {
|
|
668
669
|
const i = t.width ?? 6, o = t.taper ?? 1, s = t.fade ?? 1, a = t.opacity ?? 1, r = t.blend === "add";
|
|
669
670
|
if (n.save(), e.length >= 2) {
|
|
670
|
-
const
|
|
671
|
-
r ? (n.globalCompositeOperation = "lighter",
|
|
671
|
+
const l = le(e, i, o, s, a);
|
|
672
|
+
r ? (n.globalCompositeOperation = "lighter", A(n, l, t.color)) : ce(n, l, t.color);
|
|
672
673
|
}
|
|
673
|
-
const
|
|
674
|
-
if (t.head &&
|
|
674
|
+
const c = e[e.length - 1];
|
|
675
|
+
if (t.head && c && t.head.radius > 0) {
|
|
675
676
|
r && (n.globalCompositeOperation = "lighter");
|
|
676
|
-
const
|
|
677
|
-
h.addColorStop(0,
|
|
677
|
+
const l = t.head.color ?? t.color, h = n.createRadialGradient(c.at.x, c.at.y, 0, c.at.x, c.at.y, t.head.radius);
|
|
678
|
+
h.addColorStop(0, l), h.addColorStop(0.35, l), h.addColorStop(1, ae(n, l)), n.globalAlpha = a, n.fillStyle = h, n.beginPath(), n.arc(c.at.x, c.at.y, t.head.radius, 0, Math.PI * 2), n.fill();
|
|
678
679
|
}
|
|
679
680
|
n.restore();
|
|
680
681
|
}
|
|
@@ -685,71 +686,44 @@ function ae(n, e) {
|
|
|
685
686
|
const o = /^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i.exec(t);
|
|
686
687
|
return o ? `rgba(${o[1]}, ${o[2]}, ${o[3]}, 0)` : "rgba(0, 0, 0, 0)";
|
|
687
688
|
}
|
|
688
|
-
function
|
|
689
|
-
const s = n.map((
|
|
690
|
-
for (let
|
|
691
|
-
const h = (n[
|
|
689
|
+
function le(n, e, t, i, o) {
|
|
690
|
+
const s = n.map((l) => ({ x: l.at.x, y: l.at.y, width: e * (1 - t * l.age) })), a = K(s), r = ee(s) ?? void 0, c = [];
|
|
691
|
+
for (let l = 0; l + 1 < n.length; l++) {
|
|
692
|
+
const h = (n[l].age + n[l + 1].age) / 2, f = o * (1 - i * h);
|
|
692
693
|
if (f <= 0) continue;
|
|
693
|
-
const m =
|
|
694
|
-
|
|
694
|
+
const m = l + 2 === n.length;
|
|
695
|
+
c.push({ corners: [a.left[l], a.left[l + 1], a.right[l + 1], a.right[l]], alpha: f, ...m && r && { cap: r } });
|
|
695
696
|
}
|
|
696
|
-
return
|
|
697
|
+
return c;
|
|
697
698
|
}
|
|
698
|
-
function
|
|
699
|
+
function A(n, e, t) {
|
|
699
700
|
n.fillStyle = t;
|
|
700
701
|
for (const i of e) {
|
|
701
702
|
const [o, s, a, r] = i.corners;
|
|
702
703
|
n.globalAlpha = Math.min(1, i.alpha), n.beginPath(), n.moveTo(o.x, o.y), n.lineTo(s.x, s.y), i.cap && n.arc(i.cap.x, i.cap.y, i.cap.radius, i.cap.start, i.cap.start - Math.PI, !0), n.lineTo(a.x, a.y), n.lineTo(r.x, r.y), n.closePath(), n.fill();
|
|
703
704
|
}
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function ce(n, e, t) {
|
|
706
707
|
const i = typeof n.getTransform == "function" ? n.getTransform() : null, o = (d) => i ? { x: i.a * d.x + i.c * d.y + i.e, y: i.b * d.x + i.d * d.y + i.f } : d, s = i ? Math.sqrt(Math.abs(i.a * i.d - i.b * i.c)) : 1, a = e.map((d) => ({
|
|
707
708
|
...d,
|
|
708
709
|
corners: d.corners.map(o),
|
|
709
710
|
...d.cap && { cap: { ...d.cap, ...o(d.cap), radius: d.cap.radius * s, start: d.cap.start + (i ? Math.atan2(i.b, i.a) : 0) } }
|
|
710
711
|
}));
|
|
711
|
-
let r = 1 / 0,
|
|
712
|
+
let r = 1 / 0, c = 1 / 0, l = -1 / 0, h = -1 / 0;
|
|
712
713
|
for (const d of a) {
|
|
713
714
|
const y = d.cap ? [{ x: d.cap.x - d.cap.radius, y: d.cap.y - d.cap.radius }, { x: d.cap.x + d.cap.radius, y: d.cap.y + d.cap.radius }] : [];
|
|
714
|
-
for (const
|
|
715
|
-
r = Math.min(r,
|
|
715
|
+
for (const w of [...d.corners, ...y])
|
|
716
|
+
r = Math.min(r, w.x), c = Math.min(c, w.y), l = Math.max(l, w.x), h = Math.max(h, w.y);
|
|
716
717
|
}
|
|
717
|
-
if (!(
|
|
718
|
-
const f = Math.floor(r) - 1, m = Math.floor(
|
|
718
|
+
if (!(l > r && h > c)) return;
|
|
719
|
+
const f = Math.floor(r) - 1, m = Math.floor(c) - 1, u = i ? g(n, Math.ceil(l) + 1 - f, Math.ceil(h) + 1 - m) : null, p = u?.getContext("2d");
|
|
719
720
|
if (!u || !p) {
|
|
720
|
-
|
|
721
|
+
A(n, e, t);
|
|
721
722
|
return;
|
|
722
723
|
}
|
|
723
|
-
p.translate(-f, -m), p.globalCompositeOperation = "lighter",
|
|
724
|
-
}
|
|
725
|
-
const he = { x: 0, y: 0, scale: 1, rotate: 0, shakeX: 0, shakeY: 0, shakeRotate: 0 };
|
|
726
|
-
function Ae(n) {
|
|
727
|
-
const e = (t) => {
|
|
728
|
-
const i = n?.get(t);
|
|
729
|
-
return typeof i == "number" ? i : he[t];
|
|
730
|
-
};
|
|
731
|
-
return {
|
|
732
|
-
x: e("x"),
|
|
733
|
-
y: e("y"),
|
|
734
|
-
scale: e("scale"),
|
|
735
|
-
rotate: e("rotate"),
|
|
736
|
-
shakeX: e("shakeX"),
|
|
737
|
-
shakeY: e("shakeY"),
|
|
738
|
-
shakeRotate: e("shakeRotate")
|
|
739
|
-
};
|
|
724
|
+
p.translate(-f, -m), p.globalCompositeOperation = "lighter", A(p, a, t), n.save(), n.setTransform(1, 0, 0, 1, 0, 0), n.globalAlpha = 1, n.drawImage(u, f, m), n.restore();
|
|
740
725
|
}
|
|
741
|
-
|
|
742
|
-
const i = t.width / 2, o = t.height / 2, a = 1 + 2 * Math.max(Math.abs(e.shakeX), Math.abs(e.shakeY)) / Math.max(1, Math.min(t.width, t.height));
|
|
743
|
-
n.translate(i + e.x + e.shakeX, o + e.y + e.shakeY), n.rotate((e.rotate + e.shakeRotate) * Math.PI / 180), n.scale(e.scale * a, e.scale * a), n.translate(-i, -o);
|
|
744
|
-
}
|
|
745
|
-
function Xe(n, e, t) {
|
|
746
|
-
const i = e.width / 2, o = e.height / 2, s = (n.rotate + n.shakeRotate) * Math.PI / 180, a = (t.x - i) * n.scale, r = (t.y - o) * n.scale;
|
|
747
|
-
return {
|
|
748
|
-
x: i + n.x + n.shakeX + a * Math.cos(s) - r * Math.sin(s),
|
|
749
|
-
y: o + n.y + n.shakeY + a * Math.sin(s) + r * Math.cos(s)
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
const v = "http://www.w3.org/2000/svg", fe = /* @__PURE__ */ new Set([
|
|
726
|
+
const S = "http://www.w3.org/2000/svg", he = /* @__PURE__ */ new Set([
|
|
753
727
|
"fill",
|
|
754
728
|
"stroke",
|
|
755
729
|
"d",
|
|
@@ -769,7 +743,7 @@ const v = "http://www.w3.org/2000/svg", fe = /* @__PURE__ */ new Set([
|
|
|
769
743
|
"height",
|
|
770
744
|
"viewBox",
|
|
771
745
|
"preserveAspectRatio"
|
|
772
|
-
]),
|
|
746
|
+
]), X = {
|
|
773
747
|
strokeWidth: "stroke-width",
|
|
774
748
|
strokeLinecap: "stroke-linecap",
|
|
775
749
|
strokeLinejoin: "stroke-linejoin",
|
|
@@ -780,7 +754,7 @@ const v = "http://www.w3.org/2000/svg", fe = /* @__PURE__ */ new Set([
|
|
|
780
754
|
strokeOpacity: "stroke-opacity",
|
|
781
755
|
borderRadius: "rx"
|
|
782
756
|
// Map CSS borderRadius to SVG rx
|
|
783
|
-
},
|
|
757
|
+
}, fe = /* @__PURE__ */ new Set([
|
|
784
758
|
"x",
|
|
785
759
|
// Position x treated as translateX
|
|
786
760
|
"y",
|
|
@@ -801,8 +775,8 @@ const v = "http://www.w3.org/2000/svg", fe = /* @__PURE__ */ new Set([
|
|
|
801
775
|
"motionPathX",
|
|
802
776
|
"motionPathY",
|
|
803
777
|
"motionPathRotate"
|
|
804
|
-
]),
|
|
805
|
-
class
|
|
778
|
+
]), ue = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]);
|
|
779
|
+
class Ae {
|
|
806
780
|
targets = /* @__PURE__ */ new Map();
|
|
807
781
|
/**
|
|
808
782
|
* Register an SVG element as an animation target.
|
|
@@ -844,24 +818,24 @@ class Ee {
|
|
|
844
818
|
const i = {};
|
|
845
819
|
let o = null;
|
|
846
820
|
const s = {}, a = {}, r = {};
|
|
847
|
-
let
|
|
848
|
-
for (const [
|
|
849
|
-
|
|
821
|
+
let c = !1;
|
|
822
|
+
for (const [l, h] of t)
|
|
823
|
+
l !== "drawOn" && (fe.has(l) ? i[l] = h : l === "quaternion" ? o = q(h) : l === "originX" || l === "originY" ? typeof h == "number" && (s[l] = h) : l === "perspective" ? typeof h == "number" && (i.perspective = h) : ue.has(l) ? typeof h == "number" && (a[l] = h) : j.has(l) ? (r[l] = h, c = !0) : l === "text" ? typeof h == "string" && Z(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));
|
|
850
824
|
if (Object.keys(i).length > 0 || o) {
|
|
851
|
-
const
|
|
852
|
-
e.style.transform =
|
|
825
|
+
const l = this.buildCssTransformString(i, o);
|
|
826
|
+
e.style.transform = l, J(e);
|
|
853
827
|
}
|
|
854
828
|
if (Object.keys(s).length > 0) {
|
|
855
|
-
const
|
|
856
|
-
|
|
829
|
+
const l = e.style;
|
|
830
|
+
l.transformBox = "fill-box", l.transformOrigin = `${s.originX ?? 50}% ${s.originY ?? 50}%`;
|
|
857
831
|
}
|
|
858
832
|
if (Object.keys(a).length > 0) {
|
|
859
|
-
const
|
|
860
|
-
e.style.clipPath = `inset(${
|
|
833
|
+
const l = a.clipTop ?? 0, h = a.clipRight ?? 0, f = a.clipBottom ?? 0, m = a.clipLeft ?? 0;
|
|
834
|
+
e.style.clipPath = `inset(${l}% ${h}% ${f}% ${m}%)`;
|
|
861
835
|
}
|
|
862
|
-
if (
|
|
863
|
-
const
|
|
864
|
-
|
|
836
|
+
if (c) {
|
|
837
|
+
const l = B(r);
|
|
838
|
+
l && (e.style.filter = l);
|
|
865
839
|
}
|
|
866
840
|
}
|
|
867
841
|
/**
|
|
@@ -876,8 +850,8 @@ class Ee {
|
|
|
876
850
|
if (a !== void 0 && i.push(`rotate(${a}deg)`), e.rotateX !== void 0 && i.push(`rotateX(${e.rotateX}deg)`), e.rotateY !== void 0 && i.push(`rotateY(${e.rotateY}deg)`), t && i.push(t), e.scale !== void 0)
|
|
877
851
|
i.push(`scale(${e.scale})`);
|
|
878
852
|
else if (e.scaleX !== void 0 || e.scaleY !== void 0) {
|
|
879
|
-
const r = e.scaleX ?? 1,
|
|
880
|
-
i.push(`scale(${r}, ${
|
|
853
|
+
const r = e.scaleX ?? 1, c = e.scaleY ?? 1;
|
|
854
|
+
i.push(`scale(${r}, ${c})`);
|
|
881
855
|
}
|
|
882
856
|
return e.skewX !== void 0 && i.push(`skewX(${e.skewX}deg)`), e.skewY !== void 0 && i.push(`skewY(${e.skewY}deg)`), i.join(" ");
|
|
883
857
|
}
|
|
@@ -896,23 +870,23 @@ class Ee {
|
|
|
896
870
|
s.dataset.shineBase || (s.dataset.shineBase = e.getAttribute("fill") || "#000000");
|
|
897
871
|
const a = s.dataset.shineBase;
|
|
898
872
|
let r = i.querySelector("defs");
|
|
899
|
-
r || (r = o.createElementNS(
|
|
900
|
-
let
|
|
901
|
-
for (
|
|
873
|
+
r || (r = o.createElementNS(S, "defs"), i.insertBefore(r, i.firstChild));
|
|
874
|
+
let c = s.dataset.shineGrad, l = c ? r.querySelector(`#${c}`) : null;
|
|
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);
|
|
902
876
|
for (const h of D(t, a)) {
|
|
903
|
-
const f = o.createElementNS(
|
|
904
|
-
f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color),
|
|
877
|
+
const f = o.createElementNS(S, "stop");
|
|
878
|
+
f.setAttribute("offset", String(h.offset)), f.setAttribute("stop-color", h.color), l.appendChild(f);
|
|
905
879
|
}
|
|
906
|
-
e.setAttribute("fill", `url(#${
|
|
880
|
+
e.setAttribute("fill", `url(#${c})`);
|
|
907
881
|
}
|
|
908
882
|
applyAttribute(e, t, i) {
|
|
909
883
|
let o = t;
|
|
910
|
-
|
|
884
|
+
X[t] ? o = X[t] : he.has(t) && (o = t);
|
|
911
885
|
const s = Array.isArray(i) ? i.join(" ") : String(i);
|
|
912
886
|
e.setAttribute(o, s);
|
|
913
887
|
}
|
|
914
888
|
}
|
|
915
|
-
const
|
|
889
|
+
const de = `
|
|
916
890
|
attribute vec2 a_position;
|
|
917
891
|
attribute vec2 a_texCoord;
|
|
918
892
|
uniform mat4 u_matrix;
|
|
@@ -922,7 +896,7 @@ void main() {
|
|
|
922
896
|
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
923
897
|
v_texCoord = a_texCoord;
|
|
924
898
|
}
|
|
925
|
-
`,
|
|
899
|
+
`, pe = `
|
|
926
900
|
precision mediump float;
|
|
927
901
|
uniform vec4 u_color;
|
|
928
902
|
uniform sampler2D u_texture;
|
|
@@ -933,7 +907,7 @@ void main() {
|
|
|
933
907
|
vec4 color = u_useTexture ? texture2D(u_texture, v_texCoord) : u_color;
|
|
934
908
|
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
935
909
|
}
|
|
936
|
-
`,
|
|
910
|
+
`, me = /* @__PURE__ */ new Set([
|
|
937
911
|
"x",
|
|
938
912
|
"y",
|
|
939
913
|
"width",
|
|
@@ -954,7 +928,7 @@ void main() {
|
|
|
954
928
|
"motionPathY",
|
|
955
929
|
"motionPathRotate"
|
|
956
930
|
]);
|
|
957
|
-
class
|
|
931
|
+
class ge {
|
|
958
932
|
gl;
|
|
959
933
|
program;
|
|
960
934
|
positionBuffer;
|
|
@@ -965,7 +939,7 @@ class Ye {
|
|
|
965
939
|
basePositions = /* @__PURE__ */ new Map();
|
|
966
940
|
locations;
|
|
967
941
|
constructor(e) {
|
|
968
|
-
this.gl = e, this.program =
|
|
942
|
+
this.gl = e, this.program = be(e, de, pe), this.locations = {
|
|
969
943
|
position: e.getAttribLocation(this.program, "a_position"),
|
|
970
944
|
texCoord: e.getAttribLocation(this.program, "a_texCoord"),
|
|
971
945
|
matrix: e.getUniformLocation(this.program, "u_matrix"),
|
|
@@ -973,7 +947,7 @@ class Ye {
|
|
|
973
947
|
texture: e.getUniformLocation(this.program, "u_texture"),
|
|
974
948
|
useTexture: e.getUniformLocation(this.program, "u_useTexture"),
|
|
975
949
|
opacity: e.getUniformLocation(this.program, "u_opacity")
|
|
976
|
-
}, 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]);
|
|
977
951
|
}
|
|
978
952
|
registerTarget(e, t) {
|
|
979
953
|
this.targets.set(e, t), this.basePositions.set(e, { x: t.x, y: t.y });
|
|
@@ -1013,7 +987,7 @@ class Ye {
|
|
|
1013
987
|
e.rotate = o;
|
|
1014
988
|
return;
|
|
1015
989
|
}
|
|
1016
|
-
if (
|
|
990
|
+
if (me.has(i)) {
|
|
1017
991
|
e[i] = o;
|
|
1018
992
|
return;
|
|
1019
993
|
}
|
|
@@ -1023,20 +997,20 @@ class Ye {
|
|
|
1023
997
|
/** Draw every registered target. */
|
|
1024
998
|
render() {
|
|
1025
999
|
const e = this.gl, { width: t, height: i } = e.canvas;
|
|
1026
|
-
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),
|
|
1000
|
+
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), Y(e, this.positionBuffer, this.locations.position), Y(e, this.texCoordBuffer, this.locations.texCoord);
|
|
1027
1001
|
for (const [o, s] of this.targets)
|
|
1028
1002
|
this.drawTarget(o, s, t, i);
|
|
1029
1003
|
}
|
|
1030
1004
|
drawTarget(e, t, i, o) {
|
|
1031
1005
|
const s = this.gl;
|
|
1032
1006
|
if (t.backfaceVisibility === "hidden" && O(G(t))) return;
|
|
1033
|
-
const a =
|
|
1007
|
+
const a = ye(t, i, o);
|
|
1034
1008
|
if (s.uniformMatrix4fv(this.locations.matrix, !1, a), s.uniform1f(this.locations.opacity, t.opacity ?? 1), t.texture)
|
|
1035
1009
|
s.bindTexture(s.TEXTURE_2D, this.textureFor(e, t.texture)), s.uniform1i(this.locations.useTexture, 1), s.uniform1i(this.locations.texture, 0);
|
|
1036
1010
|
else {
|
|
1037
1011
|
s.uniform1i(this.locations.useTexture, 0);
|
|
1038
|
-
const [r,
|
|
1039
|
-
s.uniform4f(this.locations.color, r,
|
|
1012
|
+
const [r, c, l] = we(t.fill ?? "#ffffff");
|
|
1013
|
+
s.uniform4f(this.locations.color, r, c, l, 1);
|
|
1040
1014
|
}
|
|
1041
1015
|
s.drawArrays(s.TRIANGLES, 0, 6);
|
|
1042
1016
|
}
|
|
@@ -1051,32 +1025,32 @@ class Ye {
|
|
|
1051
1025
|
this.clearTargets(), this.gl.deleteProgram(this.program), this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteBuffer(this.texCoordBuffer);
|
|
1052
1026
|
}
|
|
1053
1027
|
}
|
|
1054
|
-
function
|
|
1055
|
-
const i = (n.scale ?? n.scaleX ?? 1) * n.width, o = (n.scale ?? n.scaleY ?? 1) * n.height, s = (n.originX ?? 50) / 100, a = (n.originY ?? 50) / 100, r = (n.rotate ?? 0) * Math.PI / 180,
|
|
1028
|
+
function ke(n, e, t) {
|
|
1029
|
+
const i = (n.scale ?? n.scaleX ?? 1) * n.width, o = (n.scale ?? n.scaleY ?? 1) * n.height, s = (n.originX ?? 50) / 100, a = (n.originY ?? 50) / 100, r = (n.rotate ?? 0) * Math.PI / 180, c = Math.cos(r), l = Math.sin(r), h = -s, f = -a, m = c * i, u = l * i, p = -l * o, d = c * o, y = n.x + m * h + p * f, w = n.y + u * h + d * f, v = 2 / e, P = -2 / t;
|
|
1056
1030
|
return new Float32Array([
|
|
1057
|
-
m *
|
|
1031
|
+
m * v,
|
|
1058
1032
|
u * P,
|
|
1059
1033
|
0,
|
|
1060
|
-
p *
|
|
1034
|
+
p * v,
|
|
1061
1035
|
d * P,
|
|
1062
1036
|
0,
|
|
1063
|
-
y *
|
|
1064
|
-
|
|
1037
|
+
y * v - 1,
|
|
1038
|
+
w * P + 1,
|
|
1065
1039
|
1
|
|
1066
1040
|
]);
|
|
1067
1041
|
}
|
|
1068
1042
|
function G(n) {
|
|
1069
|
-
const e = (n.originX ?? 50) / 100, t = (n.originY ?? 50) / 100, i = { x: n.x, y: n.y }, o =
|
|
1070
|
-
|
|
1071
|
-
|
|
1043
|
+
const e = (n.originX ?? 50) / 100, t = (n.originY ?? 50) / 100, i = { x: n.x, y: n.y }, o = b.multiply(
|
|
1044
|
+
b.translation([n.x, n.y, 0]),
|
|
1045
|
+
b.multiply(b.scaling([n.width, n.height, 1]), b.translation([-e, -t, 0]))
|
|
1072
1046
|
);
|
|
1073
|
-
return
|
|
1047
|
+
return b.multiply(_(n, { x: 0, y: 0 }, i), o);
|
|
1074
1048
|
}
|
|
1075
|
-
function
|
|
1049
|
+
function ye(n, e, t) {
|
|
1076
1050
|
const i = [2 / e, 0, 0, 0, 0, -2 / t, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1];
|
|
1077
|
-
return new Float32Array(
|
|
1051
|
+
return new Float32Array(b.multiply(i, G(n)));
|
|
1078
1052
|
}
|
|
1079
|
-
function
|
|
1053
|
+
function we(n) {
|
|
1080
1054
|
const e = n.trim().replace("#", "");
|
|
1081
1055
|
return e.length === 3 ? [
|
|
1082
1056
|
Number.parseInt(e[0] + e[0], 16) / 255,
|
|
@@ -1088,57 +1062,57 @@ function Te(n) {
|
|
|
1088
1062
|
Number.parseInt(e.slice(4, 6), 16) / 255
|
|
1089
1063
|
] : [1, 1, 1];
|
|
1090
1064
|
}
|
|
1091
|
-
function
|
|
1065
|
+
function be(n, e, t) {
|
|
1092
1066
|
const i = n.createProgram();
|
|
1093
1067
|
if (!i) throw new Error("WebGLAdapter: could not create a program");
|
|
1094
|
-
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))
|
|
1095
1069
|
throw new Error(`WebGLAdapter: program link failed — ${n.getProgramInfoLog(i)}`);
|
|
1096
1070
|
return i;
|
|
1097
1071
|
}
|
|
1098
|
-
function
|
|
1072
|
+
function I(n, e, t) {
|
|
1099
1073
|
const i = n.createShader(e);
|
|
1100
1074
|
if (!i) throw new Error("WebGLAdapter: could not create a shader");
|
|
1101
1075
|
if (n.shaderSource(i, t), n.compileShader(i), !n.getShaderParameter(i, n.COMPILE_STATUS))
|
|
1102
1076
|
throw new Error(`WebGLAdapter: shader compile failed — ${n.getShaderInfoLog(i)}`);
|
|
1103
1077
|
return i;
|
|
1104
1078
|
}
|
|
1105
|
-
function
|
|
1079
|
+
function $(n, e) {
|
|
1106
1080
|
const t = n.createBuffer();
|
|
1107
1081
|
if (!t) throw new Error("WebGLAdapter: could not create a buffer");
|
|
1108
1082
|
return n.bindBuffer(n.ARRAY_BUFFER, t), n.bufferData(n.ARRAY_BUFFER, new Float32Array(e), n.STATIC_DRAW), t;
|
|
1109
1083
|
}
|
|
1110
|
-
function
|
|
1084
|
+
function Y(n, e, t) {
|
|
1111
1085
|
t < 0 || (n.bindBuffer(n.ARRAY_BUFFER, e), n.enableVertexAttribArray(t), n.vertexAttribPointer(t, 2, n.FLOAT, !1, 0, 0));
|
|
1112
1086
|
}
|
|
1113
1087
|
export {
|
|
1114
1088
|
R as CanvasAdapter,
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1089
|
+
Xe as DOMAdapter,
|
|
1090
|
+
Be as IDENTITY_CAMERA,
|
|
1091
|
+
Ae as SVGAdapter,
|
|
1092
|
+
ge as WebGLAdapter,
|
|
1093
|
+
xe as applyBloom,
|
|
1094
|
+
Le as applyCamera,
|
|
1095
|
+
$e as boilFrame,
|
|
1096
|
+
C as boxBlur,
|
|
1123
1097
|
re as brightPass,
|
|
1124
1098
|
se as buildFlipTracks,
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1099
|
+
Fe as cameraFromValues,
|
|
1100
|
+
De as cameraPoint,
|
|
1101
|
+
g as canvasLike,
|
|
1102
|
+
M as drawOutline,
|
|
1103
|
+
Re as drawTrail,
|
|
1104
|
+
Me as flip,
|
|
1105
|
+
Se as isGradient,
|
|
1106
|
+
we as parseColor,
|
|
1133
1107
|
te as partialPath,
|
|
1134
|
-
|
|
1108
|
+
Ye as pathLength,
|
|
1135
1109
|
x as pathOutline,
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1110
|
+
_e as pointAlong,
|
|
1111
|
+
ke as quadMatrix,
|
|
1112
|
+
ye as quadMatrix3d,
|
|
1139
1113
|
oe as recordFlipState,
|
|
1140
1114
|
ne as rectOutline,
|
|
1141
1115
|
Z as setTextContent,
|
|
1142
1116
|
ie as sketchPen,
|
|
1143
|
-
|
|
1117
|
+
le as trailQuads
|
|
1144
1118
|
};
|