@pixerate/editor 0.248.0 → 0.249.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 +64 -61
- package/dist/animation-editor/index.js +8 -5
- package/dist/{brushstrokeRender-DTDPFBLC.cjs → brushstrokeRender-GCKK7V2I.cjs} +14 -11
- package/dist/{brushstrokeRender-QLCXROJK.js → brushstrokeRender-T3JZST44.js} +7 -4
- package/dist/canvas/index.cjs +8 -8
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-IBDU6EGZ.cjs → chunk-2SMMZDMG.cjs} +35 -35
- 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-4D6KP5BV.js +92 -0
- package/dist/chunk-5RH3VXAK.js +269 -0
- package/dist/{chunk-NZ3O3A5C.js → chunk-6BIDVPED.js} +1 -1
- package/dist/{chunk-2ONK3ERD.cjs → chunk-75K3W4D6.cjs} +20 -20
- package/dist/{chunk-7T7JWTVE.cjs → chunk-BOHDJJ2O.cjs} +8 -8
- package/dist/{chunk-2PBZBRP5.js → chunk-D5KGAO4Z.js} +10 -92
- package/dist/{chunk-5GLYUSNT.js → chunk-DOIU7VJG.js} +1 -1
- package/dist/{chunk-HB4ICNNA.cjs → chunk-DPYAO5U6.cjs} +42 -42
- package/dist/chunk-EJLRBS5Q.js +301 -0
- package/dist/{chunk-6G6ZDDDB.cjs → chunk-H4AOUUBE.cjs} +301 -149
- package/dist/{chunk-PQ3H2AAN.cjs → chunk-I7NJPHWV.cjs} +122 -204
- package/dist/{chunk-L6REDLNB.cjs → chunk-IOFVM3L3.cjs} +7 -7
- package/dist/{chunk-42TWUPNJ.js → chunk-IRSTHLQQ.js} +1 -320
- package/dist/{chunk-VNBUDVD4.js → chunk-J7T5QZ45.js} +226 -74
- package/dist/{chunk-VMROIWLL.cjs → chunk-KBYB7OWB.cjs} +3 -3
- package/dist/{chunk-TPWB4Y6L.cjs → chunk-KYX7NZ5V.cjs} +1 -1
- package/dist/chunk-LJRCU3BJ.cjs +301 -0
- package/dist/{chunk-WVS5KQDH.cjs → chunk-LP2MCSBE.cjs} +246 -244
- package/dist/{chunk-XNRBMYNB.js → chunk-O75V4ZS3.js} +1 -1
- package/dist/chunk-OTTT5N3K.js +322 -0
- package/dist/{chunk-Q2HA52V4.js → chunk-PZP2SZIZ.js} +2 -2
- package/dist/{chunk-ZFSLEOSQ.js → chunk-UBRJOIR5.js} +11 -9
- package/dist/chunk-W5M3J7PV.cjs +322 -0
- package/dist/{chunk-4P6H35HU.js → chunk-WA44NKPF.js} +2 -2
- package/dist/{chunk-XWTRATIM.cjs → chunk-WLJZZHUZ.cjs} +23 -23
- package/dist/{chunk-P3NIPIKS.js → chunk-WQCNC4DK.js} +1 -1
- package/dist/chunk-ZEYMKDYS.cjs +269 -0
- package/dist/image-editor/index.cjs +1055 -1050
- package/dist/image-editor/index.js +28 -23
- 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 +745 -602
- package/dist/paint-editor/index.d.cts +3 -0
- package/dist/paint-editor/index.d.ts +3 -0
- package/dist/paint-editor/index.js +184 -41
- 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 +331 -0
- package/dist/stickers/index.d.cts +16 -0
- package/dist/stickers/index.d.ts +16 -0
- package/dist/stickers/index.js +331 -0
- package/dist/stickers/stamps.d.cts +13 -0
- package/dist/stickers/stamps.d.ts +13 -0
- package/dist/stickers/tools.d.cts +25 -0
- package/dist/stickers/tools.d.ts +25 -0
- package/dist/stickers/types.d.cts +123 -0
- package/dist/stickers/types.d.ts +123 -0
- package/dist/vector/index.cjs +978 -975
- package/dist/vector/index.js +9 -6
- package/package.json +11 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +8 -5
- package/skills/pixerate-stickers/SKILL.md +45 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hash2
|
|
3
|
+
} from "./chunk-4D6KP5BV.js";
|
|
4
|
+
|
|
5
|
+
// src/stickers/stamps.ts
|
|
6
|
+
var STAMP_KINDS = ["dot", "star", "heart", "leaf", "flower", "confetti", "splat", "sparkle", "ring"];
|
|
7
|
+
function stampCoverage(kind, u, v, t) {
|
|
8
|
+
const r = Math.hypot(u, v);
|
|
9
|
+
const a = Math.atan2(v, u);
|
|
10
|
+
const edge = (d) => Math.min(1, Math.max(0, d * 24 + 0.5));
|
|
11
|
+
switch (kind) {
|
|
12
|
+
case "dot":
|
|
13
|
+
return edge(0.95 - r);
|
|
14
|
+
case "ring":
|
|
15
|
+
return edge(Math.min(0.95 - r, r - 0.6));
|
|
16
|
+
case "star": {
|
|
17
|
+
const f = (a + Math.PI / 2) * 5 / (2 * Math.PI) % 1;
|
|
18
|
+
const notch = Math.min(f < 0 ? f + 1 : f, 1 - (f < 0 ? f + 1 : f)) * 2;
|
|
19
|
+
return edge(0.95 - 0.55 * notch - r);
|
|
20
|
+
}
|
|
21
|
+
case "sparkle": {
|
|
22
|
+
const q = Math.pow(Math.abs(u) / 0.95, 0.6) + Math.pow(Math.abs(v) / 0.95, 0.6);
|
|
23
|
+
return edge((1 - q) * 0.4);
|
|
24
|
+
}
|
|
25
|
+
case "heart": {
|
|
26
|
+
const x = u * 1.1;
|
|
27
|
+
const y = -v * 1.1 + 0.15;
|
|
28
|
+
const q = x * x + y * y - 0.55;
|
|
29
|
+
return edge(-(q * q * q - x * x * y * y * y) * 3);
|
|
30
|
+
}
|
|
31
|
+
case "leaf": {
|
|
32
|
+
const w = 0.42 * Math.sqrt(Math.max(0, 1 - u * u));
|
|
33
|
+
const inside = edge(w - Math.abs(v + 0.15 * u * u));
|
|
34
|
+
const rib = Math.abs(v + 0.15 * u * u) < 0.03 && Math.abs(u) < 0.85 ? 0.65 : 1;
|
|
35
|
+
return inside * rib;
|
|
36
|
+
}
|
|
37
|
+
case "flower": {
|
|
38
|
+
const petals = 0.6 + 0.35 * Math.abs(Math.cos(2.5 * a));
|
|
39
|
+
const body = edge(petals - r);
|
|
40
|
+
return r < 0.22 ? Math.max(body, 1) * 0.85 : body;
|
|
41
|
+
}
|
|
42
|
+
case "confetti": {
|
|
43
|
+
return edge(Math.min(0.9 - Math.abs(u), 0.35 - Math.abs(v)));
|
|
44
|
+
}
|
|
45
|
+
case "splat": {
|
|
46
|
+
let rr = 0.55;
|
|
47
|
+
for (let k = 1; k <= 3; k++) rr += 0.08 * Math.sin(a * (k + 2) + hash2(k, 1, t) * 6.28) / k;
|
|
48
|
+
let c = edge(rr - r);
|
|
49
|
+
for (let k = 0; k < 4; k++) {
|
|
50
|
+
const ang = hash2(k, 7, t) * Math.PI * 2;
|
|
51
|
+
const dist = 0.72 + 0.2 * hash2(k, 9, t);
|
|
52
|
+
const dx = u - Math.cos(ang) * dist;
|
|
53
|
+
const dy = v - Math.sin(ang) * dist;
|
|
54
|
+
c = Math.max(c, edge(0.08 + 0.06 * hash2(k, 11, t) - Math.hypot(dx, dy)));
|
|
55
|
+
}
|
|
56
|
+
return c;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/stickers/errors.ts
|
|
62
|
+
var StickerError = class extends Error {
|
|
63
|
+
constructor(code, message) {
|
|
64
|
+
super(message);
|
|
65
|
+
this.code = code;
|
|
66
|
+
this.name = "StickerError";
|
|
67
|
+
}
|
|
68
|
+
code;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/stickers/helpers.ts
|
|
72
|
+
var DEFAULT_STICKER_PAGE = 24;
|
|
73
|
+
var MAX_STICKER_PAGE = 100;
|
|
74
|
+
var EDITOR_STICKERS_ID = "editor";
|
|
75
|
+
function checkStickerSearchOptions(options = {}) {
|
|
76
|
+
if (options.limit !== void 0 && !(Number.isInteger(options.limit) && options.limit >= 1 && options.limit <= MAX_STICKER_PAGE)) {
|
|
77
|
+
throw new StickerError("invalid_argument", `limit must be a whole number from 1 to ${MAX_STICKER_PAGE}, got ${options.limit}.`);
|
|
78
|
+
}
|
|
79
|
+
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.`);
|
|
80
|
+
}
|
|
81
|
+
var words = (s) => s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
82
|
+
function stickerPage(items, options = {}, query = "") {
|
|
83
|
+
checkStickerSearchOptions(options);
|
|
84
|
+
const q = words(query);
|
|
85
|
+
const tags = (options.tags ?? []).map((t) => t.toLowerCase());
|
|
86
|
+
const matches = items.filter((s) => {
|
|
87
|
+
if (options.category && s.category !== options.category) return false;
|
|
88
|
+
if (tags.length && !tags.every((t) => (s.tags ?? []).some((x) => x.toLowerCase() === t))) return false;
|
|
89
|
+
if (options.licence?.commercial === true && !s.licence.commercial) return false;
|
|
90
|
+
if (!q.length) return true;
|
|
91
|
+
const text = new Set(words([s.name, s.category, s.description ?? "", ...s.tags ?? []].join(" ")));
|
|
92
|
+
return q.every((w) => [...text].some((t) => t.startsWith(w)));
|
|
93
|
+
});
|
|
94
|
+
const start = options.after ? Number(options.after) : 0;
|
|
95
|
+
const limit = options.limit ?? DEFAULT_STICKER_PAGE;
|
|
96
|
+
const page = matches.slice(start, start + limit);
|
|
97
|
+
return { items: page, total: matches.length, ...start + limit < matches.length ? { next: String(start + limit) } : {} };
|
|
98
|
+
}
|
|
99
|
+
function parseStickerRef(ref) {
|
|
100
|
+
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).');
|
|
101
|
+
const i = ref.indexOf(":");
|
|
102
|
+
if (i === -1) {
|
|
103
|
+
if (STAMP_KINDS.includes(ref)) return { provider: EDITOR_STICKERS_ID, id: ref };
|
|
104
|
+
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.`);
|
|
105
|
+
}
|
|
106
|
+
if (i === 0 || i === ref.length - 1) throw new StickerError("invalid_argument", `"${ref}" is not a sticker ref; refs are "provider:id".`);
|
|
107
|
+
return { provider: ref.slice(0, i), id: ref.slice(i + 1) };
|
|
108
|
+
}
|
|
109
|
+
function normalizeStickerRef(ref) {
|
|
110
|
+
const { provider, id } = parseStickerRef(ref);
|
|
111
|
+
return `${provider}:${id}`;
|
|
112
|
+
}
|
|
113
|
+
function editorStampOf(ref) {
|
|
114
|
+
const { provider, id } = parseStickerRef(ref);
|
|
115
|
+
return provider === EDITOR_STICKERS_ID && STAMP_KINDS.includes(id) ? id : null;
|
|
116
|
+
}
|
|
117
|
+
function stickerRefOf(provider, id) {
|
|
118
|
+
return provider.namespaced ? id : `${provider.id}:${id}`;
|
|
119
|
+
}
|
|
120
|
+
function stickerIdFor(provider, ref) {
|
|
121
|
+
const { provider: owner, id } = parseStickerRef(ref);
|
|
122
|
+
if (provider.namespaced) return `${owner}:${id}`;
|
|
123
|
+
return owner === provider.id ? id : null;
|
|
124
|
+
}
|
|
125
|
+
function closestStickerRefs(wanted, candidates, n = 3) {
|
|
126
|
+
const w = wanted.toLowerCase();
|
|
127
|
+
const dist = (a, b) => {
|
|
128
|
+
const d = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
129
|
+
for (let i = 1; i <= a.length; i++) {
|
|
130
|
+
let prev = d[0];
|
|
131
|
+
d[0] = i;
|
|
132
|
+
for (let j = 1; j <= b.length; j++) {
|
|
133
|
+
const tmp = d[j];
|
|
134
|
+
d[j] = Math.min(d[j] + 1, d[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
135
|
+
prev = tmp;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return d[b.length];
|
|
139
|
+
};
|
|
140
|
+
return [...candidates].sort((a, b) => dist(w, a.toLowerCase()) - dist(w, b.toLowerCase()) || a.localeCompare(b)).slice(0, n);
|
|
141
|
+
}
|
|
142
|
+
var StickersSlot = class {
|
|
143
|
+
constructor(fallback) {
|
|
144
|
+
this.fallback = fallback;
|
|
145
|
+
this.current = fallback;
|
|
146
|
+
}
|
|
147
|
+
fallback;
|
|
148
|
+
current;
|
|
149
|
+
listeners = /* @__PURE__ */ new Set();
|
|
150
|
+
get provider() {
|
|
151
|
+
return this.current;
|
|
152
|
+
}
|
|
153
|
+
set(provider) {
|
|
154
|
+
const next = provider ?? this.fallback;
|
|
155
|
+
if (next === this.current) return;
|
|
156
|
+
this.current = next;
|
|
157
|
+
for (const l of [...this.listeners]) l(next);
|
|
158
|
+
}
|
|
159
|
+
subscribe(listener) {
|
|
160
|
+
this.listeners.add(listener);
|
|
161
|
+
return () => this.listeners.delete(listener);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/stickers/tools.ts
|
|
166
|
+
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
167
|
+
function stickerForAgent(provider, s) {
|
|
168
|
+
const { id, thumbnail: _thumbnail, ...rest } = s;
|
|
169
|
+
return { ref: stickerRefOf(provider, id), ...rest };
|
|
170
|
+
}
|
|
171
|
+
async function knownRefs(provider, cap = 500) {
|
|
172
|
+
const refs = [];
|
|
173
|
+
let after;
|
|
174
|
+
while (refs.length < cap) {
|
|
175
|
+
const page = await provider.list({ limit: MAX_STICKER_PAGE, ...after ? { after } : {} });
|
|
176
|
+
refs.push(...page.items.map((s) => stickerRefOf(provider, s.id)));
|
|
177
|
+
if (!page.next || !page.items.length) break;
|
|
178
|
+
after = page.next;
|
|
179
|
+
}
|
|
180
|
+
return refs;
|
|
181
|
+
}
|
|
182
|
+
async function describeStickerRef(provider, ref) {
|
|
183
|
+
parseStickerRef(ref);
|
|
184
|
+
const id = stickerIdFor(provider, ref);
|
|
185
|
+
const found = id === null ? void 0 : await provider.describe(id);
|
|
186
|
+
if (found) return found;
|
|
187
|
+
const near = closestStickerRefs(ref, await knownRefs(provider));
|
|
188
|
+
const owner = parseStickerRef(ref).provider;
|
|
189
|
+
const where = id === null && !provider.namespaced ? ` The sticker library is "${provider.id}", not "${owner}".` : "";
|
|
190
|
+
throw new StickerError("unknown_sticker", `No sticker "${ref}".${where} Closest: ${near.join(", ") || "none"}; find_stickers lists them.`);
|
|
191
|
+
}
|
|
192
|
+
function createStickerTools(options) {
|
|
193
|
+
const find = {
|
|
194
|
+
name: "find_stickers",
|
|
195
|
+
title: "Find stickers",
|
|
196
|
+
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.",
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: "object",
|
|
199
|
+
properties: {
|
|
200
|
+
query: { type: "string", maxLength: 200, description: "Words to match (default: list everything)." },
|
|
201
|
+
category: { type: "string", description: "Only this category (the result lists them)." },
|
|
202
|
+
tags: { type: "array", maxItems: 10, items: { type: "string", description: "A tag." }, description: "Only stickers with every one of these tags." },
|
|
203
|
+
commercial: { type: "boolean", description: "true: only stickers whose licence allows commercial use." },
|
|
204
|
+
limit: { type: "integer", minimum: 1, maximum: MAX_STICKER_PAGE, description: "Page size (default 24)." },
|
|
205
|
+
after: { type: "string", description: "next from the previous page." }
|
|
206
|
+
},
|
|
207
|
+
additionalProperties: false
|
|
208
|
+
},
|
|
209
|
+
annotations: { title: "Find stickers", ...READ },
|
|
210
|
+
handler: async ({ query, category, tags, commercial, limit, after }) => {
|
|
211
|
+
const p = options.provider();
|
|
212
|
+
const categories = await p.categories?.() ?? null;
|
|
213
|
+
if (category !== void 0 && categories && !categories.some((c) => c.id === category)) {
|
|
214
|
+
throw new StickerError("invalid_argument", `No category "${category}" in "${p.name}"; categories: ${categories.map((c) => c.id).join(", ")}.`);
|
|
215
|
+
}
|
|
216
|
+
const o = { ...category !== void 0 ? { category } : {}, ...tags ? { tags } : {}, ...commercial ? { licence: { commercial: true } } : {}, ...limit !== void 0 ? { limit } : {}, ...after !== void 0 ? { after } : {} };
|
|
217
|
+
const q = typeof query === "string" ? query.trim() : "";
|
|
218
|
+
if (q && !p.capabilities.supportsSearch) throw new StickerError("invalid_argument", `"${p.name}" can't search; leave query out and filter by category instead.`);
|
|
219
|
+
const page = q ? await p.search(q, o) : await p.list(o);
|
|
220
|
+
return { provider: p.id, items: page.items.map((s) => stickerForAgent(p, s)), total: page.total, ...page.next ? { next: page.next } : {}, ...categories ? { categories } : {} };
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const describe = {
|
|
224
|
+
name: "describe_sticker",
|
|
225
|
+
title: "Describe a sticker",
|
|
226
|
+
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.",
|
|
227
|
+
inputSchema: { type: "object", properties: { ref: { type: "string", description: "Sticker ref provider:id from find_stickers (e.g. editor:star)." } }, required: ["ref"], additionalProperties: false },
|
|
228
|
+
annotations: { title: "Describe a sticker", ...READ },
|
|
229
|
+
handler: async ({ ref }) => {
|
|
230
|
+
const p = options.provider();
|
|
231
|
+
const d = await describeStickerRef(p, ref);
|
|
232
|
+
const { thumbnail: _thumbnail, id, ...rest } = d;
|
|
233
|
+
return { ref: stickerRefOf(p, id), ...rest };
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
return [find, describe];
|
|
237
|
+
}
|
|
238
|
+
function createStickerToolProvider(options) {
|
|
239
|
+
return {
|
|
240
|
+
id: options.id ?? "stickers",
|
|
241
|
+
namespace: options.namespace,
|
|
242
|
+
title: "Stickers",
|
|
243
|
+
description: "Find and describe stickers from the sticker library, by ref (provider:id), for the editors that spray or place them.",
|
|
244
|
+
skill: "pixerate-stickers",
|
|
245
|
+
tools: createStickerTools(options)
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export {
|
|
250
|
+
STAMP_KINDS,
|
|
251
|
+
stampCoverage,
|
|
252
|
+
StickerError,
|
|
253
|
+
DEFAULT_STICKER_PAGE,
|
|
254
|
+
MAX_STICKER_PAGE,
|
|
255
|
+
EDITOR_STICKERS_ID,
|
|
256
|
+
checkStickerSearchOptions,
|
|
257
|
+
stickerPage,
|
|
258
|
+
parseStickerRef,
|
|
259
|
+
normalizeStickerRef,
|
|
260
|
+
editorStampOf,
|
|
261
|
+
stickerRefOf,
|
|
262
|
+
stickerIdFor,
|
|
263
|
+
closestStickerRefs,
|
|
264
|
+
StickersSlot,
|
|
265
|
+
stickerForAgent,
|
|
266
|
+
describeStickerRef,
|
|
267
|
+
createStickerTools,
|
|
268
|
+
createStickerToolProvider
|
|
269
|
+
};
|
|
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
|
|
|
74
74
|
var round3 = (v) => Math.round(v * 1e3) / 1e3;
|
|
75
75
|
var loading = null;
|
|
76
76
|
function loadCanvasBrushstrokeRenderer() {
|
|
77
|
-
loading ??= import("./brushstrokeRender-
|
|
77
|
+
loading ??= import("./brushstrokeRender-T3JZST44.js").catch((error) => {
|
|
78
78
|
loading = null;
|
|
79
79
|
throw error;
|
|
80
80
|
});
|
|
@@ -13,12 +13,12 @@ var _chunkBB6TR422cjs = require('./chunk-BB6TR422.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkI7NJPHWVcjs = require('./chunk-I7NJPHWV.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk2VX55NFMcjs = require('./chunk-2VX55NFM.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -367,9 +367,9 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
367
367
|
const g0 = rgb[1];
|
|
368
368
|
const b0 = rgb[2];
|
|
369
369
|
paint.tone(rgb);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i, r0 + (rgb[0] - r0) * k);
|
|
371
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i + 1, g0 + (rgb[1] - g0) * k);
|
|
372
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i + 2, b0 + (rgb[2] - b0) * k);
|
|
373
373
|
continue;
|
|
374
374
|
}
|
|
375
375
|
if (s.lockTransparency && a === 0) continue;
|
|
@@ -383,11 +383,11 @@ function applyRetouchToTile(coverage, tileData, channels, tx, ty, paint, s, opti
|
|
|
383
383
|
cb[ch] = out[i + ch] / 255;
|
|
384
384
|
cs[ch] = src[ch] / 255;
|
|
385
385
|
}
|
|
386
|
-
const o =
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (!s.lockTransparency)
|
|
386
|
+
const o = _chunk2VX55NFMcjs.blendPixel.call(void 0, blend, cb, cs, k);
|
|
387
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i, o[0]);
|
|
388
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i + 1, o[1]);
|
|
389
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, out, i + 2, o[2]);
|
|
390
|
+
if (!s.lockTransparency) _chunkI7NJPHWVcjs.put255.call(void 0, out, i + 3, o[3]);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
return out;
|
|
@@ -443,14 +443,14 @@ function applyToneToDeepTile(coverage, samples, tx, ty, tone, s, options = {}) {
|
|
|
443
443
|
const v = out[i + ch];
|
|
444
444
|
if (linear) {
|
|
445
445
|
excess[ch] = v > 1 ? v - 1 : 0;
|
|
446
|
-
rgb[ch] =
|
|
446
|
+
rgb[ch] = _chunk2VX55NFMcjs.srgbEncode.call(void 0, v > 1 ? 1 : v < 0 ? 0 : v);
|
|
447
447
|
} else rgb[ch] = v / 65535;
|
|
448
448
|
before[ch] = rgb[ch];
|
|
449
449
|
}
|
|
450
450
|
tone(rgb);
|
|
451
451
|
for (let ch = 0; ch < 3; ch++) {
|
|
452
452
|
const e = before[ch] + (rgb[ch] - before[ch]) * k;
|
|
453
|
-
if (linear) out[i + ch] =
|
|
453
|
+
if (linear) out[i + ch] = _chunk2VX55NFMcjs.srgbDecode.call(void 0, e) + excess[ch];
|
|
454
454
|
else out[i + ch] = e <= 0 ? 0 : e >= 1 ? 65535 : Math.round(e * 65535);
|
|
455
455
|
}
|
|
456
456
|
}
|
|
@@ -535,8 +535,8 @@ var RetouchDabStroke = (_class3 = class {
|
|
|
535
535
|
constructor(brush, target, effect) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);
|
|
536
536
|
this.brush = brush;
|
|
537
537
|
this.effect = effect;
|
|
538
|
-
this.walker = new (0,
|
|
539
|
-
this.medium = new (0,
|
|
538
|
+
this.walker = new (0, _chunkI7NJPHWVcjs.DabWalker)(brush);
|
|
539
|
+
this.medium = new (0, _chunkI7NJPHWVcjs.TileMedium)(target);
|
|
540
540
|
}
|
|
541
541
|
|
|
542
542
|
|
|
@@ -567,11 +567,11 @@ var RetouchDabStroke = (_class3 = class {
|
|
|
567
567
|
paint(dabs) {
|
|
568
568
|
const rects = [];
|
|
569
569
|
for (const d of dabs) {
|
|
570
|
-
const rect =
|
|
570
|
+
const rect = _chunkI7NJPHWVcjs.dabRect.call(void 0, d, this.brush.hardness);
|
|
571
571
|
const n = rect.width * rect.height;
|
|
572
572
|
if (this.buf.length < n) this.buf = new Float32Array(n);
|
|
573
573
|
const cov = this.buf.subarray(0, n);
|
|
574
|
-
|
|
574
|
+
_chunkI7NJPHWVcjs.rasterizeDab.call(void 0, { ...d, alpha: 1 }, this.brush.hardness, rect, cov);
|
|
575
575
|
this.medium.reset();
|
|
576
576
|
this.effect(this.medium, d, rect, cov);
|
|
577
577
|
rects.push(rect);
|
|
@@ -583,7 +583,7 @@ var RetouchDabStroke = (_class3 = class {
|
|
|
583
583
|
}, _class3);
|
|
584
584
|
function smudgeEffect(brush, strength, mixing = "rgb") {
|
|
585
585
|
const s = Math.min(1, Math.max(0, strength));
|
|
586
|
-
const tip = new (0,
|
|
586
|
+
const tip = new (0, _chunkI7NJPHWVcjs.SmudgeTip)({ strength: s, length: s, mixing }, brush.size);
|
|
587
587
|
return (medium, d, rect, cov) => tip.dab(medium, { x: d.x, y: d.y, radius: d.radius, opacity: d.opacity * d.alpha }, rect, cov);
|
|
588
588
|
}
|
|
589
589
|
function spongeEffect(brush, saturate, vibrance) {
|
|
@@ -606,9 +606,9 @@ function spongeEffect(brush, saturate, vibrance) {
|
|
|
606
606
|
rgb[1] = px[i + 1] / 255;
|
|
607
607
|
rgb[2] = px[i + 2] / 255;
|
|
608
608
|
sponge(rgb, k, saturate, vibrance);
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
609
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, px, i, rgb[0]);
|
|
610
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, px, i + 1, rgb[1]);
|
|
611
|
+
_chunkI7NJPHWVcjs.put255.call(void 0, px, i + 2, rgb[2]);
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
};
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkDPYAO5U6cjs = require('./chunk-DPYAO5U6.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk2VX55NFMcjs = require('./chunk-2VX55NFM.cjs');
|
|
12
12
|
|
|
13
13
|
// src/raster/effects/ui.ts
|
|
14
14
|
function layerEffectsPanel(layer) {
|
|
@@ -23,18 +23,18 @@ function layerEffectsPanel(layer) {
|
|
|
23
23
|
reason: readOnly ? "The layer is locked; unlock it to change its layer style." : void 0,
|
|
24
24
|
enabled: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _3 => _3.enabled]), () => ( true)),
|
|
25
25
|
scale: _nullishCoalesce(_optionalChain([fx, 'optionalAccess', _4 => _4.scale]), () => ( 1)),
|
|
26
|
-
rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess', _5 => _5.items]), () => ( []))).map((e) => ({ id: e.id, kind: e.kind, label:
|
|
26
|
+
rows: (_nullishCoalesce(_optionalChain([fx, 'optionalAccess', _5 => _5.items]), () => ( []))).map((e) => ({ id: e.id, kind: e.kind, label: _chunkDPYAO5U6cjs.layerEffectLabel.call(void 0, e.kind), enabled: e.enabled }))
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
function layerEffectsBadge(layer) {
|
|
30
30
|
if (!_optionalChain([layer, 'access', _6 => _6.effects, 'optionalAccess', _7 => _7.items, 'access', _8 => _8.length])) return null;
|
|
31
|
-
return
|
|
31
|
+
return _chunkDPYAO5U6cjs.hasActiveEffects.call(void 0, layer.effects) ? "on" : "off";
|
|
32
32
|
}
|
|
33
|
-
var LAYER_EFFECT_MENU =
|
|
34
|
-
var BLENDS =
|
|
33
|
+
var LAYER_EFFECT_MENU = _chunkDPYAO5U6cjs.LAYER_EFFECT_KINDS.map((kind) => ({ kind, label: _chunkDPYAO5U6cjs.layerEffectLabel.call(void 0, kind) }));
|
|
34
|
+
var BLENDS = _chunk2VX55NFMcjs.BLEND_MODES.filter((m) => m.id !== "pigment").map((m) => ({ value: m.id, label: m.label }));
|
|
35
35
|
var opt = (...pairs) => pairs.map(([value, label]) => ({ value, label }));
|
|
36
36
|
function patternOptions(patterns) {
|
|
37
|
-
return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ...
|
|
37
|
+
return [...patterns.map((p) => ({ value: p.id, label: p.name || p.id })), ..._chunkDPYAO5U6cjs.builtinPatternIds.call(void 0, ).map((id) => ({ value: id, label: _chunkDPYAO5U6cjs.builtinPattern.call(void 0, id).name }))];
|
|
38
38
|
}
|
|
39
39
|
function getPath(o, path) {
|
|
40
40
|
let v = o;
|
|
@@ -164,7 +164,7 @@ function layerEffectControls(e, patterns = []) {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
function fillOfType(current, type, patterns) {
|
|
167
|
-
if (type === "gradient") return { type: "gradient", gradient:
|
|
167
|
+
if (type === "gradient") return { type: "gradient", gradient: _chunkDPYAO5U6cjs.defaultEffectGradient.call(void 0, ) };
|
|
168
168
|
if (type === "pattern") return { type: "pattern", patternId: _nullishCoalesce(_optionalChain([patterns, 'access', _15 => _15[0], 'optionalAccess', _16 => _16.id]), () => ( "checker")), scale: 1 };
|
|
169
169
|
return { type: "color", color: current.type === "color" ? current.color : "#000000" };
|
|
170
170
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TileableNoise,
|
|
3
|
+
hash2,
|
|
4
|
+
rand01,
|
|
5
|
+
randSigned
|
|
6
|
+
} from "./chunk-4D6KP5BV.js";
|
|
1
7
|
import {
|
|
2
8
|
BRUSHSTROKE_MAX_SCALE,
|
|
3
9
|
BRUSHSTROKE_MIN_SCALE
|
|
@@ -10,11 +16,13 @@ import {
|
|
|
10
16
|
mixPigment8,
|
|
11
17
|
mixPigmentRgb,
|
|
12
18
|
pigment8,
|
|
13
|
-
pngDataUrl,
|
|
14
19
|
setPigmentColor,
|
|
15
20
|
srgbDecode,
|
|
16
21
|
srgbEncode
|
|
17
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-IRSTHLQQ.js";
|
|
23
|
+
import {
|
|
24
|
+
pngDataUrl
|
|
25
|
+
} from "./chunk-OTTT5N3K.js";
|
|
18
26
|
import {
|
|
19
27
|
TILE,
|
|
20
28
|
TiledSurface,
|
|
@@ -26,90 +34,6 @@ import {
|
|
|
26
34
|
tilesInRect
|
|
27
35
|
} from "./chunk-HVVR5PZW.js";
|
|
28
36
|
|
|
29
|
-
// src/paint/rand.ts
|
|
30
|
-
function mix32(h) {
|
|
31
|
-
h ^= h >>> 16;
|
|
32
|
-
h = Math.imul(h, 2246822507);
|
|
33
|
-
h ^= h >>> 13;
|
|
34
|
-
h = Math.imul(h, 3266489909);
|
|
35
|
-
h ^= h >>> 16;
|
|
36
|
-
return h >>> 0;
|
|
37
|
-
}
|
|
38
|
-
function hash2(x, y, salt) {
|
|
39
|
-
const h = mix32((Math.imul(x | 0, 668265261) ^ mix32((y | 0) + Math.imul(salt | 0, 374761393))) >>> 0);
|
|
40
|
-
return h / 4294967296;
|
|
41
|
-
}
|
|
42
|
-
function rand01(seed, index, stream) {
|
|
43
|
-
return hash2(index, stream, seed);
|
|
44
|
-
}
|
|
45
|
-
function randSigned(seed, index, stream) {
|
|
46
|
-
return rand01(seed, index, stream) * 2 - 1;
|
|
47
|
-
}
|
|
48
|
-
function seedFromString(text) {
|
|
49
|
-
let h = 2166136261;
|
|
50
|
-
for (let i = 0; i < text.length; i++) {
|
|
51
|
-
h ^= text.charCodeAt(i);
|
|
52
|
-
h = Math.imul(h, 16777619);
|
|
53
|
-
}
|
|
54
|
-
return mix32(h >>> 0);
|
|
55
|
-
}
|
|
56
|
-
var smooth = (t) => t * t * (3 - 2 * t);
|
|
57
|
-
var Lattice = class {
|
|
58
|
-
constructor(px, py, salt) {
|
|
59
|
-
this.px = px;
|
|
60
|
-
this.py = py;
|
|
61
|
-
this.values = new Float32Array(px * py);
|
|
62
|
-
for (let j = 0; j < py; j++) for (let i = 0; i < px; i++) this.values[j * px + i] = hash2(i, j, salt);
|
|
63
|
-
}
|
|
64
|
-
px;
|
|
65
|
-
py;
|
|
66
|
-
values;
|
|
67
|
-
/** Value noise at (x, y) in lattice cells; wraps every `px` / `py` cells. */
|
|
68
|
-
at(x, y) {
|
|
69
|
-
const { px, py } = this;
|
|
70
|
-
const x0 = Math.floor(x);
|
|
71
|
-
const y0 = Math.floor(y);
|
|
72
|
-
const tx = smooth(x - x0);
|
|
73
|
-
const ty = smooth(y - y0);
|
|
74
|
-
const i0 = (x0 % px + px) % px;
|
|
75
|
-
const j0 = (y0 % py + py) % py;
|
|
76
|
-
const i1 = (i0 + 1) % px;
|
|
77
|
-
const j1 = (j0 + 1) % py;
|
|
78
|
-
const v = this.values;
|
|
79
|
-
const a = v[j0 * px + i0] + (v[j0 * px + i1] - v[j0 * px + i0]) * tx;
|
|
80
|
-
const b = v[j1 * px + i0] + (v[j1 * px + i1] - v[j1 * px + i0]) * tx;
|
|
81
|
-
return a + (b - a) * ty;
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
var TileableNoise = class {
|
|
85
|
-
constructor(size, cellsX, cellsY, octaves, salt) {
|
|
86
|
-
this.size = size;
|
|
87
|
-
let cx = Math.max(1, Math.round(cellsX));
|
|
88
|
-
let cy = Math.max(1, Math.round(cellsY));
|
|
89
|
-
for (let o = 0; o < octaves; o++) {
|
|
90
|
-
this.octaves.push(new Lattice(cx, cy, salt + o * 7919 | 0));
|
|
91
|
-
cx *= 2;
|
|
92
|
-
cy *= 2;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
size;
|
|
96
|
-
octaves = [];
|
|
97
|
-
/** Fractal noise at pixel (x, y). */
|
|
98
|
-
at(x, y) {
|
|
99
|
-
let sum = 0;
|
|
100
|
-
let amp = 1;
|
|
101
|
-
let norm = 0;
|
|
102
|
-
const u = x / this.size;
|
|
103
|
-
const v = y / this.size;
|
|
104
|
-
for (const l of this.octaves) {
|
|
105
|
-
sum += l.at(u * l.px, v * l.py) * amp;
|
|
106
|
-
norm += amp;
|
|
107
|
-
amp *= 0.5;
|
|
108
|
-
}
|
|
109
|
-
return norm > 0 ? sum / norm : 0.5;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
37
|
// src/paint/gradient-paint.ts
|
|
114
38
|
var PAINT_GRADIENT_SPACES = ["pigment", "oklab", "srgb"];
|
|
115
39
|
var PAINT_GRADIENT_REPEATS = ["clamp", "repeat", "mirror"];
|
|
@@ -2321,12 +2245,6 @@ function union(a, b) {
|
|
|
2321
2245
|
}
|
|
2322
2246
|
|
|
2323
2247
|
export {
|
|
2324
|
-
mix32,
|
|
2325
|
-
hash2,
|
|
2326
|
-
rand01,
|
|
2327
|
-
randSigned,
|
|
2328
|
-
seedFromString,
|
|
2329
|
-
TileableNoise,
|
|
2330
2248
|
PAINT_GRADIENT_SPACES,
|
|
2331
2249
|
PAINT_GRADIENT_REPEATS,
|
|
2332
2250
|
PAINT_GRADIENT_MAPPINGS,
|