@pixerate/editor 0.248.0 → 0.250.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 +1 -0
- package/dist/animation-editor/index.cjs +118 -114
- package/dist/animation-editor/index.js +11 -7
- package/dist/{brushstrokeRender-QLCXROJK.js → brushstrokeRender-2FHFLSEG.js} +8 -4
- package/dist/{brushstrokeRender-DTDPFBLC.cjs → brushstrokeRender-QGRXOKDA.cjs} +15 -11
- package/dist/canvas/index.cjs +71 -15
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +58 -2
- package/dist/canvas/stickers.d.cts +35 -0
- package/dist/canvas/stickers.d.ts +35 -0
- package/dist/{chunk-RXZL4NG5.js → chunk-226QDRO3.js} +1 -1
- package/dist/{chunk-SC2RZ5EF.js → chunk-2VJAVXLI.js} +2 -2
- package/dist/{chunk-OLNIPTB3.cjs → chunk-2VX55NFM.cjs} +1 -320
- package/dist/chunk-3K6HWEXZ.cjs +92 -0
- package/dist/{chunk-UOOK7HTX.js → chunk-3PPJRMIG.js} +1 -1
- package/dist/{chunk-ZFSLEOSQ.js → chunk-3TWOCSCY.js} +11 -9
- package/dist/chunk-4D6KP5BV.js +92 -0
- package/dist/chunk-4JNWA3VT.cjs +302 -0
- package/dist/{chunk-L3JFOTBQ.js → chunk-5E2Q7ZHI.js} +1 -1
- package/dist/{chunk-2ONK3ERD.cjs → chunk-75K3W4D6.cjs} +20 -20
- package/dist/{chunk-AU6MWQKZ.js → chunk-ABL7IWFZ.js} +1 -1
- package/dist/chunk-ATK6ABN3.cjs +303 -0
- package/dist/{chunk-7T7JWTVE.cjs → chunk-BOHDJJ2O.cjs} +8 -8
- package/dist/{chunk-2PBZBRP5.js → chunk-D5KGAO4Z.js} +10 -92
- package/dist/{chunk-HB4ICNNA.cjs → chunk-DPYAO5U6.cjs} +42 -42
- package/dist/{chunk-6G6ZDDDB.cjs → chunk-GT77U7QG.cjs} +303 -149
- package/dist/{chunk-PQ3H2AAN.cjs → chunk-I7NJPHWV.cjs} +122 -204
- package/dist/{chunk-42TWUPNJ.js → chunk-IRSTHLQQ.js} +1 -320
- package/dist/{chunk-GHCSC2WP.cjs → chunk-ISIO63Q5.cjs} +21 -15
- package/dist/{chunk-OFH6Q67U.js → chunk-JA57JIT5.js} +9 -3
- package/dist/{chunk-VMROIWLL.cjs → chunk-KBYB7OWB.cjs} +3 -3
- package/dist/{chunk-Q2HA52V4.js → chunk-KDLBJ6QR.js} +2 -2
- package/dist/{chunk-WVS5KQDH.cjs → chunk-M2VKFE5L.cjs} +246 -244
- package/dist/{chunk-5GLYUSNT.js → chunk-NOHJP5TK.js} +1 -1
- package/dist/{chunk-XNRBMYNB.js → chunk-NTRAVM2I.js} +1 -1
- package/dist/{chunk-VNBUDVD4.js → chunk-OTEPAQJX.js} +228 -74
- package/dist/chunk-OTTT5N3K.js +322 -0
- package/dist/{chunk-QOBCBGGI.cjs → chunk-QKXO6JPP.cjs} +14 -14
- package/dist/{chunk-NZ3O3A5C.js → chunk-SMSGP2HQ.js} +1 -1
- package/dist/chunk-SZTI6EER.js +13 -0
- package/dist/chunk-U4NUOKBT.js +303 -0
- package/dist/chunk-U67EN7GG.cjs +13 -0
- package/dist/chunk-W5M3J7PV.cjs +322 -0
- package/dist/{chunk-4P6H35HU.js → chunk-WA44NKPF.js} +2 -2
- package/dist/chunk-WKH5ZAUA.js +302 -0
- package/dist/{chunk-L6REDLNB.cjs → chunk-WPUXGDH4.cjs} +7 -7
- package/dist/{chunk-P3NIPIKS.js → chunk-WQCNC4DK.js} +1 -1
- package/dist/{chunk-IBDU6EGZ.cjs → chunk-X7WRL5ZZ.cjs} +35 -35
- package/dist/{chunk-XWTRATIM.cjs → chunk-YM6ZBTXG.cjs} +23 -23
- package/dist/{chunk-TPWB4Y6L.cjs → chunk-YW43M56C.cjs} +1 -1
- package/dist/{chunk-K5DS2JTA.cjs → chunk-Z3BRH4JK.cjs} +6 -6
- package/dist/{chunk-XNZFVYC2.cjs → chunk-ZBCT5MEA.cjs} +7 -7
- package/dist/effects/helpers.d.cts +6 -0
- package/dist/effects/helpers.d.ts +6 -0
- package/dist/effects/index.cjs +62 -60
- package/dist/effects/index.js +5 -3
- package/dist/effects/tools.d.cts +6 -0
- package/dist/effects/tools.d.ts +6 -0
- package/dist/image-editor/effects.d.cts +1 -1
- package/dist/image-editor/effects.d.ts +1 -1
- package/dist/image-editor/index.cjs +1097 -1069
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +58 -30
- package/dist/image-editor/stickers.d.cts +9 -0
- package/dist/image-editor/stickers.d.ts +9 -0
- package/dist/paint/index.cjs +8 -5
- package/dist/paint/index.js +13 -10
- package/dist/paint-editor/controller.d.cts +37 -1
- package/dist/paint-editor/controller.d.ts +37 -1
- package/dist/paint-editor/index.cjs +753 -609
- package/dist/paint-editor/index.d.cts +3 -0
- package/dist/paint-editor/index.d.ts +3 -0
- package/dist/paint-editor/index.js +187 -43
- package/dist/paint-editor/sticker-art.d.cts +55 -0
- package/dist/paint-editor/sticker-art.d.ts +55 -0
- package/dist/paint-editor/stickers.d.cts +30 -17
- package/dist/paint-editor/stickers.d.ts +30 -17
- package/dist/paint-editor/stroke.d.cts +4 -0
- package/dist/paint-editor/stroke.d.ts +4 -0
- package/dist/paint-editor/ui.d.cts +10 -2
- package/dist/paint-editor/ui.d.ts +10 -2
- package/dist/raster/index.cjs +6 -4
- package/dist/raster/index.js +12 -10
- package/dist/stickers/browser.d.cts +48 -0
- package/dist/stickers/browser.d.ts +48 -0
- package/dist/stickers/combine.d.cts +10 -0
- package/dist/stickers/combine.d.ts +10 -0
- package/dist/stickers/conformance.d.cts +18 -0
- package/dist/stickers/conformance.d.ts +18 -0
- package/dist/stickers/editor.d.cts +14 -0
- package/dist/stickers/editor.d.ts +14 -0
- package/dist/stickers/errors.d.cts +6 -0
- package/dist/stickers/errors.d.ts +6 -0
- package/dist/stickers/fake.d.cts +16 -0
- package/dist/stickers/fake.d.ts +16 -0
- package/dist/stickers/helpers.d.cts +51 -0
- package/dist/stickers/helpers.d.ts +51 -0
- package/dist/stickers/index.cjs +337 -0
- package/dist/stickers/index.d.cts +16 -0
- package/dist/stickers/index.d.ts +16 -0
- package/dist/stickers/index.js +337 -0
- package/dist/stickers/stamps.d.cts +13 -0
- package/dist/stickers/stamps.d.ts +13 -0
- package/dist/stickers/tools.d.cts +81 -0
- package/dist/stickers/tools.d.ts +81 -0
- package/dist/stickers/types.d.cts +123 -0
- package/dist/stickers/types.d.ts +123 -0
- package/dist/vector/index.cjs +1018 -981
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +44 -7
- package/dist/vector/stickers.d.cts +11 -0
- package/dist/vector/stickers.d.ts +11 -0
- package/dist/video-editor/index.cjs +344 -344
- package/dist/video-editor/index.js +4 -4
- package/package.json +11 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-image-editor/SKILL.md +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +8 -5
- package/skills/pixerate-stickers/SKILL.md +57 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StickerError
|
|
3
|
+
} from "./chunk-SZTI6EER.js";
|
|
4
|
+
import {
|
|
5
|
+
hash2
|
|
6
|
+
} from "./chunk-4D6KP5BV.js";
|
|
7
|
+
|
|
8
|
+
// src/stickers/stamps.ts
|
|
9
|
+
var STAMP_KINDS = ["dot", "star", "heart", "leaf", "flower", "confetti", "splat", "sparkle", "ring"];
|
|
10
|
+
function stampCoverage(kind, u, v, t) {
|
|
11
|
+
const r = Math.hypot(u, v);
|
|
12
|
+
const a = Math.atan2(v, u);
|
|
13
|
+
const edge = (d) => Math.min(1, Math.max(0, d * 24 + 0.5));
|
|
14
|
+
switch (kind) {
|
|
15
|
+
case "dot":
|
|
16
|
+
return edge(0.95 - r);
|
|
17
|
+
case "ring":
|
|
18
|
+
return edge(Math.min(0.95 - r, r - 0.6));
|
|
19
|
+
case "star": {
|
|
20
|
+
const f = (a + Math.PI / 2) * 5 / (2 * Math.PI) % 1;
|
|
21
|
+
const notch = Math.min(f < 0 ? f + 1 : f, 1 - (f < 0 ? f + 1 : f)) * 2;
|
|
22
|
+
return edge(0.95 - 0.55 * notch - r);
|
|
23
|
+
}
|
|
24
|
+
case "sparkle": {
|
|
25
|
+
const q = Math.pow(Math.abs(u) / 0.95, 0.6) + Math.pow(Math.abs(v) / 0.95, 0.6);
|
|
26
|
+
return edge((1 - q) * 0.4);
|
|
27
|
+
}
|
|
28
|
+
case "heart": {
|
|
29
|
+
const x = u * 1.1;
|
|
30
|
+
const y = -v * 1.1 + 0.15;
|
|
31
|
+
const q = x * x + y * y - 0.55;
|
|
32
|
+
return edge(-(q * q * q - x * x * y * y * y) * 3);
|
|
33
|
+
}
|
|
34
|
+
case "leaf": {
|
|
35
|
+
const w = 0.42 * Math.sqrt(Math.max(0, 1 - u * u));
|
|
36
|
+
const inside = edge(w - Math.abs(v + 0.15 * u * u));
|
|
37
|
+
const rib = Math.abs(v + 0.15 * u * u) < 0.03 && Math.abs(u) < 0.85 ? 0.65 : 1;
|
|
38
|
+
return inside * rib;
|
|
39
|
+
}
|
|
40
|
+
case "flower": {
|
|
41
|
+
const petals = 0.6 + 0.35 * Math.abs(Math.cos(2.5 * a));
|
|
42
|
+
const body = edge(petals - r);
|
|
43
|
+
return r < 0.22 ? Math.max(body, 1) * 0.85 : body;
|
|
44
|
+
}
|
|
45
|
+
case "confetti": {
|
|
46
|
+
return edge(Math.min(0.9 - Math.abs(u), 0.35 - Math.abs(v)));
|
|
47
|
+
}
|
|
48
|
+
case "splat": {
|
|
49
|
+
let rr = 0.55;
|
|
50
|
+
for (let k = 1; k <= 3; k++) rr += 0.08 * Math.sin(a * (k + 2) + hash2(k, 1, t) * 6.28) / k;
|
|
51
|
+
let c = edge(rr - r);
|
|
52
|
+
for (let k = 0; k < 4; k++) {
|
|
53
|
+
const ang = hash2(k, 7, t) * Math.PI * 2;
|
|
54
|
+
const dist = 0.72 + 0.2 * hash2(k, 9, t);
|
|
55
|
+
const dx = u - Math.cos(ang) * dist;
|
|
56
|
+
const dy = v - Math.sin(ang) * dist;
|
|
57
|
+
c = Math.max(c, edge(0.08 + 0.06 * hash2(k, 11, t) - Math.hypot(dx, dy)));
|
|
58
|
+
}
|
|
59
|
+
return c;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/stickers/helpers.ts
|
|
65
|
+
var DEFAULT_STICKER_PAGE = 24;
|
|
66
|
+
var MAX_STICKER_PAGE = 100;
|
|
67
|
+
var EDITOR_STICKERS_ID = "editor";
|
|
68
|
+
function checkStickerSearchOptions(options = {}) {
|
|
69
|
+
if (options.limit !== void 0 && !(Number.isInteger(options.limit) && options.limit >= 1 && options.limit <= MAX_STICKER_PAGE)) {
|
|
70
|
+
throw new StickerError("invalid_argument", `limit must be a whole number from 1 to ${MAX_STICKER_PAGE}, got ${options.limit}.`);
|
|
71
|
+
}
|
|
72
|
+
if (options.after !== void 0 && !/^\d+$/.test(options.after)) throw new StickerError("invalid_argument", `after "${options.after}" is not a cursor from this provider; pass the next value of the previous page.`);
|
|
73
|
+
}
|
|
74
|
+
var words = (s) => s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
75
|
+
function stickerPage(items, options = {}, query = "") {
|
|
76
|
+
checkStickerSearchOptions(options);
|
|
77
|
+
const q = words(query);
|
|
78
|
+
const tags = (options.tags ?? []).map((t) => t.toLowerCase());
|
|
79
|
+
const matches = items.filter((s) => {
|
|
80
|
+
if (options.category && s.category !== options.category) return false;
|
|
81
|
+
if (tags.length && !tags.every((t) => (s.tags ?? []).some((x) => x.toLowerCase() === t))) return false;
|
|
82
|
+
if (options.licence?.commercial === true && !s.licence.commercial) return false;
|
|
83
|
+
if (!q.length) return true;
|
|
84
|
+
const text = new Set(words([s.name, s.category, s.description ?? "", ...s.tags ?? []].join(" ")));
|
|
85
|
+
return q.every((w) => [...text].some((t) => t.startsWith(w)));
|
|
86
|
+
});
|
|
87
|
+
const start = options.after ? Number(options.after) : 0;
|
|
88
|
+
const limit = options.limit ?? DEFAULT_STICKER_PAGE;
|
|
89
|
+
const page = matches.slice(start, start + limit);
|
|
90
|
+
return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
|
|
91
|
+
}
|
|
92
|
+
function parseStickerRef(ref) {
|
|
93
|
+
if (typeof ref !== "string" || !ref) throw new StickerError("invalid_argument", 'A sticker ref is a "provider:id" string, e.g. "editor:star" (find_stickers lists them).');
|
|
94
|
+
const i = ref.indexOf(":");
|
|
95
|
+
if (i === -1) {
|
|
96
|
+
if (STAMP_KINDS.includes(ref)) return { provider: EDITOR_STICKERS_ID, id: ref };
|
|
97
|
+
throw new StickerError("invalid_argument", `"${ref}" is not a sticker ref; refs are "provider:id" (e.g. "editor:${STAMP_KINDS[1]}"); find_stickers lists them.`);
|
|
98
|
+
}
|
|
99
|
+
if (i === 0 || i === ref.length - 1) throw new StickerError("invalid_argument", `"${ref}" is not a sticker ref; refs are "provider:id".`);
|
|
100
|
+
return { provider: ref.slice(0, i), id: ref.slice(i + 1) };
|
|
101
|
+
}
|
|
102
|
+
function normalizeStickerRef(ref) {
|
|
103
|
+
const { provider, id } = parseStickerRef(ref);
|
|
104
|
+
return `${provider}:${id}`;
|
|
105
|
+
}
|
|
106
|
+
function editorStampOf(ref) {
|
|
107
|
+
const { provider, id } = parseStickerRef(ref);
|
|
108
|
+
return provider === EDITOR_STICKERS_ID && STAMP_KINDS.includes(id) ? id : null;
|
|
109
|
+
}
|
|
110
|
+
function stickerRefOf(provider, id) {
|
|
111
|
+
return provider.namespaced ? id : `${provider.id}:${id}`;
|
|
112
|
+
}
|
|
113
|
+
function stickerIdFor(provider, ref) {
|
|
114
|
+
const { provider: owner, id } = parseStickerRef(ref);
|
|
115
|
+
if (provider.namespaced) return `${owner}:${id}`;
|
|
116
|
+
return owner === provider.id ? id : null;
|
|
117
|
+
}
|
|
118
|
+
function closestStickerRefs(wanted, candidates, n = 3) {
|
|
119
|
+
const w = wanted.toLowerCase();
|
|
120
|
+
const dist = (a, b) => {
|
|
121
|
+
const d = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
122
|
+
for (let i = 1; i <= a.length; i++) {
|
|
123
|
+
let prev = d[0];
|
|
124
|
+
d[0] = i;
|
|
125
|
+
for (let j = 1; j <= b.length; j++) {
|
|
126
|
+
const tmp = d[j];
|
|
127
|
+
d[j] = Math.min(d[j] + 1, d[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
128
|
+
prev = tmp;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return d[b.length];
|
|
132
|
+
};
|
|
133
|
+
return [...candidates].sort((a, b) => dist(w, a.toLowerCase()) - dist(w, b.toLowerCase()) || a.localeCompare(b)).slice(0, n);
|
|
134
|
+
}
|
|
135
|
+
var StickersSlot = class {
|
|
136
|
+
constructor(fallback) {
|
|
137
|
+
this.fallback = fallback;
|
|
138
|
+
this.current = fallback;
|
|
139
|
+
}
|
|
140
|
+
fallback;
|
|
141
|
+
current;
|
|
142
|
+
listeners = /* @__PURE__ */ new Set();
|
|
143
|
+
get provider() {
|
|
144
|
+
return this.current;
|
|
145
|
+
}
|
|
146
|
+
set(provider) {
|
|
147
|
+
const next = provider ?? this.fallback;
|
|
148
|
+
if (next === this.current) return;
|
|
149
|
+
this.current = next;
|
|
150
|
+
for (const l of [...this.listeners]) l(next);
|
|
151
|
+
}
|
|
152
|
+
subscribe(listener) {
|
|
153
|
+
this.listeners.add(listener);
|
|
154
|
+
return () => this.listeners.delete(listener);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/stickers/tools.ts
|
|
159
|
+
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
160
|
+
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
161
|
+
function stickerForAgent(provider, s) {
|
|
162
|
+
const { id, thumbnail: _thumbnail, ...rest } = s;
|
|
163
|
+
return { ref: stickerRefOf(provider, id), ...rest };
|
|
164
|
+
}
|
|
165
|
+
async function knownRefs(provider, cap = 500) {
|
|
166
|
+
const refs = [];
|
|
167
|
+
let after;
|
|
168
|
+
while (refs.length < cap) {
|
|
169
|
+
const page = await provider.list({ limit: MAX_STICKER_PAGE, ...after ? { after } : {} });
|
|
170
|
+
refs.push(...page.items.map((s) => stickerRefOf(provider, s.id)));
|
|
171
|
+
if (!page.next || !page.items.length) break;
|
|
172
|
+
after = page.next;
|
|
173
|
+
}
|
|
174
|
+
return refs;
|
|
175
|
+
}
|
|
176
|
+
async function describeStickerRef(provider, ref) {
|
|
177
|
+
parseStickerRef(ref);
|
|
178
|
+
const id = stickerIdFor(provider, ref);
|
|
179
|
+
const found = id === null ? void 0 : await provider.describe(id);
|
|
180
|
+
if (found) return found;
|
|
181
|
+
const near = closestStickerRefs(ref, await knownRefs(provider));
|
|
182
|
+
const owner = parseStickerRef(ref).provider;
|
|
183
|
+
const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
|
|
184
|
+
throw new StickerError("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
|
|
185
|
+
}
|
|
186
|
+
function createStickerTools(options) {
|
|
187
|
+
const find = {
|
|
188
|
+
name: "find_stickers",
|
|
189
|
+
title: "Find stickers",
|
|
190
|
+
description: "Searches the sticker library (the editor's own stamps unless the host plugged in its own): words in the name, tags, category or description, filtered by category, tags and commercial licence, a small page at a time. Returns each sticker's ref (provider:id, for the tools that spray or place stickers), name, category, tags, natural width and height, formats, whether it is tintable (recoloured to the paint colour) and its licence, plus total and next (pass as after for the next page) and the categories. Changes nothing.",
|
|
191
|
+
inputSchema: {
|
|
192
|
+
type: "object",
|
|
193
|
+
properties: {
|
|
194
|
+
query: { type: "string", maxLength: 200, description: "Words to match (default: list everything)." },
|
|
195
|
+
category: { type: "string", description: "Only this category (the result lists them)." },
|
|
196
|
+
tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
|
|
197
|
+
commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
|
|
198
|
+
limit: { type: "integer", minimum: 1, maximum: MAX_STICKER_PAGE, description: "Page size (default 24)." },
|
|
199
|
+
after: { type: "string", description: "next from the previous page." }
|
|
200
|
+
},
|
|
201
|
+
additionalProperties: false
|
|
202
|
+
},
|
|
203
|
+
annotations: { title: "Find stickers", ...READ },
|
|
204
|
+
handler: async ({ query, category, tags, commercial, limit, after }) => {
|
|
205
|
+
const p = options.provider();
|
|
206
|
+
const categories = await p.categories?.() ?? null;
|
|
207
|
+
if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
|
|
208
|
+
throw new StickerError("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
|
|
209
|
+
}
|
|
210
|
+
const o = { ...category !== void 0 ? { category } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
|
|
211
|
+
const q = typeof query === "string" ? query.trim() : "";
|
|
212
|
+
if (q && !p.capabilities.supportsSearch) throw new StickerError("invalid_argument", `"${p.name}" can't search; leave query out and filter by category instead.`);
|
|
213
|
+
const page = q ? await p.search(q, o) : await p.list(o);
|
|
214
|
+
return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {} };
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const describe = {
|
|
218
|
+
name: "describe_sticker",
|
|
219
|
+
title: "Describe a sticker",
|
|
220
|
+
description: "Everything about one sticker by ref (from find_stickers): name, category, tags, natural size, formats, tintable, licence (with any attribution it asks for), dominant colours, variants and its outline as SVG path data (silhouette). An unknown ref is refused with the closest refs. Changes nothing.",
|
|
221
|
+
inputSchema: { type: "object", properties: { ref: { type: "string", description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." } }, required: ["ref"], additionalProperties: false },
|
|
222
|
+
annotations: { title: "Describe a sticker", ...READ },
|
|
223
|
+
handler: async ({ ref }) => {
|
|
224
|
+
const p = options.provider();
|
|
225
|
+
const d = await describeStickerRef(p, ref);
|
|
226
|
+
const { thumbnail: _thumbnail, id, ...rest } = d;
|
|
227
|
+
return { ref: stickerRefOf(p, id), ...rest };
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
return options.insert ? [find, describe, createInsertStickerTool(options.provider, options.insert)] : [find, describe];
|
|
231
|
+
}
|
|
232
|
+
async function loadForHost(provider, ref, d, host, colour, size) {
|
|
233
|
+
const id = stickerIdFor(provider, ref);
|
|
234
|
+
const format = d.formats.includes(host.format) ? host.format : d.formats[0] ?? host.format;
|
|
235
|
+
return provider.load(id, { format, ...format === "png" ? { size: Math.max(8, Math.min(provider.capabilities.maxSize ?? 1024, Math.round(size))) } : {}, ...colour && d.tintable ? { colour } : {} });
|
|
236
|
+
}
|
|
237
|
+
async function insertSticker(provider, host, options) {
|
|
238
|
+
const d = await describeStickerRef(provider, options.ref);
|
|
239
|
+
if (options.color !== void 0 && !d.tintable) throw new StickerError("invalid_argument", `"${options.ref}" is not tintable (its art has its own colours); leave color out, or pick a tintable sticker (find_stickers lists tintable).`);
|
|
240
|
+
if (options.width !== void 0 && !(options.width > 0)) throw new StickerError("invalid_argument", `width must be a positive size, got ${options.width}.`);
|
|
241
|
+
const w = options.width ?? d.width;
|
|
242
|
+
const h = w * d.height / d.width;
|
|
243
|
+
const centre = host.defaultCentre();
|
|
244
|
+
const asset = await loadForHost(provider, options.ref, d, host, options.color, Math.max(w, h));
|
|
245
|
+
const ref = stickerRefOf(provider, d.id);
|
|
246
|
+
const made = await host.insert({ ref, description: d, asset, x: options.x ?? centre.x, y: options.y ?? centre.y, width: w, height: h, ...options.color ? { colour: options.color.toLowerCase() } : {} });
|
|
247
|
+
return { ...made, ref, width: w, height: h, licence: d.licence };
|
|
248
|
+
}
|
|
249
|
+
function createInsertStickerTool(provider, host) {
|
|
250
|
+
return {
|
|
251
|
+
name: "insert_sticker",
|
|
252
|
+
title: "Insert a sticker",
|
|
253
|
+
description: `Puts one sticker from the sticker library (ref from find_stickers) into the document as a new ${host.noun}, centred at x, y and width wide (its natural aspect kept; default its natural size), tinted to color when the sticker is tintable. Its art is loaded first; an unknown ref is refused with the closest ones. One undo step. Returns the new ${host.noun}'s id (for the editor's own tools, such as effects on it), the ref and its licence (credit any attribution it asks for).`,
|
|
254
|
+
inputSchema: {
|
|
255
|
+
type: "object",
|
|
256
|
+
properties: {
|
|
257
|
+
ref: { type: "string", minLength: 1, description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." },
|
|
258
|
+
x: { type: "number", description: "Centre x in document units (default the middle of the view or document)." },
|
|
259
|
+
y: { type: "number", description: "Centre y in document units (default the middle of the view or document)." },
|
|
260
|
+
width: { type: "number", exclusiveMinimum: 0, maximum: 1e4, description: "Width in document units (default the natural width); the height follows the aspect." },
|
|
261
|
+
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$", description: "Tint #rrggbb for tintable stickers (default the sticker's own colour); refused for stickers that are not tintable." }
|
|
262
|
+
},
|
|
263
|
+
required: ["ref"],
|
|
264
|
+
additionalProperties: false
|
|
265
|
+
},
|
|
266
|
+
annotations: { title: "Insert a sticker", ...WRITE },
|
|
267
|
+
handler: ({ ref, x, y, width, color }) => insertSticker(provider(), host, { ref, x, y, width, color })
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
function createStickerToolProvider(options) {
|
|
271
|
+
return {
|
|
272
|
+
id: options.id ?? "stickers",
|
|
273
|
+
namespace: options.namespace,
|
|
274
|
+
title: "Stickers",
|
|
275
|
+
description: "Find and describe stickers from the sticker library, by ref (provider:id), for the editors that spray or place them.",
|
|
276
|
+
skill: "pixerate-stickers",
|
|
277
|
+
tools: createStickerTools(options)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
STAMP_KINDS,
|
|
283
|
+
stampCoverage,
|
|
284
|
+
DEFAULT_STICKER_PAGE,
|
|
285
|
+
MAX_STICKER_PAGE,
|
|
286
|
+
EDITOR_STICKERS_ID,
|
|
287
|
+
checkStickerSearchOptions,
|
|
288
|
+
stickerPage,
|
|
289
|
+
parseStickerRef,
|
|
290
|
+
normalizeStickerRef,
|
|
291
|
+
editorStampOf,
|
|
292
|
+
stickerRefOf,
|
|
293
|
+
stickerIdFor,
|
|
294
|
+
closestStickerRefs,
|
|
295
|
+
StickersSlot,
|
|
296
|
+
stickerForAgent,
|
|
297
|
+
describeStickerRef,
|
|
298
|
+
createStickerTools,
|
|
299
|
+
insertSticker,
|
|
300
|
+
createInsertStickerTool,
|
|
301
|
+
createStickerToolProvider
|
|
302
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkGT77U7QGcjs = require('./chunk-GT77U7QG.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkCVFAAZXEcjs = require('./chunk-CVFAAZXE.cjs');
|
|
@@ -47,7 +47,7 @@ var _chunkNM3G4VQTcjs = require('./chunk-NM3G4VQT.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkI7NJPHWVcjs = require('./chunk-I7NJPHWV.cjs');
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
@@ -2527,7 +2527,7 @@ function vectorExtrudeFaces(path, params) {
|
|
|
2527
2527
|
// src/vector/brushstroke.ts
|
|
2528
2528
|
var VECTOR_BRUSHSTROKE_SCALE = 2;
|
|
2529
2529
|
function vectorBrushstrokeBrushes() {
|
|
2530
|
-
return
|
|
2530
|
+
return _chunkGT77U7QGcjs.BUILTIN_BRUSHES.filter((b) => _chunkI7NJPHWVcjs.isBrushstrokeBrush.call(void 0, b));
|
|
2531
2531
|
}
|
|
2532
2532
|
function vectorBrushstrokeBrush(id) {
|
|
2533
2533
|
return _nullishCoalesce(vectorBrushstrokeBrushes().find((b) => b.id === id), () => ( null));
|
|
@@ -2558,7 +2558,7 @@ function sanitizeVectorBrushstrokePaper(value) {
|
|
|
2558
2558
|
if (!value || typeof value !== "object") return null;
|
|
2559
2559
|
const r = value;
|
|
2560
2560
|
const out = {};
|
|
2561
|
-
if (typeof r.pattern === "string" &&
|
|
2561
|
+
if (typeof r.pattern === "string" && _chunkI7NJPHWVcjs.GRAIN_PATTERNS.includes(r.pattern)) out.pattern = r.pattern;
|
|
2562
2562
|
const seed = sanitizeSeed(r.seed);
|
|
2563
2563
|
if (seed !== void 0) out.seed = seed;
|
|
2564
2564
|
if (finite2(r.scale) && r.scale > 0) out.scale = Math.min(8, Math.max(0.25, r.scale));
|
|
@@ -2573,7 +2573,7 @@ function vectorBrushstrokeCharacterError(brush) {
|
|
|
2573
2573
|
const r = paper;
|
|
2574
2574
|
const extra = Object.keys(r).filter((k) => !["pattern", "seed", "scale", "depth"].includes(k));
|
|
2575
2575
|
if (extra.length) return `paper has unknown field ${extra.map((k) => `"${k}"`).join(", ")}: use pattern, seed, scale, depth.`;
|
|
2576
|
-
if (r.pattern !== void 0 && !
|
|
2576
|
+
if (r.pattern !== void 0 && !_chunkI7NJPHWVcjs.GRAIN_PATTERNS.includes(r.pattern)) return `Unknown paper pattern "${String(r.pattern)}": use one of ${_chunkI7NJPHWVcjs.GRAIN_PATTERNS.join(", ")}.`;
|
|
2577
2577
|
if (r.seed !== void 0 && !(Number.isInteger(r.seed) && r.seed >= 0 && r.seed <= VECTOR_BRUSHSTROKE_MAX_SEED)) return `paper.seed must be an integer from 0 to ${VECTOR_BRUSHSTROKE_MAX_SEED}.`;
|
|
2578
2578
|
if (r.scale !== void 0 && !(finite2(r.scale) && r.scale >= 0.25 && r.scale <= 8)) return "paper.scale must be from 0.25 to 8 (1 is the pattern's natural size).";
|
|
2579
2579
|
if (r.depth !== void 0 && !(finite2(r.depth) && r.depth >= 0 && r.depth <= 1)) return "paper.depth must be from 0 to 1.";
|
|
@@ -2589,7 +2589,7 @@ function vectorBrushstrokeReach(layer) {
|
|
|
2589
2589
|
if (!isVectorBrushstrokeLayer(layer)) return 0;
|
|
2590
2590
|
return (_nullishCoalesce(layer.brush.size, () => ( vectorBrushstrokeBrush(layer.brush.brushId).tip.size))) / 2;
|
|
2591
2591
|
}
|
|
2592
|
-
var cache = new (0,
|
|
2592
|
+
var cache = new (0, _chunkI7NJPHWVcjs.BrushstrokeCache)(256);
|
|
2593
2593
|
var urls = /* @__PURE__ */ new WeakMap();
|
|
2594
2594
|
var layerCache = /* @__PURE__ */ new WeakMap();
|
|
2595
2595
|
function vectorBrushstrokeImages(node, layer) {
|
|
@@ -2614,7 +2614,7 @@ function vectorBrushstrokeImages(node, layer) {
|
|
|
2614
2614
|
const stroke = cache.render({ points: ring.map(([x, y]) => ({ x, y })), ...layer.brush.pressure ? { pressure: layer.brush.pressure } : {} }, brush, { scale: VECTOR_BRUSHSTROKE_SCALE, color: color2, maxPixels: 2048 * 2048, ...character });
|
|
2615
2615
|
if (!stroke.bounds) continue;
|
|
2616
2616
|
let href = urls.get(stroke);
|
|
2617
|
-
if (!href) urls.set(stroke, href =
|
|
2617
|
+
if (!href) urls.set(stroke, href = _chunkI7NJPHWVcjs.brushstrokeDataUrl.call(void 0, stroke));
|
|
2618
2618
|
out.push({ href, ...stroke.bounds });
|
|
2619
2619
|
}
|
|
2620
2620
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkWPUXGDH4cjs = require('./chunk-WPUXGDH4.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunkWPUXGDH4cjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunkWPUXGDH4cjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkWPUXGDH4cjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkL6REDLNBcjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunkWPUXGDH4cjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunkWPUXGDH4cjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
|
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunkWPUXGDH4cjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunkWPUXGDH4cjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkWPUXGDH4cjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunkWPUXGDH4cjs.expandVectorGradientStops.call(void 0, a), ..._chunkWPUXGDH4cjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunkWPUXGDH4cjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkWPUXGDH4cjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunkWPUXGDH4cjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkWPUXGDH4cjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkWPUXGDH4cjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunkWPUXGDH4cjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkWPUXGDH4cjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunkWPUXGDH4cjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkWPUXGDH4cjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunkWPUXGDH4cjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkWPUXGDH4cjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkWPUXGDH4cjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunkWPUXGDH4cjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunkWPUXGDH4cjs.nodeMatrix.call(void 0, a), mb = _chunkWPUXGDH4cjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunkWPUXGDH4cjs.isIdentityMatrix.call(void 0, ma) || !_chunkWPUXGDH4cjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkWPUXGDH4cjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkWPUXGDH4cjs.invertMatrix.call(void 0, m) : _chunkWPUXGDH4cjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkL6REDLNBcjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunkWPUXGDH4cjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunkWPUXGDH4cjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkWPUXGDH4cjs.multiplyMatrices.call(void 0, _chunkWPUXGDH4cjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkWPUXGDH4cjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunkWPUXGDH4cjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkWPUXGDH4cjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkWPUXGDH4cjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkWPUXGDH4cjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|