@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,303 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk4JNWA3VTcjs = require('./chunk-4JNWA3VT.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkU67EN7GGcjs = require('./chunk-U67EN7GG.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _chunkW5M3J7PVcjs = require('./chunk-W5M3J7PV.cjs');
|
|
14
|
+
|
|
15
|
+
// src/stickers/editor.ts
|
|
16
|
+
var BOX = 100;
|
|
17
|
+
var GRID = 128;
|
|
18
|
+
var SHAPE_SEED = 7;
|
|
19
|
+
var LICENCE = { spdx: "MIT", name: "MIT", commercial: true };
|
|
20
|
+
var META = {
|
|
21
|
+
dot: { name: "Dot", category: "shapes", tags: ["circle", "round", "spot"], colour: "#2563eb", description: "A round dot." },
|
|
22
|
+
star: { name: "Star", category: "shapes", tags: ["five-pointed", "favourite", "rating"], colour: "#f59e0b", description: "A five-pointed star, one point up." },
|
|
23
|
+
heart: { name: "Heart", category: "shapes", tags: ["love", "like"], colour: "#e11d48", description: "A heart." },
|
|
24
|
+
leaf: { name: "Leaf", category: "nature", tags: ["plant", "green"], colour: "#16a34a", description: "A pointed leaf with a midrib." },
|
|
25
|
+
flower: { name: "Flower", category: "nature", tags: ["petals", "blossom"], colour: "#db2777", description: "A five-petal flower." },
|
|
26
|
+
confetti: { name: "Confetti", category: "party", tags: ["celebration", "rectangle"], colour: "#7c3aed", description: "A small strip of confetti." },
|
|
27
|
+
splat: { name: "Splat", category: "party", tags: ["paint", "splash", "blob"], colour: "#0891b2", description: "A paint splat with drops." },
|
|
28
|
+
sparkle: { name: "Sparkle", category: "party", tags: ["twinkle", "shine", "glint"], colour: "#eab308", description: "A four-pointed twinkle." },
|
|
29
|
+
ring: { name: "Ring", category: "shapes", tags: ["circle", "outline", "hoop"], colour: "#0f766e", description: "A ring." }
|
|
30
|
+
};
|
|
31
|
+
var HEX = /^#[0-9a-fA-F]{6}$/;
|
|
32
|
+
function stampOutline(kind) {
|
|
33
|
+
const n = GRID;
|
|
34
|
+
const f = new Float32Array((n + 1) * (n + 1));
|
|
35
|
+
for (let j = 0; j <= n; j++) for (let i = 0; i <= n; i++) f[j * (n + 1) + i] = _chunk4JNWA3VTcjs.stampCoverage.call(void 0, kind, i / n * 2 - 1, j / n * 2 - 1, SHAPE_SEED) - 0.5;
|
|
36
|
+
const at = (i, j) => f[j * (n + 1) + i];
|
|
37
|
+
const points = /* @__PURE__ */ new Map();
|
|
38
|
+
const point = (key, i0, j0, i1, j1) => {
|
|
39
|
+
if (!points.has(key)) {
|
|
40
|
+
const a = at(i0, j0);
|
|
41
|
+
const b = at(i1, j1);
|
|
42
|
+
const t = a / (a - b);
|
|
43
|
+
points.set(key, [(i0 + (i1 - i0) * t) / n * BOX, (j0 + (j1 - j0) * t) / n * BOX]);
|
|
44
|
+
}
|
|
45
|
+
return key;
|
|
46
|
+
};
|
|
47
|
+
const next = /* @__PURE__ */ new Map();
|
|
48
|
+
for (let j = 0; j < n; j++) {
|
|
49
|
+
for (let i = 0; i < n; i++) {
|
|
50
|
+
const tl = at(i, j) > 0 ? 1 : 0;
|
|
51
|
+
const tr = at(i + 1, j) > 0 ? 1 : 0;
|
|
52
|
+
const br = at(i + 1, j + 1) > 0 ? 1 : 0;
|
|
53
|
+
const bl = at(i, j + 1) > 0 ? 1 : 0;
|
|
54
|
+
const code = tl << 3 | tr << 2 | br << 1 | bl;
|
|
55
|
+
if (code === 0 || code === 15) continue;
|
|
56
|
+
const top = () => point(`h${i},${j}`, i, j, i + 1, j);
|
|
57
|
+
const right = () => point(`v${i + 1},${j}`, i + 1, j, i + 1, j + 1);
|
|
58
|
+
const bottom = () => point(`h${i},${j + 1}`, i, j + 1, i + 1, j + 1);
|
|
59
|
+
const left = () => point(`v${i},${j}`, i, j, i, j + 1);
|
|
60
|
+
const seg = (a, b) => next.set(a, b);
|
|
61
|
+
const centre = at(i, j) + at(i + 1, j) + at(i + 1, j + 1) + at(i, j + 1) > 0;
|
|
62
|
+
switch (code) {
|
|
63
|
+
case 1:
|
|
64
|
+
seg(left(), bottom());
|
|
65
|
+
break;
|
|
66
|
+
case 2:
|
|
67
|
+
seg(bottom(), right());
|
|
68
|
+
break;
|
|
69
|
+
case 3:
|
|
70
|
+
seg(left(), right());
|
|
71
|
+
break;
|
|
72
|
+
case 4:
|
|
73
|
+
seg(right(), top());
|
|
74
|
+
break;
|
|
75
|
+
case 5:
|
|
76
|
+
if (centre) {
|
|
77
|
+
seg(left(), top());
|
|
78
|
+
seg(right(), bottom());
|
|
79
|
+
} else {
|
|
80
|
+
seg(left(), bottom());
|
|
81
|
+
seg(right(), top());
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 6:
|
|
85
|
+
seg(bottom(), top());
|
|
86
|
+
break;
|
|
87
|
+
case 7:
|
|
88
|
+
seg(left(), top());
|
|
89
|
+
break;
|
|
90
|
+
case 8:
|
|
91
|
+
seg(top(), left());
|
|
92
|
+
break;
|
|
93
|
+
case 9:
|
|
94
|
+
seg(top(), bottom());
|
|
95
|
+
break;
|
|
96
|
+
case 10:
|
|
97
|
+
if (centre) {
|
|
98
|
+
seg(top(), right());
|
|
99
|
+
seg(bottom(), left());
|
|
100
|
+
} else {
|
|
101
|
+
seg(top(), left());
|
|
102
|
+
seg(bottom(), right());
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
case 11:
|
|
106
|
+
seg(top(), right());
|
|
107
|
+
break;
|
|
108
|
+
case 12:
|
|
109
|
+
seg(right(), left());
|
|
110
|
+
break;
|
|
111
|
+
case 13:
|
|
112
|
+
seg(right(), bottom());
|
|
113
|
+
break;
|
|
114
|
+
case 14:
|
|
115
|
+
seg(bottom(), left());
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const loops = [];
|
|
121
|
+
const seen = /* @__PURE__ */ new Set();
|
|
122
|
+
for (const start of next.keys()) {
|
|
123
|
+
if (seen.has(start)) continue;
|
|
124
|
+
const loop = [];
|
|
125
|
+
let k = start;
|
|
126
|
+
while (k !== void 0 && !seen.has(k)) {
|
|
127
|
+
seen.add(k);
|
|
128
|
+
loop.push(points.get(k));
|
|
129
|
+
k = next.get(k);
|
|
130
|
+
}
|
|
131
|
+
if (loop.length >= 3) loops.push(simplify(loop, 0.12));
|
|
132
|
+
}
|
|
133
|
+
const fmt = (v) => String(Math.round(v * 100) / 100);
|
|
134
|
+
return loops.map((l) => "M" + l.map(([x, y]) => `${fmt(x)} ${fmt(y)}`).join("L") + "Z").join("");
|
|
135
|
+
}
|
|
136
|
+
function simplify(loop, eps) {
|
|
137
|
+
if (loop.length < 8) return loop;
|
|
138
|
+
const keep = new Uint8Array(loop.length);
|
|
139
|
+
const rdp = (a, b) => {
|
|
140
|
+
const [ax, ay] = loop[a];
|
|
141
|
+
const [bx, by] = loop[b];
|
|
142
|
+
const len = Math.hypot(bx - ax, by - ay) || 1e-9;
|
|
143
|
+
let worst = -1;
|
|
144
|
+
let far = 0;
|
|
145
|
+
for (let i = a + 1; i < b; i++) {
|
|
146
|
+
const d = Math.abs((bx - ax) * (ay - loop[i][1]) - (ax - loop[i][0]) * (by - ay)) / len;
|
|
147
|
+
if (d > far) {
|
|
148
|
+
far = d;
|
|
149
|
+
worst = i;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (worst !== -1 && far > eps) {
|
|
153
|
+
keep[worst] = 1;
|
|
154
|
+
rdp(a, worst);
|
|
155
|
+
rdp(worst, b);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const mid = Math.floor(loop.length / 2);
|
|
159
|
+
keep[0] = keep[mid] = 1;
|
|
160
|
+
rdp(0, mid);
|
|
161
|
+
rdp(mid, loop.length - 1);
|
|
162
|
+
keep[loop.length - 1] = 1;
|
|
163
|
+
return loop.filter((_, i) => keep[i]);
|
|
164
|
+
}
|
|
165
|
+
function stampPixels(kind, size, colour) {
|
|
166
|
+
const out = new Uint8ClampedArray(size * size * 4);
|
|
167
|
+
const n = parseInt(colour.slice(1), 16);
|
|
168
|
+
const ss = size <= 128 ? 3 : 2;
|
|
169
|
+
for (let y = 0; y < size; y++) {
|
|
170
|
+
for (let x = 0; x < size; x++) {
|
|
171
|
+
let c = 0;
|
|
172
|
+
for (let sy = 0; sy < ss; sy++) for (let sx = 0; sx < ss; sx++) c += _chunk4JNWA3VTcjs.stampCoverage.call(void 0, kind, (x + (sx + 0.5) / ss) / size * 2 - 1, (y + (sy + 0.5) / ss) / size * 2 - 1, SHAPE_SEED);
|
|
173
|
+
const a = Math.round(c / (ss * ss) * 255);
|
|
174
|
+
if (!a) continue;
|
|
175
|
+
const i = (y * size + x) * 4;
|
|
176
|
+
out[i] = n >> 16 & 255;
|
|
177
|
+
out[i + 1] = n >> 8 & 255;
|
|
178
|
+
out[i + 2] = n & 255;
|
|
179
|
+
out[i + 3] = a;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
function editorStickers() {
|
|
185
|
+
const outlines = /* @__PURE__ */ new Map();
|
|
186
|
+
const thumbs = /* @__PURE__ */ new Map();
|
|
187
|
+
const outline = (k) => _nullishCoalesce(outlines.get(k), () => ( (outlines.set(k, stampOutline(k)), outlines.get(k))));
|
|
188
|
+
const summary = (k) => {
|
|
189
|
+
const m = META[k];
|
|
190
|
+
if (!thumbs.has(k)) thumbs.set(k, _chunkW5M3J7PVcjs.pngDataUrl.call(void 0, 48, 48, stampPixels(k, 48, m.colour)));
|
|
191
|
+
return { id: k, name: m.name, category: m.category, tags: m.tags, description: m.description, width: BOX, height: BOX, thumbnail: thumbs.get(k), formats: ["svg", "png"], licence: { ...LICENCE }, tintable: true };
|
|
192
|
+
};
|
|
193
|
+
const kind = (id) => {
|
|
194
|
+
if (!_chunk4JNWA3VTcjs.STAMP_KINDS.includes(id)) throw new (0, _chunkU67EN7GGcjs.StickerError)("unknown_sticker", `The editor has no sticker "${id}"; its stickers are ${_chunk4JNWA3VTcjs.STAMP_KINDS.join(", ")}.`);
|
|
195
|
+
return id;
|
|
196
|
+
};
|
|
197
|
+
return {
|
|
198
|
+
id: _chunk4JNWA3VTcjs.EDITOR_STICKERS_ID,
|
|
199
|
+
name: "Editor stickers",
|
|
200
|
+
version: "1",
|
|
201
|
+
capabilities: { supportsSearch: true, supportsSvg: true, supportsRaster: true, maxSize: 1024 },
|
|
202
|
+
list: (options) => _chunk4JNWA3VTcjs.stickerPage.call(void 0, _chunk4JNWA3VTcjs.STAMP_KINDS.map(summary), options),
|
|
203
|
+
search: (query, options) => _chunk4JNWA3VTcjs.stickerPage.call(void 0, _chunk4JNWA3VTcjs.STAMP_KINDS.map(summary), options, query),
|
|
204
|
+
describe(id) {
|
|
205
|
+
if (!_chunk4JNWA3VTcjs.STAMP_KINDS.includes(id)) return void 0;
|
|
206
|
+
const k = id;
|
|
207
|
+
return { ...summary(k), silhouette: outline(k), colours: [META[k].colour] };
|
|
208
|
+
},
|
|
209
|
+
categories: () => [...new Set(_chunk4JNWA3VTcjs.STAMP_KINDS.map((k) => META[k].category))].map((c) => ({ id: c, name: c[0].toUpperCase() + c.slice(1), count: _chunk4JNWA3VTcjs.STAMP_KINDS.filter((k) => META[k].category === c).length })),
|
|
210
|
+
load(id, options = {}) {
|
|
211
|
+
const k = kind(id);
|
|
212
|
+
const colour = _nullishCoalesce(options.colour, () => ( META[k].colour));
|
|
213
|
+
if (!HEX.test(colour)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `colour ${JSON.stringify(colour)} must be #rrggbb.`);
|
|
214
|
+
if (options.format === "png") {
|
|
215
|
+
const size = _nullishCoalesce(options.size, () => ( 256));
|
|
216
|
+
if (!(Number.isInteger(size) && size >= 8 && size <= 1024)) throw new (0, _chunkU67EN7GGcjs.StickerError)("invalid_argument", `size must be a whole number of px from 8 to 1024, got ${size}.`);
|
|
217
|
+
return { kind: "image", url: _chunkW5M3J7PVcjs.pngDataUrl.call(void 0, size, size, stampPixels(k, size, colour.toLowerCase())), width: size, height: size };
|
|
218
|
+
}
|
|
219
|
+
if (options.format !== void 0 && options.format !== "svg") throw new (0, _chunkU67EN7GGcjs.StickerError)("unsupported_format", `format must be svg or png, got ${JSON.stringify(options.format)}.`);
|
|
220
|
+
const d = outline(k);
|
|
221
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${BOX} ${BOX}" width="${BOX}" height="${BOX}"><path fill="${colour.toLowerCase()}" fill-rule="evenodd" d="${d}"/></svg>`;
|
|
222
|
+
return { kind: "svg", svg, silhouette: d };
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/stickers/browser.ts
|
|
228
|
+
var StickerBrowser = (_class = class {
|
|
229
|
+
constructor(provider, pageSize = 24) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
230
|
+
this.provider = provider;
|
|
231
|
+
this.pageSize = pageSize;
|
|
232
|
+
this.s = { query: "", category: "", items: [], total: 0, hasMore: false, loading: false, error: null, categories: [], provider: provider().name };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
__init() {this.run = 0}
|
|
239
|
+
__init2() {this.listeners = /* @__PURE__ */ new Set()}
|
|
240
|
+
get state() {
|
|
241
|
+
return this.s;
|
|
242
|
+
}
|
|
243
|
+
subscribe(listener) {
|
|
244
|
+
this.listeners.add(listener);
|
|
245
|
+
return () => this.listeners.delete(listener);
|
|
246
|
+
}
|
|
247
|
+
set(patch) {
|
|
248
|
+
this.s = { ...this.s, ...patch };
|
|
249
|
+
for (const l of [...this.listeners]) l();
|
|
250
|
+
}
|
|
251
|
+
/** Loads the first page (and the categories) again, for the current provider. */
|
|
252
|
+
async refresh() {
|
|
253
|
+
const run = ++this.run;
|
|
254
|
+
const p = this.provider();
|
|
255
|
+
this.next = void 0;
|
|
256
|
+
this.set({ loading: true, error: null, items: [], total: 0, hasMore: false, provider: p.name });
|
|
257
|
+
try {
|
|
258
|
+
const categories = await _asyncNullishCoalesce(await _optionalChain([p, 'access', _2 => _2.categories, 'optionalCall', _3 => _3()]), async () => ( []));
|
|
259
|
+
if (run !== this.run) return;
|
|
260
|
+
this.set({ categories });
|
|
261
|
+
await this.page(run, p, true);
|
|
262
|
+
} catch (e) {
|
|
263
|
+
if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/** Searches for `query` (words; `''` lists everything) from the first page. */
|
|
267
|
+
setQuery(query) {
|
|
268
|
+
this.s = { ...this.s, query };
|
|
269
|
+
return this.refresh();
|
|
270
|
+
}
|
|
271
|
+
/** Shows one category (`''` for all) from the first page. */
|
|
272
|
+
setCategory(category) {
|
|
273
|
+
this.s = { ...this.s, category };
|
|
274
|
+
return this.refresh();
|
|
275
|
+
}
|
|
276
|
+
/** Loads the next page onto the list. */
|
|
277
|
+
async more() {
|
|
278
|
+
if (!this.next || this.s.loading) return;
|
|
279
|
+
const run = this.run;
|
|
280
|
+
this.set({ loading: true });
|
|
281
|
+
try {
|
|
282
|
+
await this.page(run, this.provider(), false);
|
|
283
|
+
} catch (e) {
|
|
284
|
+
if (run === this.run) this.set({ loading: false, error: e instanceof Error ? e.message : String(e) });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async page(run, p, first) {
|
|
288
|
+
const options = { limit: this.pageSize, ...this.s.category ? { category: this.s.category } : {}, ...!first && this.next ? { after: this.next } : {} };
|
|
289
|
+
const q = this.s.query.trim();
|
|
290
|
+
const res = q && p.capabilities.supportsSearch ? await p.search(q, options) : await p.list(options);
|
|
291
|
+
if (run !== this.run) return;
|
|
292
|
+
this.next = res.next;
|
|
293
|
+
const items = res.items.map((s) => ({ ...s, ref: _chunk4JNWA3VTcjs.stickerRefOf.call(void 0, p, s.id) }));
|
|
294
|
+
this.set({ items: first ? items : [...this.s.items, ...items], total: res.total, hasMore: Boolean(res.next), loading: false });
|
|
295
|
+
}
|
|
296
|
+
}, _class);
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
exports.stampOutline = stampOutline; exports.stampPixels = stampPixels; exports.editorStickers = editorStickers; exports.StickerBrowser = StickerBrowser;
|
|
@@ -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,
|