@pixodesk/svg-animator-web 1.0.18 → 1.0.19
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/dist/index.cjs +212 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -18
- package/dist/index.d.ts +60 -18
- package/dist/index.js +209 -118
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.umd.js +209 -118
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1035,8 +1035,9 @@ var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
|
1035
1035
|
gradientTransform: px.string().optional()
|
|
1036
1036
|
}));
|
|
1037
1037
|
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
1038
|
-
var
|
|
1039
|
-
|
|
1038
|
+
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
1039
|
+
path: px.string(),
|
|
1040
|
+
pathOverflow: px.string().optional(),
|
|
1040
1041
|
lengthAdjust: px.string().optional(),
|
|
1041
1042
|
method: px.string().optional(),
|
|
1042
1043
|
spacing: px.string().optional(),
|
|
@@ -1055,7 +1056,7 @@ var PxEffectsSchema = implementsInterface()(px.object({
|
|
|
1055
1056
|
isCombinedShape: px.boolean().optional(),
|
|
1056
1057
|
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
1057
1058
|
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
1058
|
-
|
|
1059
|
+
textPath: PxTextPathEffectSchema.optional(),
|
|
1059
1060
|
text: PxTextEffectSchema.optional()
|
|
1060
1061
|
}));
|
|
1061
1062
|
function validateNodeEffects(root, opts) {
|
|
@@ -1928,103 +1929,6 @@ function remapKeyframeTimesOnly(node, start, stretch) {
|
|
|
1928
1929
|
}
|
|
1929
1930
|
}
|
|
1930
1931
|
|
|
1931
|
-
// src/effects/textAlongPathEffect.ts
|
|
1932
|
-
function applyTextAlongPathEffect(node, fx, _ctx) {
|
|
1933
|
-
var _a;
|
|
1934
|
-
if (!fx) return node;
|
|
1935
|
-
const href = typeof fx.href === "string" && !fx.href.startsWith("#") ? "#" + fx.href : fx.href;
|
|
1936
|
-
const textPath = {
|
|
1937
|
-
type: "textPath",
|
|
1938
|
-
href,
|
|
1939
|
-
children: (_a = node.children) != null ? _a : []
|
|
1940
|
-
};
|
|
1941
|
-
if (fx.lengthAdjust !== void 0) textPath.lengthAdjust = fx.lengthAdjust;
|
|
1942
|
-
if (fx.method !== void 0) textPath.method = fx.method;
|
|
1943
|
-
if (fx.spacing !== void 0) textPath.spacing = fx.spacing;
|
|
1944
|
-
applyAnimatableNumber(textPath, "startOffset", fx.startOffset);
|
|
1945
|
-
applyAnimatableNumber(textPath, "textLength", fx.textLength);
|
|
1946
|
-
node.children = [textPath];
|
|
1947
|
-
return node;
|
|
1948
|
-
}
|
|
1949
|
-
function applyAnimatableNumber(node, attrName, raw) {
|
|
1950
|
-
if (raw === void 0 || raw === null) return;
|
|
1951
|
-
if (typeof raw === "number") {
|
|
1952
|
-
node[attrName] = String(raw);
|
|
1953
|
-
return;
|
|
1954
|
-
}
|
|
1955
|
-
if (typeof raw === "object" && raw !== null) {
|
|
1956
|
-
const obj = raw;
|
|
1957
|
-
if (Array.isArray(obj.keyframes)) {
|
|
1958
|
-
const prevAnimate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
1959
|
-
const animate = __spreadValues({}, prevAnimate || {});
|
|
1960
|
-
const block = { keyframes: obj.keyframes };
|
|
1961
|
-
if (obj.loop !== void 0) block.loop = obj.loop;
|
|
1962
|
-
animate[attrName] = block;
|
|
1963
|
-
node.animate = animate;
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
if (typeof obj.value === "number") {
|
|
1967
|
-
node[attrName] = String(obj.value);
|
|
1968
|
-
return;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
// src/effects/elementFactory.ts
|
|
1974
|
-
var jsonElementFactory = (type, props, children) => {
|
|
1975
|
-
const node = { type };
|
|
1976
|
-
for (const k in props) if (props[k] !== void 0) node[k] = props[k];
|
|
1977
|
-
const arr = Array.isArray(children) ? children.filter((c) => c != null) : children != null ? [children] : [];
|
|
1978
|
-
if (arr.length) node.children = arr;
|
|
1979
|
-
return node;
|
|
1980
|
-
};
|
|
1981
|
-
|
|
1982
|
-
// src/effects/glyphPathBake.ts
|
|
1983
|
-
function fmt(v, decimals) {
|
|
1984
|
-
return Math.round(v) === v ? "" + Math.round(v) : v.toFixed(decimals);
|
|
1985
|
-
}
|
|
1986
|
-
function pack(nums, decimals) {
|
|
1987
|
-
let s = "";
|
|
1988
|
-
for (let i = 0; i < nums.length; i++) {
|
|
1989
|
-
const str2 = fmt(nums[i], decimals);
|
|
1990
|
-
if (i > 0 && str2.charCodeAt(0) !== 45) s += " ";
|
|
1991
|
-
s += str2;
|
|
1992
|
-
}
|
|
1993
|
-
return s;
|
|
1994
|
-
}
|
|
1995
|
-
function apply(m, x, y) {
|
|
1996
|
-
return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];
|
|
1997
|
-
}
|
|
1998
|
-
var TOKEN_RE = /([MLCQZ])|(-?\d*\.?\d+(?:e[-+]?\d+)?)/gi;
|
|
1999
|
-
function transformPathData(d, m, decimals = 2) {
|
|
2000
|
-
const tokens = [];
|
|
2001
|
-
let match;
|
|
2002
|
-
TOKEN_RE.lastIndex = 0;
|
|
2003
|
-
while ((match = TOKEN_RE.exec(d)) !== null) tokens.push(match[0]);
|
|
2004
|
-
let out = "";
|
|
2005
|
-
let i = 0;
|
|
2006
|
-
const num2 = () => parseFloat(tokens[i++]);
|
|
2007
|
-
while (i < tokens.length) {
|
|
2008
|
-
const cmd = tokens[i++];
|
|
2009
|
-
if (cmd === "M" || cmd === "L") {
|
|
2010
|
-
const [x, y] = apply(m, num2(), num2());
|
|
2011
|
-
out += cmd + pack([x, y], decimals);
|
|
2012
|
-
} else if (cmd === "C") {
|
|
2013
|
-
const [x1, y1] = apply(m, num2(), num2());
|
|
2014
|
-
const [x2, y2] = apply(m, num2(), num2());
|
|
2015
|
-
const [x, y] = apply(m, num2(), num2());
|
|
2016
|
-
out += "C" + pack([x1, y1, x2, y2, x, y], decimals);
|
|
2017
|
-
} else if (cmd === "Q") {
|
|
2018
|
-
const [x1, y1] = apply(m, num2(), num2());
|
|
2019
|
-
const [x, y] = apply(m, num2(), num2());
|
|
2020
|
-
out += "Q" + pack([x1, y1, x, y], decimals);
|
|
2021
|
-
} else if (cmd === "Z" || cmd === "z") {
|
|
2022
|
-
out += "Z";
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
return out;
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
1932
|
// src/PxAnimatorUtil.ts
|
|
2029
1933
|
function bezierToSvgPath(path) {
|
|
2030
1934
|
var _a, _b, _c, _d;
|
|
@@ -2569,6 +2473,7 @@ function createPathSampler(d) {
|
|
|
2569
2473
|
};
|
|
2570
2474
|
return {
|
|
2571
2475
|
totalLength,
|
|
2476
|
+
closed,
|
|
2572
2477
|
sampleAtDistance(dist) {
|
|
2573
2478
|
if (!closed && (dist < 0 || dist > totalLength)) {
|
|
2574
2479
|
const edge = dist < 0 ? 0 : totalLength;
|
|
@@ -2581,6 +2486,173 @@ function createPathSampler(d) {
|
|
|
2581
2486
|
};
|
|
2582
2487
|
}
|
|
2583
2488
|
|
|
2489
|
+
// src/effects/textPathEffect.ts
|
|
2490
|
+
var EXTEND_MARGIN_FRAC = 0.15;
|
|
2491
|
+
function numRange(v) {
|
|
2492
|
+
if (typeof v === "number") return { min: v, max: v };
|
|
2493
|
+
if (v && typeof v === "object") {
|
|
2494
|
+
const o = v;
|
|
2495
|
+
if (typeof o.value === "number") return { min: o.value, max: o.value };
|
|
2496
|
+
if (Array.isArray(o.keyframes) && o.keyframes.length) {
|
|
2497
|
+
const vals = o.keyframes.map((k) => Number(k.value) || 0);
|
|
2498
|
+
return { min: Math.min(...vals), max: Math.max(...vals) };
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
return { min: 0, max: 0 };
|
|
2502
|
+
}
|
|
2503
|
+
function estimateTextAdvance(node) {
|
|
2504
|
+
let chars = 0, maxFont = 16;
|
|
2505
|
+
const walk = (el) => {
|
|
2506
|
+
var _a, _b;
|
|
2507
|
+
const fs = parseFloat(String((_a = el.fontSize) != null ? _a : "")) || 0;
|
|
2508
|
+
if (fs) maxFont = Math.max(maxFont, fs);
|
|
2509
|
+
const t = (_b = el.text) != null ? _b : el.textContent;
|
|
2510
|
+
if (typeof t === "string") chars += t.length;
|
|
2511
|
+
if (el.children) for (const c of el.children) walk(c);
|
|
2512
|
+
};
|
|
2513
|
+
walk(node);
|
|
2514
|
+
return chars * maxFont;
|
|
2515
|
+
}
|
|
2516
|
+
var r3 = (n) => Math.round(n * 1e3) / 1e3;
|
|
2517
|
+
function shiftAnimatable(v, by) {
|
|
2518
|
+
if (!by || v === void 0 || v === null) return v;
|
|
2519
|
+
if (typeof v === "number") return v + by;
|
|
2520
|
+
const o = v;
|
|
2521
|
+
if (typeof o.value === "number") return __spreadProps(__spreadValues({}, o), { value: o.value + by });
|
|
2522
|
+
if (Array.isArray(o.keyframes)) return __spreadProps(__spreadValues({}, o), { keyframes: o.keyframes.map((k) => __spreadProps(__spreadValues({}, k), { value: (Number(k.value) || 0) + by })) });
|
|
2523
|
+
return v;
|
|
2524
|
+
}
|
|
2525
|
+
function extendedPathForBrowser(pathD, opts) {
|
|
2526
|
+
var _a;
|
|
2527
|
+
if (opts.pathOverflow === "clip") return { d: pathD, startShift: 0 };
|
|
2528
|
+
const sampler = createPathSampler(pathD);
|
|
2529
|
+
if (!sampler || sampler.closed || sampler.totalLength <= 0) return { d: pathD, startShift: 0 };
|
|
2530
|
+
const L = sampler.totalLength;
|
|
2531
|
+
const margin = EXTEND_MARGIN_FRAC * L;
|
|
2532
|
+
const so = numRange(opts.startOffset);
|
|
2533
|
+
const runWidth = numRange(opts.textLength).max || ((_a = opts.advance) != null ? _a : 0);
|
|
2534
|
+
const startOverflow = Math.max(0, -so.min);
|
|
2535
|
+
const endOverflow = Math.max(0, so.max + runWidth - L);
|
|
2536
|
+
const startExt = startOverflow > 0 ? startOverflow + margin : 0;
|
|
2537
|
+
const endExt = endOverflow > 0 ? endOverflow + margin : 0;
|
|
2538
|
+
if (endExt <= 0 && startExt <= 0) return { d: pathD, startShift: 0 };
|
|
2539
|
+
const s = sampler.sampleAtDistance(0);
|
|
2540
|
+
const e = sampler.sampleAtDistance(L);
|
|
2541
|
+
let d = pathD;
|
|
2542
|
+
if (startExt > 0) {
|
|
2543
|
+
const sx = s.x - Math.cos(s.angle) * startExt, sy = s.y - Math.sin(s.angle) * startExt;
|
|
2544
|
+
const rest = pathD.replace(/^\s*[Mm]\s*-?[\d.]+[\s,]+-?[\d.]+/, "");
|
|
2545
|
+
d = "M" + r3(sx) + "," + r3(sy) + "L" + r3(s.x) + "," + r3(s.y) + rest;
|
|
2546
|
+
}
|
|
2547
|
+
if (endExt > 0) {
|
|
2548
|
+
const ex = e.x + Math.cos(e.angle) * endExt, ey = e.y + Math.sin(e.angle) * endExt;
|
|
2549
|
+
d += "L" + r3(ex) + "," + r3(ey);
|
|
2550
|
+
}
|
|
2551
|
+
return { d, startShift: startExt };
|
|
2552
|
+
}
|
|
2553
|
+
function applyTextPathEffect(node, fx, ctx) {
|
|
2554
|
+
var _a;
|
|
2555
|
+
if (!fx || typeof fx.path !== "string" || !fx.path) return node;
|
|
2556
|
+
const pathId = genId(ctx, "tpath");
|
|
2557
|
+
const { d, startShift } = extendedPathForBrowser(fx.path, {
|
|
2558
|
+
pathOverflow: fx.pathOverflow,
|
|
2559
|
+
startOffset: fx.startOffset,
|
|
2560
|
+
textLength: fx.textLength,
|
|
2561
|
+
advance: estimateTextAdvance(node)
|
|
2562
|
+
});
|
|
2563
|
+
ctx.defs.push({ type: "path", id: pathId, d });
|
|
2564
|
+
const textPath = {
|
|
2565
|
+
type: "textPath",
|
|
2566
|
+
href: "#" + pathId,
|
|
2567
|
+
children: (_a = node.children) != null ? _a : []
|
|
2568
|
+
};
|
|
2569
|
+
if (fx.lengthAdjust !== void 0) textPath.lengthAdjust = fx.lengthAdjust;
|
|
2570
|
+
if (fx.method !== void 0) textPath.method = fx.method;
|
|
2571
|
+
if (fx.spacing !== void 0) textPath.spacing = fx.spacing;
|
|
2572
|
+
applyAnimatableNumber(textPath, "startOffset", shiftAnimatable(fx.startOffset, startShift));
|
|
2573
|
+
applyAnimatableNumber(textPath, "textLength", fx.textLength);
|
|
2574
|
+
node.children = [textPath];
|
|
2575
|
+
return node;
|
|
2576
|
+
}
|
|
2577
|
+
function applyAnimatableNumber(node, attrName, raw) {
|
|
2578
|
+
if (raw === void 0 || raw === null) return;
|
|
2579
|
+
if (typeof raw === "number") {
|
|
2580
|
+
node[attrName] = String(raw);
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
if (typeof raw === "object" && raw !== null) {
|
|
2584
|
+
const obj = raw;
|
|
2585
|
+
if (Array.isArray(obj.keyframes)) {
|
|
2586
|
+
const prevAnimate = node.animate && typeof node.animate === "object" && !Array.isArray(node.animate) ? node.animate : void 0;
|
|
2587
|
+
const animate = __spreadValues({}, prevAnimate || {});
|
|
2588
|
+
const block = { keyframes: obj.keyframes };
|
|
2589
|
+
if (obj.loop !== void 0) block.loop = obj.loop;
|
|
2590
|
+
animate[attrName] = block;
|
|
2591
|
+
node.animate = animate;
|
|
2592
|
+
return;
|
|
2593
|
+
}
|
|
2594
|
+
if (typeof obj.value === "number") {
|
|
2595
|
+
node[attrName] = String(obj.value);
|
|
2596
|
+
return;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
// src/effects/elementFactory.ts
|
|
2602
|
+
var jsonElementFactory = (type, props, children) => {
|
|
2603
|
+
const node = { type };
|
|
2604
|
+
for (const k in props) if (props[k] !== void 0) node[k] = props[k];
|
|
2605
|
+
const arr = Array.isArray(children) ? children.filter((c) => c != null) : children != null ? [children] : [];
|
|
2606
|
+
if (arr.length) node.children = arr;
|
|
2607
|
+
return node;
|
|
2608
|
+
};
|
|
2609
|
+
|
|
2610
|
+
// src/effects/glyphPathBake.ts
|
|
2611
|
+
function fmt(v, decimals) {
|
|
2612
|
+
return Math.round(v) === v ? "" + Math.round(v) : v.toFixed(decimals);
|
|
2613
|
+
}
|
|
2614
|
+
function pack(nums, decimals) {
|
|
2615
|
+
let s = "";
|
|
2616
|
+
for (let i = 0; i < nums.length; i++) {
|
|
2617
|
+
const str2 = fmt(nums[i], decimals);
|
|
2618
|
+
if (i > 0 && str2.charCodeAt(0) !== 45) s += " ";
|
|
2619
|
+
s += str2;
|
|
2620
|
+
}
|
|
2621
|
+
return s;
|
|
2622
|
+
}
|
|
2623
|
+
function apply(m, x, y) {
|
|
2624
|
+
return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];
|
|
2625
|
+
}
|
|
2626
|
+
var TOKEN_RE = /([MLCQZ])|(-?\d*\.?\d+(?:e[-+]?\d+)?)/gi;
|
|
2627
|
+
function transformPathData(d, m, decimals = 2) {
|
|
2628
|
+
const tokens = [];
|
|
2629
|
+
let match;
|
|
2630
|
+
TOKEN_RE.lastIndex = 0;
|
|
2631
|
+
while ((match = TOKEN_RE.exec(d)) !== null) tokens.push(match[0]);
|
|
2632
|
+
let out = "";
|
|
2633
|
+
let i = 0;
|
|
2634
|
+
const num2 = () => parseFloat(tokens[i++]);
|
|
2635
|
+
while (i < tokens.length) {
|
|
2636
|
+
const cmd = tokens[i++];
|
|
2637
|
+
if (cmd === "M" || cmd === "L") {
|
|
2638
|
+
const [x, y] = apply(m, num2(), num2());
|
|
2639
|
+
out += cmd + pack([x, y], decimals);
|
|
2640
|
+
} else if (cmd === "C") {
|
|
2641
|
+
const [x1, y1] = apply(m, num2(), num2());
|
|
2642
|
+
const [x2, y2] = apply(m, num2(), num2());
|
|
2643
|
+
const [x, y] = apply(m, num2(), num2());
|
|
2644
|
+
out += "C" + pack([x1, y1, x2, y2, x, y], decimals);
|
|
2645
|
+
} else if (cmd === "Q") {
|
|
2646
|
+
const [x1, y1] = apply(m, num2(), num2());
|
|
2647
|
+
const [x, y] = apply(m, num2(), num2());
|
|
2648
|
+
out += "Q" + pack([x1, y1, x, y], decimals);
|
|
2649
|
+
} else if (cmd === "Z" || cmd === "z") {
|
|
2650
|
+
out += "Z";
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
return out;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2584
2656
|
// src/effects/textGlyphsEffect.ts
|
|
2585
2657
|
var DEFAULT_FONT_SIZE = 16;
|
|
2586
2658
|
var TEXT_ATTR_KEYS = [
|
|
@@ -2742,7 +2814,7 @@ function alongAffine(sampler, dist, scale, widthEm) {
|
|
|
2742
2814
|
const cos = Math.cos(angle), sin = Math.sin(angle), hw = widthEm / 2;
|
|
2743
2815
|
return [scale * cos, scale * sin, -scale * sin, scale * cos, x - scale * cos * hw, y - scale * sin * hw];
|
|
2744
2816
|
}
|
|
2745
|
-
function materialiseGlyphTextAlongPath(node, pathD, startOffset, opts, textLength) {
|
|
2817
|
+
function materialiseGlyphTextAlongPath(node, pathD, startOffset, opts, textLength, pathOverflow) {
|
|
2746
2818
|
var _a;
|
|
2747
2819
|
const { glyphs, create = jsonElementFactory, warnings } = opts;
|
|
2748
2820
|
const sampler = pathD ? createPathSampler(pathD) : null;
|
|
@@ -2757,12 +2829,17 @@ function materialiseGlyphTextAlongPath(node, pathD, startOffset, opts, textLengt
|
|
|
2757
2829
|
const k = textLength / width;
|
|
2758
2830
|
for (const c of cells) c.midBase *= k;
|
|
2759
2831
|
}
|
|
2832
|
+
const isClip = pathOverflow === "clip" && !sampler.closed;
|
|
2760
2833
|
const so = readAnimatable(startOffset);
|
|
2761
2834
|
if (so.kind === "animated" /* Animated */ && so.keyframes.length >= 2) {
|
|
2762
|
-
return toGroup(node, buildAnimatedAlongPath(cells, sampler, so.keyframes, so.loop, create), create);
|
|
2835
|
+
return toGroup(node, buildAnimatedAlongPath(cells, sampler, so.keyframes, so.loop, create, isClip), create);
|
|
2763
2836
|
}
|
|
2764
2837
|
const base = so.kind === "animated" /* Animated */ ? Number((_a = so.keyframes[0]) == null ? void 0 : _a.value) || 0 : so.kind === "static" /* Static */ ? Number(so.value) || 0 : 0;
|
|
2765
|
-
const
|
|
2838
|
+
const placeCells = isClip ? cells.filter((c) => {
|
|
2839
|
+
const d = base + c.midBase;
|
|
2840
|
+
return d >= 0 && d <= sampler.totalLength;
|
|
2841
|
+
}) : cells;
|
|
2842
|
+
const placements = placeCells.map((c) => ({
|
|
2766
2843
|
glyphD: c.glyphD,
|
|
2767
2844
|
paint: c.paint,
|
|
2768
2845
|
m: alongAffine(sampler, base + c.midBase, c.scale, c.widthEm)
|
|
@@ -2775,10 +2852,11 @@ function roundN(v, n) {
|
|
|
2775
2852
|
const f = __pow(10, n);
|
|
2776
2853
|
return Math.round(v * f) / f;
|
|
2777
2854
|
}
|
|
2778
|
-
function buildAnimatedAlongPath(cells, sampler, sokfs, loop, create) {
|
|
2855
|
+
function buildAnimatedAlongPath(cells, sampler, sokfs, loop, create, isClip) {
|
|
2779
2856
|
const step = Math.max(sampler.totalLength / ALONG_PATH_MAX_STEPS, 0.5);
|
|
2780
2857
|
const timeOf = (kf) => Number(kf.time) || 0;
|
|
2781
2858
|
const offOf = (kf) => Number(kf.value) || 0;
|
|
2859
|
+
const onPath = (dist) => dist >= 0 && dist <= sampler.totalLength;
|
|
2782
2860
|
const out = [];
|
|
2783
2861
|
for (const c of cells) {
|
|
2784
2862
|
const centred = [c.scale, 0, 0, c.scale, -c.scale * (c.widthEm / 2), 0];
|
|
@@ -2793,19 +2871,31 @@ function buildAnimatedAlongPath(cells, sampler, sokfs, loop, create) {
|
|
|
2793
2871
|
}
|
|
2794
2872
|
};
|
|
2795
2873
|
};
|
|
2796
|
-
const kfs = [
|
|
2874
|
+
const kfs = [];
|
|
2875
|
+
const opKfs = [];
|
|
2876
|
+
const pushKf = (dist, time) => {
|
|
2877
|
+
kfs.push(sampleKf(dist, time));
|
|
2878
|
+
if (isClip) opKfs.push({ time, value: onPath(dist) ? 1 : 0 });
|
|
2879
|
+
};
|
|
2880
|
+
pushKf(offOf(sokfs[0]) + c.midBase, timeOf(sokfs[0]));
|
|
2797
2881
|
for (let k = 1; k < sokfs.length; k++) {
|
|
2798
2882
|
const t0 = timeOf(sokfs[k - 1]), t1 = timeOf(sokfs[k]);
|
|
2799
2883
|
const o0 = offOf(sokfs[k - 1]), o1 = offOf(sokfs[k]);
|
|
2800
2884
|
const n = Math.min(ALONG_PATH_MAX_STEPS_PER_SEGMENT, Math.max(1, Math.ceil(Math.abs(o1 - o0) / step)));
|
|
2801
2885
|
for (let s = 1; s <= n; s++) {
|
|
2802
2886
|
const f = s / n;
|
|
2803
|
-
|
|
2887
|
+
pushKf(o0 + f * (o1 - o0) + c.midBase, t0 + f * (t1 - t0));
|
|
2804
2888
|
}
|
|
2805
2889
|
}
|
|
2806
2890
|
const transform = { keyframes: kfs };
|
|
2807
2891
|
if (loop !== void 0) transform.loop = loop;
|
|
2808
|
-
|
|
2892
|
+
const animate = { transform };
|
|
2893
|
+
if (isClip && opKfs.some((k) => k.value === 0)) {
|
|
2894
|
+
const op = { keyframes: opKfs };
|
|
2895
|
+
if (loop !== void 0) op.loop = loop;
|
|
2896
|
+
animate.opacity = op;
|
|
2897
|
+
}
|
|
2898
|
+
out.push(create("path", __spreadProps(__spreadValues({ d }, paintProps(c.paint)), { animate }), []));
|
|
2809
2899
|
}
|
|
2810
2900
|
return out;
|
|
2811
2901
|
}
|
|
@@ -2849,7 +2939,7 @@ function toGroup(node, children, create) {
|
|
|
2849
2939
|
return create("g", gProps, children);
|
|
2850
2940
|
}
|
|
2851
2941
|
function materialiseGlyphText(node, opts) {
|
|
2852
|
-
if (opts.alongPath) return materialiseGlyphTextAlongPath(node, opts.alongPath.pathD, opts.alongPath.startOffset, opts, opts.alongPath.textLength);
|
|
2942
|
+
if (opts.alongPath) return materialiseGlyphTextAlongPath(node, opts.alongPath.pathD, opts.alongPath.startOffset, opts, opts.alongPath.textLength, opts.alongPath.pathOverflow);
|
|
2853
2943
|
return materialiseGlyphTextHorizontal(node, opts);
|
|
2854
2944
|
}
|
|
2855
2945
|
function applyTextGlyphsEffect(node, fx, ctx) {
|
|
@@ -2860,12 +2950,12 @@ function applyTextGlyphsEffect(node, fx, ctx) {
|
|
|
2860
2950
|
}
|
|
2861
2951
|
return materialiseGlyphTextHorizontal(node, { glyphs: ctx.glyphs, warnings: ctx.warnings });
|
|
2862
2952
|
}
|
|
2863
|
-
function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength) {
|
|
2953
|
+
function applyTextGlyphsAlongPath(node, ctx, pathD, startOffset, textLength, pathOverflow) {
|
|
2864
2954
|
if (!ctx.glyphs) {
|
|
2865
2955
|
ctx.warnings.push("textGlyphs: no definitions.glyphs");
|
|
2866
2956
|
return null;
|
|
2867
2957
|
}
|
|
2868
|
-
return materialiseGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength);
|
|
2958
|
+
return materialiseGlyphTextAlongPath(node, pathD, startOffset, { glyphs: ctx.glyphs, warnings: ctx.warnings }, textLength, pathOverflow);
|
|
2869
2959
|
}
|
|
2870
2960
|
|
|
2871
2961
|
// src/PxMotionPath.ts
|
|
@@ -4271,18 +4361,17 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
|
|
|
4271
4361
|
const originalId = typeof node.id === "string" ? node.id : void 0;
|
|
4272
4362
|
const innerIdForContentRef = originalId ? ctx.contentRefInnerIds.get(originalId) : void 0;
|
|
4273
4363
|
if (!fx && !innerIdForContentRef) return node;
|
|
4274
|
-
const { transformation, repeater, maskedBy, trimPath, clone: cloneFx, fillGradient, strokeGradient,
|
|
4364
|
+
const { transformation, repeater, maskedBy, trimPath, clone: cloneFx, fillGradient, strokeGradient, textPath, text } = fx != null ? fx : {};
|
|
4275
4365
|
const isCombinedShape = fx == null ? void 0 : fx.isCombinedShape;
|
|
4276
4366
|
if (fx) delete node.effects;
|
|
4277
4367
|
let n = node;
|
|
4278
4368
|
let consumedByGlyphs = false;
|
|
4279
4369
|
if (text == null ? void 0 : text.useGlyphs) {
|
|
4280
|
-
if (
|
|
4281
|
-
const
|
|
4282
|
-
const
|
|
4283
|
-
const rawTL = textAlongPath.textLength;
|
|
4370
|
+
if (textPath) {
|
|
4371
|
+
const pathD = typeof textPath.path === "string" ? textPath.path : void 0;
|
|
4372
|
+
const rawTL = textPath.textLength;
|
|
4284
4373
|
const textLength = typeof rawTL === "number" ? rawTL : rawTL && typeof rawTL === "object" ? typeof rawTL.value === "number" ? rawTL.value : Array.isArray(rawTL.keyframes) && rawTL.keyframes.length ? Number((_a = rawTL.keyframes[0]) == null ? void 0 : _a.value) : void 0 : void 0;
|
|
4285
|
-
const glyphed = applyTextGlyphsAlongPath(n, ctx, pathD,
|
|
4374
|
+
const glyphed = applyTextGlyphsAlongPath(n, ctx, pathD, textPath.startOffset, textLength, textPath.pathOverflow);
|
|
4286
4375
|
if (glyphed) {
|
|
4287
4376
|
n = glyphed;
|
|
4288
4377
|
consumedByGlyphs = true;
|
|
@@ -4292,7 +4381,7 @@ function applyPlayerEffects_exceptRetime(node, ctx) {
|
|
|
4292
4381
|
consumedByGlyphs = true;
|
|
4293
4382
|
}
|
|
4294
4383
|
}
|
|
4295
|
-
if (!consumedByGlyphs) n =
|
|
4384
|
+
if (!consumedByGlyphs) n = applyTextPathEffect(n, textPath, ctx);
|
|
4296
4385
|
n = applyFillGradientEffect(n, fillGradient, ctx);
|
|
4297
4386
|
n = applyStrokeGradientEffect(n, strokeGradient, ctx);
|
|
4298
4387
|
n = applyTrimPathEffect(n, trimPath, isCombinedShape, ctx);
|
|
@@ -5679,8 +5768,8 @@ export {
|
|
|
5679
5768
|
PxRetimeEffectSchema,
|
|
5680
5769
|
PxStrokeGradientEffectSchema,
|
|
5681
5770
|
PxSvgNodeExtra,
|
|
5682
|
-
PxTextAlongPathEffectSchema,
|
|
5683
5771
|
PxTextEffectSchema,
|
|
5772
|
+
PxTextPathEffectSchema,
|
|
5684
5773
|
PxTransformPartsSchema,
|
|
5685
5774
|
PxTransformValueSchema,
|
|
5686
5775
|
PxTransformationEffectSchema,
|
|
@@ -5700,6 +5789,7 @@ export {
|
|
|
5700
5789
|
describeSchema,
|
|
5701
5790
|
diffInEffect,
|
|
5702
5791
|
evaluateMotionPathSegment,
|
|
5792
|
+
extendedPathForBrowser,
|
|
5703
5793
|
generateNewIds,
|
|
5704
5794
|
getAnimatorConfig,
|
|
5705
5795
|
getBindings,
|
|
@@ -5725,6 +5815,7 @@ export {
|
|
|
5725
5815
|
renderNode,
|
|
5726
5816
|
schemaKeys,
|
|
5727
5817
|
setupAnimationTriggers,
|
|
5818
|
+
shiftAnimatable,
|
|
5728
5819
|
toRGBA,
|
|
5729
5820
|
validateNodeEffects,
|
|
5730
5821
|
visualModelAt
|