@codingfactory/mediables-vue 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiFrameExporter-dBsAo3iz.cjs → PixiFrameExporter-BKFYai9I.cjs} +2 -2
- package/dist/{PixiFrameExporter-dBsAo3iz.cjs.map → PixiFrameExporter-BKFYai9I.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-Cz7dg92v.js → PixiFrameExporter-w_UZwFZG.js} +2 -2
- package/dist/{PixiFrameExporter-Cz7dg92v.js.map → PixiFrameExporter-w_UZwFZG.js.map} +1 -1
- package/dist/components/video/VideoEditorDialog.vue.d.ts +2 -2
- package/dist/editor-DAx1zj7y.cjs +42 -0
- package/dist/editor-DAx1zj7y.cjs.map +1 -0
- package/dist/{editor-CfH1RN8F.js → editor-DJXRx8vN.js} +1219 -913
- package/dist/editor-DJXRx8vN.js.map +1 -0
- package/dist/index-BSiVRjOF.cjs +342 -0
- package/dist/index-BSiVRjOF.cjs.map +1 -0
- package/dist/{index-DDmYo-6o.js → index-j6fnH8-G.js} +7277 -6673
- package/dist/index-j6fnH8-G.js.map +1 -0
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/editor-BPW3mi6G.cjs +0 -42
- package/dist/editor-BPW3mi6G.cjs.map +0 -1
- package/dist/editor-CfH1RN8F.js.map +0 -1
- package/dist/index-DDmYo-6o.js.map +0 -1
- package/dist/index-Du0vZ5BO.cjs +0 -39
- package/dist/index-Du0vZ5BO.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var ge = (s, e, t) => e in s ? me(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var U = (s, e, t) => ge(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import * as g from "pixi-filters";
|
|
5
|
-
import * as
|
|
6
|
-
import { GlProgram as
|
|
5
|
+
import * as w from "pixi.js";
|
|
6
|
+
import { GlProgram as be } from "pixi.js";
|
|
7
7
|
class B {
|
|
8
8
|
constructor() {
|
|
9
9
|
this._events = /* @__PURE__ */ new Map();
|
|
@@ -17,16 +17,16 @@ class B {
|
|
|
17
17
|
}
|
|
18
18
|
emit(e, ...t) {
|
|
19
19
|
const i = this._events.get(e);
|
|
20
|
-
i && i.forEach((
|
|
20
|
+
i && i.forEach((r) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
r(...t);
|
|
23
23
|
} catch {
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
once(e, t) {
|
|
28
|
-
const i = (...
|
|
29
|
-
this.off(e, i), t(...
|
|
28
|
+
const i = (...r) => {
|
|
29
|
+
this.off(e, i), t(...r);
|
|
30
30
|
};
|
|
31
31
|
return this.on(e, i);
|
|
32
32
|
}
|
|
@@ -34,7 +34,7 @@ class B {
|
|
|
34
34
|
e ? this._events.delete(e) : this._events.clear();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
class
|
|
37
|
+
class ye extends B {
|
|
38
38
|
constructor() {
|
|
39
39
|
super(), this._state = {
|
|
40
40
|
// Image state
|
|
@@ -76,9 +76,9 @@ class pe extends B {
|
|
|
76
76
|
if (e.includes(".")) {
|
|
77
77
|
const t = e.split(".");
|
|
78
78
|
let i = this._state;
|
|
79
|
-
for (const
|
|
79
|
+
for (const r of t) {
|
|
80
80
|
if (i == null) return;
|
|
81
|
-
i = i[
|
|
81
|
+
i = i[r];
|
|
82
82
|
}
|
|
83
83
|
return i;
|
|
84
84
|
}
|
|
@@ -92,9 +92,9 @@ class pe extends B {
|
|
|
92
92
|
set(e, t) {
|
|
93
93
|
const i = this.get(e);
|
|
94
94
|
if (e.includes(".")) {
|
|
95
|
-
const
|
|
95
|
+
const r = e.split("."), a = r.pop();
|
|
96
96
|
let o = this._state;
|
|
97
|
-
for (const n of
|
|
97
|
+
for (const n of r)
|
|
98
98
|
o[n] === void 0 && (o[n] = {}), o = o[n];
|
|
99
99
|
o[a] = t;
|
|
100
100
|
} else
|
|
@@ -160,10 +160,10 @@ class pe extends B {
|
|
|
160
160
|
this.set("isDarkMode", this._state.theme === "dark");
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
return new
|
|
163
|
+
function _e() {
|
|
164
|
+
return new ye();
|
|
165
165
|
}
|
|
166
|
-
class
|
|
166
|
+
class xe extends B {
|
|
167
167
|
constructor() {
|
|
168
168
|
super(), this.app = null, this.sprite = null, this.originalTexture = null, this.baseTexture = null, this.fitScale = 1, this.zoom = 1, this._container = null, this._mountPromise = null;
|
|
169
169
|
}
|
|
@@ -181,8 +181,8 @@ class me extends B {
|
|
|
181
181
|
* canvas getter which throws when renderer is undefined.
|
|
182
182
|
*/
|
|
183
183
|
_getCssSize() {
|
|
184
|
-
var
|
|
185
|
-
const e = (a = (
|
|
184
|
+
var r, a, o, n, l, c;
|
|
185
|
+
const e = (a = (r = this.app) == null ? void 0 : r.renderer) == null ? void 0 : a.canvas, t = (e == null ? void 0 : e.clientWidth) ?? ((n = (o = this.app) == null ? void 0 : o.screen) == null ? void 0 : n.width) ?? 0, i = (e == null ? void 0 : e.clientHeight) ?? ((c = (l = this.app) == null ? void 0 : l.screen) == null ? void 0 : c.height) ?? 0;
|
|
186
186
|
return { w: t, h: i };
|
|
187
187
|
}
|
|
188
188
|
/**
|
|
@@ -204,15 +204,15 @@ class me extends B {
|
|
|
204
204
|
if (!this.app || !e) return 1;
|
|
205
205
|
const { w: t, h: i } = this._getCssSize();
|
|
206
206
|
if (t <= 1 || i <= 1) return 1;
|
|
207
|
-
let
|
|
208
|
-
return (!Number.isFinite(
|
|
207
|
+
let r = Math.min(t / e.width, i / e.height) * 0.9;
|
|
208
|
+
return (!Number.isFinite(r) || r <= 0) && (r = 1), r;
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
211
211
|
* Apply view transform (position and scale) to sprite
|
|
212
212
|
*/
|
|
213
213
|
applyViewTransform(e = {}) {
|
|
214
214
|
if (!this.app || !this.sprite || !this.originalTexture) return;
|
|
215
|
-
const t = this.fitScale * this.zoom, { w: i, h:
|
|
215
|
+
const t = this.fitScale * this.zoom, { w: i, h: r } = this._getCssSize(), a = e.keepCenter ? { x: this.sprite.x + this.sprite.width / 2, y: this.sprite.y + this.sprite.height / 2 } : e.center ?? { x: i / 2, y: r / 2 };
|
|
216
216
|
this.sprite.width = this.originalTexture.width * t, this.sprite.height = this.originalTexture.height * t, this.sprite.x = a.x - this.sprite.width / 2, this.sprite.y = a.y - this.sprite.height / 2, this.render();
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
@@ -239,12 +239,12 @@ class me extends B {
|
|
|
239
239
|
this._container = e;
|
|
240
240
|
const i = async () => {
|
|
241
241
|
var l;
|
|
242
|
-
const
|
|
243
|
-
if (!
|
|
242
|
+
const r = window.PIXI;
|
|
243
|
+
if (!r)
|
|
244
244
|
throw new Error("PIXI.js not found. Please ensure PIXI is loaded globally.");
|
|
245
|
-
(l =
|
|
245
|
+
(l = r.Assets) != null && l.setPreferences && r.Assets.setPreferences({ crossOrigin: "anonymous" });
|
|
246
246
|
const a = e.clientWidth || 600, o = e.clientHeight || 400;
|
|
247
|
-
this.app = new
|
|
247
|
+
this.app = new r.Application(), await this.app.init({
|
|
248
248
|
width: a,
|
|
249
249
|
height: o,
|
|
250
250
|
backgroundColor: t,
|
|
@@ -266,14 +266,14 @@ class me extends B {
|
|
|
266
266
|
if (this._mountPromise && await this._mountPromise, !((l = this.app) != null && l.renderer)) return;
|
|
267
267
|
const t = window.PIXI, i = await this._loadImageElement(e);
|
|
268
268
|
if (!i || !((c = this.app) != null && c.renderer)) return;
|
|
269
|
-
const
|
|
270
|
-
if (!
|
|
269
|
+
const r = t.Texture.from(i);
|
|
270
|
+
if (!r)
|
|
271
271
|
return;
|
|
272
|
-
this.originalTexture =
|
|
272
|
+
this.originalTexture = r, this.baseTexture = r, this.sprite && (this.app.stage.removeChild(this.sprite), this.sprite.destroy()), this.sprite = new t.Sprite(r), this.app.stage.addChild(this.sprite), this.fitScale = this.getFitScaleFor(r), this.zoom = 1;
|
|
273
273
|
const { w: a, h: o } = this._getCssSize();
|
|
274
274
|
if (this.applyViewTransform({ center: { x: a / 2, y: o / 2 } }), await new Promise(requestAnimationFrame), !((d = this.app) != null && d.renderer)) return;
|
|
275
|
-
const n = this.getFitScaleFor(
|
|
276
|
-
Math.abs(n - this.fitScale) / Math.max(1e-6, n) > 0.02 && (this.fitScale = n, this.applyViewTransform({ center: { x: a / 2, y: o / 2 } })), this.render(), this.emit("textureLoaded", { width:
|
|
275
|
+
const n = this.getFitScaleFor(r);
|
|
276
|
+
Math.abs(n - this.fitScale) / Math.max(1e-6, n) > 0.02 && (this.fitScale = n, this.applyViewTransform({ center: { x: a / 2, y: o / 2 } })), this.render(), this.emit("textureLoaded", { width: r.width, height: r.height });
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
279
|
* Export the current image with filters applied
|
|
@@ -283,7 +283,7 @@ class me extends B {
|
|
|
283
283
|
* @param {boolean} dontUpscale - Don't upscale smaller images
|
|
284
284
|
* @returns {string|null} Data URL
|
|
285
285
|
*/
|
|
286
|
-
exportImage(e = "png", t = 0.92, i = 0,
|
|
286
|
+
exportImage(e = "png", t = 0.92, i = 0, r = !0) {
|
|
287
287
|
var m, b, _;
|
|
288
288
|
if (!((m = this.app) != null && m.renderer) || !this.originalTexture)
|
|
289
289
|
return null;
|
|
@@ -294,7 +294,7 @@ class me extends B {
|
|
|
294
294
|
if (i > 0) {
|
|
295
295
|
const x = Math.max(o, n);
|
|
296
296
|
let y = i / x;
|
|
297
|
-
|
|
297
|
+
r && (y = Math.min(1, y)), l = Math.round(o * y), c = Math.round(n * y);
|
|
298
298
|
}
|
|
299
299
|
const d = new a.Container(), h = new a.Sprite(this.originalTexture);
|
|
300
300
|
if (h.scale.set(l / o, c / n), (_ = (b = this.sprite) == null ? void 0 : b.filters) != null && _.length) {
|
|
@@ -315,10 +315,10 @@ class me extends B {
|
|
|
315
315
|
if (typeof x.toDataURL == "function")
|
|
316
316
|
y = x.toDataURL(`image/${e}`, t);
|
|
317
317
|
else if (typeof x.getContext == "function") {
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
318
|
+
const A = document.createElement("canvas");
|
|
319
|
+
A.width = x.width, A.height = x.height;
|
|
320
|
+
const I = A.getContext("2d");
|
|
321
|
+
I && (I.drawImage(x, 0, 0), y = A.toDataURL(`image/${e}`, t));
|
|
322
322
|
}
|
|
323
323
|
return y || null;
|
|
324
324
|
} catch {
|
|
@@ -332,8 +332,8 @@ class me extends B {
|
|
|
332
332
|
* @param {HTMLElement} container
|
|
333
333
|
*/
|
|
334
334
|
resizeTo(e) {
|
|
335
|
-
var
|
|
336
|
-
if (!((
|
|
335
|
+
var r;
|
|
336
|
+
if (!((r = this.app) != null && r.renderer) || !e) return;
|
|
337
337
|
const t = e.clientWidth, i = e.clientHeight;
|
|
338
338
|
if (!(t === Math.round(this.app.screen.width) && i === Math.round(this.app.screen.height)) && !(t <= 0 || i <= 0) && (this.app.renderer.resize(t, i), this.originalTexture && this.sprite)) {
|
|
339
339
|
const a = {
|
|
@@ -379,7 +379,7 @@ class me extends B {
|
|
|
379
379
|
this.sprite = null, this.originalTexture = null, this.baseTexture = null, this._container = null, this.removeAllListeners();
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
const
|
|
382
|
+
const Ce = {
|
|
383
383
|
adjust: ["adjust", "advanced"],
|
|
384
384
|
// adjustment, adjustmentAdvanced, alpha, colorMatrix
|
|
385
385
|
blur: ["blur"],
|
|
@@ -395,7 +395,7 @@ const ge = {
|
|
|
395
395
|
stylize: ["stylize"]
|
|
396
396
|
// ascii, crt, crossHatch, dot, emboss
|
|
397
397
|
};
|
|
398
|
-
class
|
|
398
|
+
class we extends B {
|
|
399
399
|
constructor(e, t) {
|
|
400
400
|
super(), this.state = e, this.renderer = t, this.instances = {}, this._filterRegistry = null;
|
|
401
401
|
}
|
|
@@ -430,11 +430,11 @@ class be extends B {
|
|
|
430
430
|
*/
|
|
431
431
|
getFiltersByCategory(e) {
|
|
432
432
|
if (!this._filterRegistry) return [];
|
|
433
|
-
const t =
|
|
433
|
+
const t = Ce[e] || [e], i = [], r = /* @__PURE__ */ new Set();
|
|
434
434
|
for (const a of t) {
|
|
435
435
|
const o = this._filterRegistry.getFiltersByCategory(a) || [];
|
|
436
436
|
for (const n of o)
|
|
437
|
-
|
|
437
|
+
r.has(n.id) || (r.add(n.id), i.push(n));
|
|
438
438
|
}
|
|
439
439
|
return i;
|
|
440
440
|
}
|
|
@@ -458,13 +458,13 @@ class be extends B {
|
|
|
458
458
|
e[t] = i;
|
|
459
459
|
return;
|
|
460
460
|
}
|
|
461
|
-
const
|
|
461
|
+
const r = t.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
462
462
|
let a = e;
|
|
463
|
-
for (let n = 0; n <
|
|
464
|
-
const l =
|
|
463
|
+
for (let n = 0; n < r.length - 1; n++) {
|
|
464
|
+
const l = r[n];
|
|
465
465
|
if (!(l in a) || (a = a[l], a == null)) return;
|
|
466
466
|
}
|
|
467
|
-
const o =
|
|
467
|
+
const o = r[r.length - 1];
|
|
468
468
|
a[o] = i;
|
|
469
469
|
}
|
|
470
470
|
/**
|
|
@@ -474,8 +474,8 @@ class be extends B {
|
|
|
474
474
|
initializeValues(e) {
|
|
475
475
|
const t = this.getFilterDef(e);
|
|
476
476
|
t && t.controls.forEach((i) => {
|
|
477
|
-
const
|
|
478
|
-
i.id in
|
|
477
|
+
const r = this.state.getFilterValues(e);
|
|
478
|
+
i.id in r || this.state.setFilterValue(e, i.id, i.default);
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
481
|
/**
|
|
@@ -504,12 +504,12 @@ class be extends B {
|
|
|
504
504
|
* @returns {boolean} True if updated in-place
|
|
505
505
|
*/
|
|
506
506
|
updateValue(e, t, i) {
|
|
507
|
-
const
|
|
508
|
-
this.state.setFilterValue(e, t,
|
|
507
|
+
const r = this._normalizeValue(i);
|
|
508
|
+
this.state.setFilterValue(e, t, r);
|
|
509
509
|
const a = this.instances[e];
|
|
510
510
|
if (a) {
|
|
511
511
|
const o = this.getFilterDef(e), n = o == null ? void 0 : o.controls.find((c) => c.id === t), l = (n == null ? void 0 : n.property) || t;
|
|
512
|
-
return typeof a.updateUIParam == "function" ? (a.updateUIParam(l,
|
|
512
|
+
return typeof a.updateUIParam == "function" ? (a.updateUIParam(l, r), !0) : (this._setDeepProp(a, l, r), a.uniforms && l in a.uniforms && (a.uniforms[l] = r), !0);
|
|
513
513
|
}
|
|
514
514
|
return !1;
|
|
515
515
|
}
|
|
@@ -575,7 +575,7 @@ class be extends B {
|
|
|
575
575
|
return this.instances[e] || null;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
const
|
|
578
|
+
const R = class R extends B {
|
|
579
579
|
constructor(e, t) {
|
|
580
580
|
super(), this.state = e, this.renderer = t, this._overlayCanvas = null, this._isDragging = !1, this._dragStart = null, this._dragMode = null, this._startRect = null, this._hoverMode = null, this._lastAutoZoomCheck = 0, this.HANDLE_SIZE = 14, this.EDGE_HIT_PAD = 10, this._onPointerDown = this._handlePointerDown.bind(this), this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerUp = this._handlePointerUp.bind(this);
|
|
581
581
|
}
|
|
@@ -603,9 +603,9 @@ const N = class N extends B {
|
|
|
603
603
|
if (t[e] !== void 0) return t[e];
|
|
604
604
|
const i = e.split(":");
|
|
605
605
|
if (i.length === 2) {
|
|
606
|
-
const
|
|
607
|
-
if (Number.isFinite(
|
|
608
|
-
return
|
|
606
|
+
const r = parseFloat(i[0]), a = parseFloat(i[1]);
|
|
607
|
+
if (Number.isFinite(r) && Number.isFinite(a) && a > 0)
|
|
608
|
+
return r / a;
|
|
609
609
|
}
|
|
610
610
|
return null;
|
|
611
611
|
}
|
|
@@ -617,8 +617,8 @@ const N = class N extends B {
|
|
|
617
617
|
if (!e || t === "free") return;
|
|
618
618
|
const i = this._getAspectRatio(t);
|
|
619
619
|
if (!i) return;
|
|
620
|
-
const
|
|
621
|
-
Math.abs(
|
|
620
|
+
const r = e.width / e.height;
|
|
621
|
+
Math.abs(r - i) < 0.01 || (r > i ? e.width = e.height * i : e.height = e.width / i, this.state.set("crop.rect", e));
|
|
622
622
|
}
|
|
623
623
|
/**
|
|
624
624
|
* Constrain crop rect to bounds
|
|
@@ -628,8 +628,8 @@ const N = class N extends B {
|
|
|
628
628
|
if (!e) return;
|
|
629
629
|
const t = this.renderer.sprite, i = this.renderer.app;
|
|
630
630
|
if (!t || !i) return;
|
|
631
|
-
const
|
|
632
|
-
if (e.x = Math.max(o.x, Math.min(e.x, o.x + o.w - e.width)), e.y = Math.max(o.y, Math.min(e.y, o.y + o.h - e.height)), e.width = Math.min(e.width, o.w), e.height = Math.min(e.height, o.h),
|
|
631
|
+
const r = this.state.get("crop.shape"), o = r === "circle" || !!this.state.get("autoZoomOnCropOverflow") ? { x: 0, y: 0, w: i.screen.width, h: i.screen.height } : { x: t.x, y: t.y, w: t.width, h: t.height };
|
|
632
|
+
if (e.x = Math.max(o.x, Math.min(e.x, o.x + o.w - e.width)), e.y = Math.max(o.y, Math.min(e.y, o.y + o.h - e.height)), e.width = Math.min(e.width, o.w), e.height = Math.min(e.height, o.h), r !== "free" || this.state.get("crop.aspect") === "1:1") {
|
|
633
633
|
const n = Math.min(e.width, e.height);
|
|
634
634
|
e.width = n, e.height = n;
|
|
635
635
|
}
|
|
@@ -648,14 +648,14 @@ const N = class N extends B {
|
|
|
648
648
|
* @param {number} currentZoom - Current zoom level
|
|
649
649
|
* @returns {number|null} Target zoom level, or null if no zoom needed
|
|
650
650
|
*/
|
|
651
|
-
static calcAutoZoom(e, t, i,
|
|
652
|
-
if (!e || !
|
|
651
|
+
static calcAutoZoom(e, t, i, r, a, o, n) {
|
|
652
|
+
if (!e || !r || !a || !o) return null;
|
|
653
653
|
const l = e.width > t, c = e.height > i;
|
|
654
654
|
if (!l && !c) return null;
|
|
655
|
-
const d =
|
|
655
|
+
const d = R.AUTO_ZOOM_PADDING;
|
|
656
656
|
let h = n;
|
|
657
657
|
if (l) {
|
|
658
|
-
const p = e.width / (d *
|
|
658
|
+
const p = e.width / (d * r * o);
|
|
659
659
|
h = Math.min(h, p);
|
|
660
660
|
}
|
|
661
661
|
if (c) {
|
|
@@ -671,16 +671,16 @@ const N = class N extends B {
|
|
|
671
671
|
_checkAutoZoom() {
|
|
672
672
|
if (!this.state.get("autoZoomOnCropOverflow")) return;
|
|
673
673
|
const e = Date.now();
|
|
674
|
-
if (e - this._lastAutoZoomCheck <
|
|
674
|
+
if (e - this._lastAutoZoomCheck < R.AUTO_ZOOM_THROTTLE_MS) return;
|
|
675
675
|
this._lastAutoZoomCheck = e;
|
|
676
|
-
const t = this.state.get("crop.rect"), i = this.renderer.sprite,
|
|
677
|
-
if (!t || !i || !
|
|
678
|
-
const a =
|
|
676
|
+
const t = this.state.get("crop.rect"), i = this.renderer.sprite, r = this.renderer.originalTexture;
|
|
677
|
+
if (!t || !i || !r) return;
|
|
678
|
+
const a = R.calcAutoZoom(
|
|
679
679
|
t,
|
|
680
680
|
i.width,
|
|
681
681
|
i.height,
|
|
682
|
-
|
|
683
|
-
|
|
682
|
+
r.width,
|
|
683
|
+
r.height,
|
|
684
684
|
this.renderer.fitScale,
|
|
685
685
|
this.renderer.zoom
|
|
686
686
|
);
|
|
@@ -694,11 +694,11 @@ const N = class N extends B {
|
|
|
694
694
|
if (!e) return;
|
|
695
695
|
const t = this.renderer.app;
|
|
696
696
|
if (!t) return;
|
|
697
|
-
const i = t.canvas,
|
|
698
|
-
(e.width !== Math.max(1, Math.floor(
|
|
697
|
+
const i = t.canvas, r = i.clientWidth, a = i.clientHeight, o = window.devicePixelRatio || 1;
|
|
698
|
+
(e.width !== Math.max(1, Math.floor(r * o)) || e.height !== Math.max(1, Math.floor(a * o))) && (e.width = Math.max(1, Math.floor(r * o)), e.height = Math.max(1, Math.floor(a * o)), e.style.width = r + "px", e.style.height = a + "px");
|
|
699
699
|
const n = e.getContext("2d");
|
|
700
700
|
if (!n) return;
|
|
701
|
-
n.setTransform(o, 0, 0, o, 0, 0), n.clearRect(0, 0,
|
|
701
|
+
n.setTransform(o, 0, 0, o, 0, 0), n.clearRect(0, 0, r, a), n.fillStyle = "rgba(0, 0, 0, 0.5)", n.fillRect(0, 0, r, a);
|
|
702
702
|
const l = this.state.get("crop.rect");
|
|
703
703
|
if (!l) return;
|
|
704
704
|
const c = this.state.get("crop.shape");
|
|
@@ -742,8 +742,8 @@ const N = class N extends B {
|
|
|
742
742
|
_hitHandle(e, t) {
|
|
743
743
|
const i = this.state.get("crop.rect");
|
|
744
744
|
if (!i) return null;
|
|
745
|
-
const
|
|
746
|
-
return
|
|
745
|
+
const r = (a, o, n, l, c) => Math.abs(a - n) <= c && Math.abs(o - l) <= c;
|
|
746
|
+
return r(e, t, i.x, i.y, this.HANDLE_SIZE) ? "resize-nw" : r(e, t, i.x + i.width, i.y, this.HANDLE_SIZE) ? "resize-ne" : r(e, t, i.x, i.y + i.height, this.HANDLE_SIZE) ? "resize-sw" : r(e, t, i.x + i.width, i.y + i.height, this.HANDLE_SIZE) ? "resize-se" : Math.abs(t - i.y) <= this.EDGE_HIT_PAD && e >= i.x && e <= i.x + i.width ? "n" : Math.abs(t - (i.y + i.height)) <= this.EDGE_HIT_PAD && e >= i.x && e <= i.x + i.width ? "s" : Math.abs(e - i.x) <= this.EDGE_HIT_PAD && t >= i.y && t <= i.y + i.height ? "w" : Math.abs(e - (i.x + i.width)) <= this.EDGE_HIT_PAD && t >= i.y && t <= i.y + i.height ? "e" : e >= i.x && e <= i.x + i.width && t >= i.y && t <= i.y + i.height ? "move" : null;
|
|
747
747
|
}
|
|
748
748
|
/**
|
|
749
749
|
* Handle pointer down event
|
|
@@ -766,39 +766,39 @@ const N = class N extends B {
|
|
|
766
766
|
this._hoverMode = this._hitHandle(i.x, i.y), t.stage.cursor = this._hoverMode === "move" ? "move" : this._hoverMode === "n" || this._hoverMode === "s" ? "ns-resize" : this._hoverMode === "e" || this._hoverMode === "w" ? "ew-resize" : (l = this._hoverMode) != null && l.endsWith("nw") || (c = this._hoverMode) != null && c.endsWith("se") ? "nwse-resize" : (d = this._hoverMode) != null && d.endsWith("ne") || (h = this._hoverMode) != null && h.endsWith("sw") ? "nesw-resize" : "crosshair", this.drawOverlay();
|
|
767
767
|
return;
|
|
768
768
|
}
|
|
769
|
-
const
|
|
770
|
-
if (!
|
|
769
|
+
const r = this.state.get("crop.rect");
|
|
770
|
+
if (!r) return;
|
|
771
771
|
const a = i.x - this._dragStart.x, o = i.y - this._dragStart.y;
|
|
772
772
|
switch (this._dragMode) {
|
|
773
773
|
case "move":
|
|
774
|
-
|
|
774
|
+
r.x = this._startRect.x + a, r.y = this._startRect.y + o;
|
|
775
775
|
break;
|
|
776
776
|
case "n":
|
|
777
|
-
|
|
777
|
+
r.y = this._startRect.y + o, r.height = this._startRect.height - o;
|
|
778
778
|
break;
|
|
779
779
|
case "s":
|
|
780
|
-
|
|
780
|
+
r.height = this._startRect.height + o;
|
|
781
781
|
break;
|
|
782
782
|
case "w":
|
|
783
|
-
|
|
783
|
+
r.x = this._startRect.x + a, r.width = this._startRect.width - a;
|
|
784
784
|
break;
|
|
785
785
|
case "e":
|
|
786
|
-
|
|
786
|
+
r.width = this._startRect.width + a;
|
|
787
787
|
break;
|
|
788
788
|
case "resize-nw":
|
|
789
|
-
|
|
789
|
+
r.x = this._startRect.x + a, r.y = this._startRect.y + o, r.width = this._startRect.width - a, r.height = this._startRect.height - o;
|
|
790
790
|
break;
|
|
791
791
|
case "resize-ne":
|
|
792
|
-
|
|
792
|
+
r.y = this._startRect.y + o, r.width = this._startRect.width + a, r.height = this._startRect.height - o;
|
|
793
793
|
break;
|
|
794
794
|
case "resize-sw":
|
|
795
|
-
|
|
795
|
+
r.x = this._startRect.x + a, r.width = this._startRect.width - a, r.height = this._startRect.height + o;
|
|
796
796
|
break;
|
|
797
797
|
case "resize-se":
|
|
798
|
-
|
|
798
|
+
r.width = this._startRect.width + a, r.height = this._startRect.height + o;
|
|
799
799
|
break;
|
|
800
800
|
}
|
|
801
|
-
|
|
801
|
+
r.width = Math.max(50, r.width), r.height = Math.max(50, r.height), this.state.set("crop.rect", r), this.state.get("crop.shape") === "circle" && this.state.get("crop.aspect") !== "1:1" && this.state.set("crop.aspect", "1:1"), this.applyAspectRatio(), this._dragMode !== "move" && this._checkAutoZoom(), this.constrainCropRect(), this.drawOverlay();
|
|
802
802
|
}
|
|
803
803
|
/**
|
|
804
804
|
* Handle pointer up event
|
|
@@ -817,8 +817,8 @@ const N = class N extends B {
|
|
|
817
817
|
const a = Math.min(e.screen.width, e.screen.height) * 0.7, o = t.x + (t.width - a) / 2, n = t.y + (t.height - a) / 2;
|
|
818
818
|
i = { x: o, y: n, width: a, height: a }, this.state.set("crop.rect", i), this.state.get("crop.shape") === "circle" && this.state.set("crop.aspect", "1:1"), this.state.get("crop.aspect") !== "free" && (this.applyAspectRatio(), this.constrainCropRect());
|
|
819
819
|
}
|
|
820
|
-
const
|
|
821
|
-
|
|
820
|
+
const r = e.stage;
|
|
821
|
+
r.eventMode = "static", r.hitArea = e.screen, r.cursor = "crosshair", r.on("pointerdown", this._onPointerDown), r.on("pointermove", this._onPointerMove), r.on("pointerup", this._onPointerUp), r.on("pointerupoutside", this._onPointerUp), this.state.set("mode", "crop"), this.drawOverlay(), this.emit("enabled");
|
|
822
822
|
}
|
|
823
823
|
/**
|
|
824
824
|
* Disable crop mode
|
|
@@ -838,15 +838,15 @@ const N = class N extends B {
|
|
|
838
838
|
* @returns {{ texture: PIXI.Texture, preservedZoom: number }|null}
|
|
839
839
|
*/
|
|
840
840
|
apply() {
|
|
841
|
-
const e = this.renderer.app, t = this.renderer.sprite, i = this.renderer.originalTexture,
|
|
842
|
-
if (!
|
|
843
|
-
const a = window.PIXI, o = this.renderer.zoom, n = i.width / t.width, l = i.height / t.height, c = (
|
|
844
|
-
let h = Math.round(Math.max(1,
|
|
841
|
+
const e = this.renderer.app, t = this.renderer.sprite, i = this.renderer.originalTexture, r = this.state.get("crop.rect");
|
|
842
|
+
if (!r || !t || !e || !i) return null;
|
|
843
|
+
const a = window.PIXI, o = this.renderer.zoom, n = i.width / t.width, l = i.height / t.height, c = (r.x - t.x) * n, d = (r.y - t.y) * l;
|
|
844
|
+
let h = Math.round(Math.max(1, r.width * n)), p = Math.round(Math.max(1, r.height * l)), m = Math.round(c), S = Math.round(d);
|
|
845
845
|
if (h <= 0 || p <= 0) return null;
|
|
846
846
|
const b = new a.Container(), _ = new a.Sprite(i);
|
|
847
847
|
if (this.state.get("crop.shape") === "circle") {
|
|
848
|
-
const
|
|
849
|
-
m = Math.round(
|
|
848
|
+
const I = Math.round(Math.max(h, p)), pe = m + h / 2, fe = S + p / 2;
|
|
849
|
+
m = Math.round(pe - I / 2), S = Math.round(fe - I / 2), h = p = I;
|
|
850
850
|
const M = new a.Graphics();
|
|
851
851
|
typeof M.circle == "function" && typeof M.fill == "function" ? M.circle(h / 2, p / 2, h / 2).fill(16777215) : (M.beginFill(16777215, 1), M.drawCircle(h / 2, p / 2, h / 2), M.endFill()), _.mask = M, b.addChild(M);
|
|
852
852
|
}
|
|
@@ -857,8 +857,8 @@ const N = class N extends B {
|
|
|
857
857
|
target: y,
|
|
858
858
|
clear: !0
|
|
859
859
|
}), b.destroy({ children: !0 }), this.renderer.originalTexture = y, e.stage.removeChild(t), t.destroy();
|
|
860
|
-
const
|
|
861
|
-
return e.stage.addChild(
|
|
860
|
+
const A = new a.Sprite(y);
|
|
861
|
+
return e.stage.addChild(A), this.renderer.sprite = A, this.renderer.fitScale = this.renderer.getFitScaleFor(y), this.renderer.setZoom(o, { keepCenter: !1 }), this.renderer.applyViewTransform(), this.renderer.render(), this.disable(), this.emit("applied", { width: h, height: p }), { texture: y, preservedZoom: o };
|
|
862
862
|
}
|
|
863
863
|
/**
|
|
864
864
|
* Cancel crop
|
|
@@ -885,12 +885,12 @@ const N = class N extends B {
|
|
|
885
885
|
* Padding factor for auto-zoom: image will be ~91% of crop size (1/1.1).
|
|
886
886
|
* Higher values = more aggressive zoom-out, more padding around image.
|
|
887
887
|
*/
|
|
888
|
-
|
|
888
|
+
U(R, "AUTO_ZOOM_PADDING", 1.1), /**
|
|
889
889
|
* Minimum interval (ms) between auto-zoom adjustments during drag.
|
|
890
890
|
*/
|
|
891
|
-
|
|
892
|
-
let H =
|
|
893
|
-
class
|
|
891
|
+
U(R, "AUTO_ZOOM_THROTTLE_MS", 100);
|
|
892
|
+
let H = R;
|
|
893
|
+
class Se {
|
|
894
894
|
/**
|
|
895
895
|
* Create a new RemoveBgManager
|
|
896
896
|
* @param {Object} options
|
|
@@ -913,13 +913,13 @@ class ye {
|
|
|
913
913
|
* @returns {Promise<{dataUrl: string, model: string, processMs: string}>}
|
|
914
914
|
*/
|
|
915
915
|
async removeBackground(e, t = {}) {
|
|
916
|
-
const i = typeof e == "string" ? await this._dataUrlToBlob(e) : e,
|
|
917
|
-
|
|
916
|
+
const i = typeof e == "string" ? await this._dataUrlToBlob(e) : e, r = new FormData();
|
|
917
|
+
r.append("file", i, "image.png"), r.append("tier", t.tier || "balanced"), t.model && r.append("model", t.model), t.alpha_matting && (r.append("alpha_matting", "true"), r.append("alpha_f", String(t.alpha_f ?? 10)), r.append("alpha_fr", String(t.alpha_fr ?? 15)), r.append("alpha_erode_size", String(t.alpha_erode_size ?? 10)));
|
|
918
918
|
let a, o;
|
|
919
919
|
try {
|
|
920
920
|
a = await fetch(this._endpoint, {
|
|
921
921
|
method: "POST",
|
|
922
|
-
body:
|
|
922
|
+
body: r,
|
|
923
923
|
credentials: "include"
|
|
924
924
|
// For Sanctum auth
|
|
925
925
|
});
|
|
@@ -930,7 +930,7 @@ class ye {
|
|
|
930
930
|
try {
|
|
931
931
|
a = await fetch(this._fallbackEndpoint, {
|
|
932
932
|
method: "POST",
|
|
933
|
-
body:
|
|
933
|
+
body: r
|
|
934
934
|
});
|
|
935
935
|
} catch (c) {
|
|
936
936
|
o || (o = c);
|
|
@@ -960,7 +960,7 @@ class ye {
|
|
|
960
960
|
*/
|
|
961
961
|
async _dataUrlToBlob(e) {
|
|
962
962
|
if (e.startsWith("data:")) {
|
|
963
|
-
const [i,
|
|
963
|
+
const [i, r] = e.split(","), a = i.match(/:(.*?);/), o = a ? a[1] : "image/png", n = atob(r), l = new Uint8Array(n.length);
|
|
964
964
|
for (let c = 0; c < n.length; c++)
|
|
965
965
|
l[c] = n.charCodeAt(c);
|
|
966
966
|
return new Blob([l], { type: o });
|
|
@@ -974,8 +974,8 @@ class ye {
|
|
|
974
974
|
*/
|
|
975
975
|
_blobToDataUrl(e) {
|
|
976
976
|
return new Promise((t, i) => {
|
|
977
|
-
const
|
|
978
|
-
|
|
977
|
+
const r = new FileReader();
|
|
978
|
+
r.onload = () => t(r.result), r.onerror = () => i(new Error("Failed to read blob as data URL")), r.readAsDataURL(e);
|
|
979
979
|
});
|
|
980
980
|
}
|
|
981
981
|
/**
|
|
@@ -1000,39 +1000,39 @@ class ye {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
function u(
|
|
1004
|
-
const i = document.createElement(
|
|
1005
|
-
for (const [
|
|
1003
|
+
function u(s, e = {}, ...t) {
|
|
1004
|
+
const i = document.createElement(s);
|
|
1005
|
+
for (const [r, a] of Object.entries(e))
|
|
1006
1006
|
if (a != null)
|
|
1007
|
-
if (
|
|
1007
|
+
if (r === "className")
|
|
1008
1008
|
i.className = a;
|
|
1009
|
-
else if (
|
|
1009
|
+
else if (r === "style" && typeof a == "object")
|
|
1010
1010
|
Object.assign(i.style, a);
|
|
1011
|
-
else if (
|
|
1012
|
-
const o =
|
|
1011
|
+
else if (r.startsWith("on") && typeof a == "function") {
|
|
1012
|
+
const o = r.slice(2).toLowerCase();
|
|
1013
1013
|
i.addEventListener(o, a);
|
|
1014
|
-
} else
|
|
1015
|
-
for (const
|
|
1016
|
-
typeof
|
|
1014
|
+
} else r === "dataset" && typeof a == "object" ? Object.assign(i.dataset, a) : i.setAttribute(r, a);
|
|
1015
|
+
for (const r of t)
|
|
1016
|
+
typeof r == "string" ? i.appendChild(document.createTextNode(r)) : r instanceof HTMLElement && i.appendChild(r);
|
|
1017
1017
|
return i;
|
|
1018
1018
|
}
|
|
1019
|
-
function
|
|
1020
|
-
const n =
|
|
1019
|
+
function se({ id: s, label: e, min: t = 0, max: i = 1, step: r = 0.01, value: a = 0.5, onChange: o }) {
|
|
1020
|
+
const n = s.includes("-") ? s.split("-").slice(1).join("-") : s, l = u("div", {
|
|
1021
1021
|
className: "slider-control slider-wrapper",
|
|
1022
1022
|
"data-control": n,
|
|
1023
1023
|
"data-testid": `slider-${n}`
|
|
1024
1024
|
}), c = u(
|
|
1025
1025
|
"div",
|
|
1026
1026
|
{ className: "slider-header" },
|
|
1027
|
-
u("label", { for:
|
|
1028
|
-
u("span", { className: "slider-value", id: `${
|
|
1027
|
+
u("label", { for: s, className: "slider-label" }, e),
|
|
1028
|
+
u("span", { className: "slider-value", id: `${s}-value` }, V(a))
|
|
1029
1029
|
), d = u("input", {
|
|
1030
1030
|
type: "range",
|
|
1031
|
-
id:
|
|
1031
|
+
id: s,
|
|
1032
1032
|
className: "slider-input",
|
|
1033
1033
|
min: String(t),
|
|
1034
1034
|
max: String(i),
|
|
1035
|
-
step: String(
|
|
1035
|
+
step: String(r),
|
|
1036
1036
|
value: String(a),
|
|
1037
1037
|
onInput: (h) => {
|
|
1038
1038
|
const p = parseFloat(h.target.value), m = l.querySelector(".slider-value");
|
|
@@ -1045,13 +1045,13 @@ function _e({ id: r, label: e, min: t = 0, max: i = 1, step: s = 0.01, value: a
|
|
|
1045
1045
|
p && (p.textContent = V(h));
|
|
1046
1046
|
}, l;
|
|
1047
1047
|
}
|
|
1048
|
-
function V(
|
|
1049
|
-
return Number.isInteger(
|
|
1048
|
+
function V(s) {
|
|
1049
|
+
return Number.isInteger(s) ? String(s) : s.toFixed(2);
|
|
1050
1050
|
}
|
|
1051
|
-
function
|
|
1052
|
-
const
|
|
1051
|
+
function ae({ id: s, label: e, checked: t = !1, onChange: i }) {
|
|
1052
|
+
const r = u("div", { className: "toggle-control" }), a = u("label", { className: "toggle-label", for: s }, e), o = u("input", {
|
|
1053
1053
|
type: "checkbox",
|
|
1054
|
-
id:
|
|
1054
|
+
id: s,
|
|
1055
1055
|
className: "toggle-input",
|
|
1056
1056
|
checked: t ? "checked" : void 0,
|
|
1057
1057
|
onChange: (c) => i == null ? void 0 : i(c.target.checked)
|
|
@@ -1061,27 +1061,27 @@ function xe({ id: r, label: e, checked: t = !1, onChange: i }) {
|
|
|
1061
1061
|
c.target !== o && (o.checked = !o.checked, i == null || i(o.checked));
|
|
1062
1062
|
}
|
|
1063
1063
|
}), l = u("span", { className: "toggle-slider" });
|
|
1064
|
-
return n.appendChild(o), n.appendChild(l),
|
|
1064
|
+
return n.appendChild(o), n.appendChild(l), r.appendChild(a), r.appendChild(n), r.setChecked = (c) => {
|
|
1065
1065
|
o.checked = c;
|
|
1066
|
-
},
|
|
1066
|
+
}, r;
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1069
|
-
const
|
|
1068
|
+
function oe({ id: s, label: e, value: t = "#000000", onChange: i }) {
|
|
1069
|
+
const r = u("div", { className: "color-control" }), a = u("label", { className: "color-label", for: s }, e), o = u("input", {
|
|
1070
1070
|
type: "color",
|
|
1071
|
-
id:
|
|
1071
|
+
id: s,
|
|
1072
1072
|
className: "color-input",
|
|
1073
1073
|
value: t,
|
|
1074
1074
|
onInput: (n) => i == null ? void 0 : i(n.target.value)
|
|
1075
1075
|
});
|
|
1076
|
-
return
|
|
1076
|
+
return r.appendChild(a), r.appendChild(o), r.setValue = (n) => {
|
|
1077
1077
|
o.value = n;
|
|
1078
|
-
},
|
|
1078
|
+
}, r;
|
|
1079
1079
|
}
|
|
1080
|
-
function
|
|
1081
|
-
const a = u("div", { className: "select-control" }), o = u("label", { className: "select-label", for:
|
|
1082
|
-
id:
|
|
1080
|
+
function ne({ id: s, label: e, options: t = [], value: i, onChange: r }) {
|
|
1081
|
+
const a = u("div", { className: "select-control" }), o = u("label", { className: "select-label", for: s }, e), n = u("select", {
|
|
1082
|
+
id: s,
|
|
1083
1083
|
className: "select-input",
|
|
1084
|
-
onChange: (l) =>
|
|
1084
|
+
onChange: (l) => r == null ? void 0 : r(l.target.value)
|
|
1085
1085
|
});
|
|
1086
1086
|
for (const l of t) {
|
|
1087
1087
|
const c = u("option", { value: l.value }, l.label);
|
|
@@ -1091,12 +1091,12 @@ function we({ id: r, label: e, options: t = [], value: i, onChange: s }) {
|
|
|
1091
1091
|
n.value = l;
|
|
1092
1092
|
}, a;
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1094
|
+
function F({ label: s, className: e = "", onClick: t, icon: i = null, disabled: r = !1 }) {
|
|
1095
1095
|
const a = u("button", {
|
|
1096
1096
|
type: "button",
|
|
1097
1097
|
className: `btn ${e}`.trim(),
|
|
1098
1098
|
onClick: t,
|
|
1099
|
-
disabled:
|
|
1099
|
+
disabled: r ? "disabled" : void 0
|
|
1100
1100
|
});
|
|
1101
1101
|
if (i) {
|
|
1102
1102
|
const o = u("span", { className: "btn-icon" });
|
|
@@ -1104,25 +1104,25 @@ function Y({ label: r, className: e = "", onClick: t, icon: i = null, disabled:
|
|
|
1104
1104
|
const n = o.querySelector("svg");
|
|
1105
1105
|
n && n.setAttribute("aria-hidden", "true"), a.appendChild(o);
|
|
1106
1106
|
}
|
|
1107
|
-
return
|
|
1107
|
+
return s && a.appendChild(document.createTextNode(s)), a;
|
|
1108
1108
|
}
|
|
1109
|
-
function
|
|
1109
|
+
function C({ icon: s, title: e, className: t = "", onClick: i, disabled: r = !1, testId: a = null, ariaLabel: o = null }) {
|
|
1110
1110
|
const n = {
|
|
1111
1111
|
type: "button",
|
|
1112
1112
|
className: `icon-btn ${t}`.trim(),
|
|
1113
1113
|
title: e,
|
|
1114
1114
|
"aria-label": o || e,
|
|
1115
1115
|
onClick: i,
|
|
1116
|
-
disabled:
|
|
1116
|
+
disabled: r ? "disabled" : void 0
|
|
1117
1117
|
};
|
|
1118
1118
|
a && (n.dataset = { testid: a });
|
|
1119
1119
|
const l = u("button", n);
|
|
1120
|
-
l.innerHTML =
|
|
1120
|
+
l.innerHTML = s;
|
|
1121
1121
|
const c = l.querySelector("svg");
|
|
1122
1122
|
return c && c.setAttribute("aria-hidden", "true"), l;
|
|
1123
1123
|
}
|
|
1124
|
-
function $({ label:
|
|
1125
|
-
const
|
|
1124
|
+
function $({ label: s, icon: e, active: t = !1, onClick: i }) {
|
|
1125
|
+
const r = u("button", {
|
|
1126
1126
|
type: "button",
|
|
1127
1127
|
className: `chip ${t ? "active" : ""}`.trim(),
|
|
1128
1128
|
onClick: i
|
|
@@ -1131,13 +1131,13 @@ function $({ label: r, icon: e, active: t = !1, onClick: i }) {
|
|
|
1131
1131
|
const a = u("span", { className: "chip-icon" });
|
|
1132
1132
|
a.innerHTML = e;
|
|
1133
1133
|
const o = a.querySelector("svg");
|
|
1134
|
-
o && o.setAttribute("aria-hidden", "true"),
|
|
1134
|
+
o && o.setAttribute("aria-hidden", "true"), r.appendChild(a);
|
|
1135
1135
|
}
|
|
1136
|
-
return
|
|
1137
|
-
|
|
1138
|
-
},
|
|
1136
|
+
return r.appendChild(u("span", { className: "chip-label" }, s)), r.setActive = (a) => {
|
|
1137
|
+
r.classList.toggle("active", a);
|
|
1138
|
+
}, r;
|
|
1139
1139
|
}
|
|
1140
|
-
const
|
|
1140
|
+
const le = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M328 112L184 256l144 144"/></svg>', ce = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="M184 112l144 144-144 144"/></svg>', ve = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M256 184v74m-37-37h74"/></svg>', ke = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M338.29 338.29L448 448M184 221h74"/></svg>', Pe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M432 320v112H320M80 192V80h112M320 80h112v112M192 432H80V320"/></svg>', Me = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M262.29 192.31a64 64 0 1057.4 57.4 64.13 64.13 0 00-57.4-57.4z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416.39 256a154.34 154.34 0 01-1.53 20.79l45.21 35.46a10.81 10.81 0 012.45 13.75l-42.77 74a10.81 10.81 0 01-13.14 4.59l-44.9-18.08a16.11 16.11 0 00-15.17 1.75A164.48 164.48 0 01325 400.8a15.94 15.94 0 00-8.82 12.14l-6.73 47.89a11.08 11.08 0 01-10.68 9.17h-85.54a11.11 11.11 0 01-10.69-8.87l-6.72-47.82a16.07 16.07 0 00-9-12.22 155.3 155.3 0 01-21.46-12.57 16 16 0 00-15.11-1.71l-44.89 18.07a10.81 10.81 0 01-13.14-4.58l-42.77-74a10.8 10.8 0 012.45-13.75l38.21-30a16.05 16.05 0 006-14.08c-.36-4.17-.58-8.33-.58-12.5s.21-8.27.58-12.35a16 16 0 00-6.07-13.94l-38.19-30A10.81 10.81 0 0149.48 186l42.77-74a10.81 10.81 0 0113.14-4.59l44.9 18.08a16.11 16.11 0 0015.17-1.75A164.48 164.48 0 01187 111.2a15.94 15.94 0 008.82-12.14l6.73-47.89A11.08 11.08 0 01213.23 42h85.54a11.11 11.11 0 0110.69 8.87l6.72 47.82a16.07 16.07 0 009 12.22 155.3 155.3 0 0121.46 12.57 16 16 0 0015.11 1.71l44.89-18.07a10.81 10.81 0 0113.14 4.58l42.77 74a10.8 10.8 0 01-2.45 13.75l-38.21 30a16.05 16.05 0 00-6.05 14.08c.33 4.14.55 8.3.55 12.47z"/></svg>', Fe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M344 328a72 72 0 01-72 72"/></svg>', Ae = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32" d="M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z"/><circle cx="144" cy="208" r="32"/><circle cx="152" cy="311" r="32"/><circle cx="224" cy="144" r="32"/><circle cx="256" cy="367" r="32"/><circle cx="328" cy="144" r="32"/></svg>', ze = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z"/></svg>', Ne = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M176 112l80-80 80 80M255.98 32l.02 448M176 400l80 80 80-80M400 176l80 80-80 80M112 176l-80 80 80 80M32 256h448"/></svg>', Re = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z"/></svg>', he = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M144 48v272a48 48 0 0048 48h272"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 464V192a48 48 0 00-48-48H48"/></svg>', Te = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z"/></svg>', Z = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M368 368L144 144M368 144L144 368"/></svg>', de = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M320 146s24.36-12-64-12a160 160 0 10160 160"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 58l80 80-80 80"/></svg>', Ie = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M80 112h352"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224"/></svg>', Ee = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M64 192v-72a40 40 0 0140-40h75.89a40 40 0 0122.19 6.72l27.84 18.56a40 40 0 0022.19 6.72H408a40 40 0 0140 40v40"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M479.9 226.55L463.68 392a40 40 0 01-39.93 40H88.25a40 40 0 01-39.93-40L32.1 226.55A32 32 0 0164 192h384.1a32 32 0 0131.8 34.55z"/></svg>', W = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M416 128L192 384l-96-96"/></svg>', Xe = '<svg viewBox="0 0 512 512" width="20" height="20"><rect x="64" y="64" width="384" height="384" rx="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>', Ye = '<svg viewBox="0 0 512 512" width="20" height="20"><circle cx="256" cy="256" r="208" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>', Be = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M80 96h64l64 320h64l64-160h96"/></svg>', G = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32" d="M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32"/></svg>', K = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 136c0-30.62 4.51-61.61 16-88C99.57 81.27 48 159.32 48 248c0 119.29 96.71 216 216 216 88.68 0 166.73-51.57 200-128-26.39 11.49-57.38 16-88 16-119.29 0-216-96.71-216-216z"/></svg>', Oe = '<svg viewBox="0 0 512 512" width="20" height="20"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M436 80H76a44.05 44.05 0 00-44 44v264a44.05 44.05 0 0044 44h360a44.05 44.05 0 0044-44V124a44.05 44.05 0 00-44-44z"/><circle cx="256" cy="256" r="80" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M220 80v56M292 80v56M220 376v56M292 376v56M80 144h56M80 224h56M80 304h56M376 144h56M376 224h56M376 304h56"/></svg>';
|
|
1141
1141
|
class Le {
|
|
1142
1142
|
constructor(e, t) {
|
|
1143
1143
|
this.state = e, this.editor = t, this.element = null, this._unsubscribers = [];
|
|
@@ -1148,8 +1148,8 @@ class Le {
|
|
|
1148
1148
|
*/
|
|
1149
1149
|
render() {
|
|
1150
1150
|
this.element = u("div", { className: "editor-toolbar" });
|
|
1151
|
-
const e = u("div", { className: "toolbar-section toolbar-left" }), t =
|
|
1152
|
-
icon:
|
|
1151
|
+
const e = u("div", { className: "toolbar-section toolbar-left" }), t = C({
|
|
1152
|
+
icon: Ee,
|
|
1153
1153
|
title: "Open Image",
|
|
1154
1154
|
className: "toolbar-btn",
|
|
1155
1155
|
testId: "btn-open-image",
|
|
@@ -1157,8 +1157,8 @@ class Le {
|
|
|
1157
1157
|
onClick: () => this.editor.openFilePicker()
|
|
1158
1158
|
});
|
|
1159
1159
|
e.appendChild(t);
|
|
1160
|
-
const i = u("div", { className: "toolbar-section toolbar-center" }),
|
|
1161
|
-
icon:
|
|
1160
|
+
const i = u("div", { className: "toolbar-section toolbar-center" }), r = C({
|
|
1161
|
+
icon: ke,
|
|
1162
1162
|
title: "Zoom Out",
|
|
1163
1163
|
className: "toolbar-btn",
|
|
1164
1164
|
testId: "btn-zoom-out",
|
|
@@ -1174,8 +1174,8 @@ class Le {
|
|
|
1174
1174
|
"aria-atomic": "true",
|
|
1175
1175
|
role: "status"
|
|
1176
1176
|
}, "100%");
|
|
1177
|
-
const a =
|
|
1178
|
-
icon:
|
|
1177
|
+
const a = C({
|
|
1178
|
+
icon: ve,
|
|
1179
1179
|
title: "Zoom In",
|
|
1180
1180
|
className: "toolbar-btn",
|
|
1181
1181
|
testId: "btn-zoom-in",
|
|
@@ -1184,60 +1184,73 @@ class Le {
|
|
|
1184
1184
|
const h = this.state.get("zoom");
|
|
1185
1185
|
this.editor.setZoom(h + 0.25);
|
|
1186
1186
|
}
|
|
1187
|
-
}), o =
|
|
1188
|
-
icon:
|
|
1187
|
+
}), o = C({
|
|
1188
|
+
icon: Pe,
|
|
1189
1189
|
title: "Fit to Screen",
|
|
1190
1190
|
className: "toolbar-btn",
|
|
1191
1191
|
testId: "btn-fit-screen",
|
|
1192
1192
|
ariaLabel: "Fit to screen",
|
|
1193
1193
|
onClick: () => this.editor.fitToScreen()
|
|
1194
1194
|
});
|
|
1195
|
-
i.appendChild(
|
|
1195
|
+
i.appendChild(r), i.appendChild(this._zoomLabel), i.appendChild(a), i.appendChild(o);
|
|
1196
1196
|
const n = u("div", { className: "toolbar-section toolbar-right" });
|
|
1197
|
-
this._themeBtn =
|
|
1198
|
-
icon: this.state.get("isDarkMode") ?
|
|
1197
|
+
this._themeBtn = C({
|
|
1198
|
+
icon: this.state.get("isDarkMode") ? G : K,
|
|
1199
1199
|
title: "Toggle Theme",
|
|
1200
|
-
className: "toolbar-btn",
|
|
1200
|
+
className: "toolbar-btn toolbar-btn-theme",
|
|
1201
1201
|
testId: "btn-toggle-theme",
|
|
1202
1202
|
ariaLabel: "Toggle theme",
|
|
1203
1203
|
onClick: () => this.editor.toggleTheme()
|
|
1204
|
+
}), this._cropBtn = C({
|
|
1205
|
+
icon: he,
|
|
1206
|
+
title: "Crop",
|
|
1207
|
+
className: "toolbar-btn toolbar-btn-crop",
|
|
1208
|
+
testId: "btn-crop",
|
|
1209
|
+
ariaLabel: "Crop image",
|
|
1210
|
+
onClick: () => {
|
|
1211
|
+
this.state.get("mode") === "crop" ? this.editor.setMode("filters") : this.editor.setMode("crop");
|
|
1212
|
+
}
|
|
1204
1213
|
});
|
|
1205
|
-
const l =
|
|
1206
|
-
icon:
|
|
1214
|
+
const l = C({
|
|
1215
|
+
icon: de,
|
|
1207
1216
|
title: "Reset All",
|
|
1208
1217
|
className: "toolbar-btn",
|
|
1209
1218
|
testId: "btn-reset-all",
|
|
1210
1219
|
ariaLabel: "Reset all changes",
|
|
1211
1220
|
onClick: () => this.editor.resetAll()
|
|
1212
|
-
}), c =
|
|
1221
|
+
}), c = C({
|
|
1213
1222
|
icon: Te,
|
|
1214
1223
|
title: "Save Image",
|
|
1215
1224
|
className: "toolbar-btn toolbar-btn-primary",
|
|
1216
1225
|
testId: "btn-save-edit",
|
|
1217
1226
|
ariaLabel: "Save image",
|
|
1218
1227
|
onClick: () => this.editor.save()
|
|
1219
|
-
}), d =
|
|
1220
|
-
icon:
|
|
1228
|
+
}), d = C({
|
|
1229
|
+
icon: Z,
|
|
1221
1230
|
title: "Close",
|
|
1222
1231
|
className: "toolbar-btn",
|
|
1223
1232
|
testId: "btn-cancel-edit",
|
|
1224
1233
|
ariaLabel: "Close editor",
|
|
1225
1234
|
onClick: () => this.editor.close()
|
|
1226
1235
|
});
|
|
1227
|
-
return n.appendChild(this._themeBtn), n.appendChild(l), n.appendChild(c), n.appendChild(d), this.element.appendChild(e), this.element.appendChild(i), this.element.appendChild(n), this._subscribeToState(), this.element;
|
|
1236
|
+
return n.appendChild(this._themeBtn), n.appendChild(this._cropBtn), n.appendChild(l), n.appendChild(c), n.appendChild(d), this.element.appendChild(e), this.element.appendChild(i), this.element.appendChild(n), this._subscribeToState(), this.element;
|
|
1228
1237
|
}
|
|
1229
1238
|
/**
|
|
1230
1239
|
* Subscribe to state changes
|
|
1231
1240
|
*/
|
|
1232
1241
|
_subscribeToState() {
|
|
1233
|
-
const e = this.state.on("change:zoom", ({ value:
|
|
1234
|
-
this._zoomLabel.textContent = `${Math.round(
|
|
1242
|
+
const e = this.state.on("change:zoom", ({ value: r }) => {
|
|
1243
|
+
this._zoomLabel.textContent = `${Math.round(r * 100)}%`;
|
|
1235
1244
|
});
|
|
1236
1245
|
this._unsubscribers.push(e);
|
|
1237
|
-
const t = this.state.on("change:isDarkMode", ({ value:
|
|
1238
|
-
this._themeBtn.innerHTML =
|
|
1246
|
+
const t = this.state.on("change:isDarkMode", ({ value: r }) => {
|
|
1247
|
+
this._themeBtn.innerHTML = r ? G : K;
|
|
1239
1248
|
});
|
|
1240
1249
|
this._unsubscribers.push(t);
|
|
1250
|
+
const i = this.state.on("change:mode", ({ value: r }) => {
|
|
1251
|
+
this._cropBtn && this._cropBtn.classList.toggle("toolbar-btn-primary", r === "crop");
|
|
1252
|
+
});
|
|
1253
|
+
this._unsubscribers.push(i);
|
|
1241
1254
|
}
|
|
1242
1255
|
/**
|
|
1243
1256
|
* Update zoom display
|
|
@@ -1255,23 +1268,23 @@ class Le {
|
|
|
1255
1268
|
}
|
|
1256
1269
|
}
|
|
1257
1270
|
const O = [
|
|
1258
|
-
{ id: "adjust", name: "Adjust", icon:
|
|
1271
|
+
{ id: "adjust", name: "Adjust", icon: Me },
|
|
1259
1272
|
// adjustment, adjustmentAdvanced, alpha
|
|
1260
|
-
{ id: "blur", name: "Blur", icon:
|
|
1273
|
+
{ id: "blur", name: "Blur", icon: Fe },
|
|
1261
1274
|
// blur, kawaseBlur, motionBlur, radialBlur, etc.
|
|
1262
|
-
{ id: "color", name: "Color", icon:
|
|
1275
|
+
{ id: "color", name: "Color", icon: Ae },
|
|
1263
1276
|
// colorOverlay, grayscale, hslAdjustment, etc.
|
|
1264
|
-
{ id: "effects", name: "Effects", icon:
|
|
1277
|
+
{ id: "effects", name: "Effects", icon: ze },
|
|
1265
1278
|
// noise, vignette, pixelate, dropShadow, etc.
|
|
1266
|
-
{ id: "distortion", name: "Distortion", icon:
|
|
1279
|
+
{ id: "distortion", name: "Distortion", icon: Ne },
|
|
1267
1280
|
// twist, bulgePinch, displacement, etc.
|
|
1268
|
-
{ id: "light", name: "Light", icon:
|
|
1281
|
+
{ id: "light", name: "Light", icon: Re },
|
|
1269
1282
|
// bloom, glow, godray, advancedBloom
|
|
1270
1283
|
{ id: "stylize", name: "Stylize", icon: Oe },
|
|
1271
1284
|
// ascii, crt, crossHatch, dot, emboss
|
|
1272
|
-
{ id: "crop", name: "Crop", icon:
|
|
1285
|
+
{ id: "crop", name: "Crop", icon: he }
|
|
1273
1286
|
];
|
|
1274
|
-
class
|
|
1287
|
+
class De {
|
|
1275
1288
|
constructor(e, t) {
|
|
1276
1289
|
this.state = e, this.editor = t, this.element = null, this._chips = /* @__PURE__ */ new Map(), this._scrollIndex = 0, this._unsubscribers = [];
|
|
1277
1290
|
}
|
|
@@ -1284,21 +1297,21 @@ class Ue {
|
|
|
1284
1297
|
this._onSelect = e, this.element = u("div", {
|
|
1285
1298
|
className: "category-carousel-container",
|
|
1286
1299
|
"data-testid": "category-carousel"
|
|
1287
|
-
}), this._leftBtn =
|
|
1288
|
-
icon:
|
|
1300
|
+
}), this._leftBtn = C({
|
|
1301
|
+
icon: le,
|
|
1289
1302
|
title: "Previous categories",
|
|
1290
1303
|
className: "carousel-nav carousel-nav-left",
|
|
1291
1304
|
onClick: () => this._scrollLeft()
|
|
1292
1305
|
}), this._carousel = u("div", { className: "category-carousel" }), O.forEach((i) => {
|
|
1293
|
-
const
|
|
1306
|
+
const r = $({
|
|
1294
1307
|
label: i.name,
|
|
1295
1308
|
icon: i.icon,
|
|
1296
1309
|
active: this.state.get("selectedCategory") === i.id,
|
|
1297
1310
|
onClick: () => this._selectCategory(i.id)
|
|
1298
1311
|
});
|
|
1299
|
-
|
|
1300
|
-
}), this._rightBtn =
|
|
1301
|
-
icon:
|
|
1312
|
+
r.dataset.categoryId = i.id, r.dataset.category = i.id, r.dataset.testid = `category-${i.id}`, this._chips.set(i.id, r), this._carousel.appendChild(r);
|
|
1313
|
+
}), this._rightBtn = C({
|
|
1314
|
+
icon: ce,
|
|
1302
1315
|
title: "Next categories",
|
|
1303
1316
|
className: "carousel-nav carousel-nav-right",
|
|
1304
1317
|
onClick: () => this._scrollRight()
|
|
@@ -1309,7 +1322,7 @@ class Ue {
|
|
|
1309
1322
|
});
|
|
1310
1323
|
const t = Math.ceil(O.length / 3);
|
|
1311
1324
|
for (let i = 0; i < t; i++) {
|
|
1312
|
-
const
|
|
1325
|
+
const r = u("button", {
|
|
1313
1326
|
type: "button",
|
|
1314
1327
|
className: `pagination-dot ${i === 0 ? "active" : ""}`,
|
|
1315
1328
|
role: "tab",
|
|
@@ -1317,7 +1330,7 @@ class Ue {
|
|
|
1317
1330
|
"aria-selected": i === 0 ? "true" : "false",
|
|
1318
1331
|
onClick: () => this._scrollToPage(i)
|
|
1319
1332
|
});
|
|
1320
|
-
this._pagination.appendChild(
|
|
1333
|
+
this._pagination.appendChild(r);
|
|
1321
1334
|
}
|
|
1322
1335
|
return this.element.appendChild(this._leftBtn), this.element.appendChild(this._carousel), this.element.appendChild(this._rightBtn), this.element.appendChild(this._pagination), this._subscribeToState(), this._updateNavButtons(), this.element;
|
|
1323
1336
|
}
|
|
@@ -1326,8 +1339,8 @@ class Ue {
|
|
|
1326
1339
|
*/
|
|
1327
1340
|
_subscribeToState() {
|
|
1328
1341
|
const e = this.state.on("change:selectedCategory", ({ value: t }) => {
|
|
1329
|
-
this._chips.forEach((i,
|
|
1330
|
-
i.setActive(
|
|
1342
|
+
this._chips.forEach((i, r) => {
|
|
1343
|
+
i.setActive(r === t);
|
|
1331
1344
|
});
|
|
1332
1345
|
});
|
|
1333
1346
|
this._unsubscribers.push(e);
|
|
@@ -1385,8 +1398,8 @@ class Ue {
|
|
|
1385
1398
|
_updatePagination() {
|
|
1386
1399
|
if (this._pagination) {
|
|
1387
1400
|
const e = this._pagination.querySelectorAll(".pagination-dot"), t = Math.floor(this._scrollIndex / 3);
|
|
1388
|
-
e.forEach((i,
|
|
1389
|
-
const a =
|
|
1401
|
+
e.forEach((i, r) => {
|
|
1402
|
+
const a = r === t;
|
|
1390
1403
|
i.classList.toggle("active", a), i.setAttribute("aria-selected", a ? "true" : "false");
|
|
1391
1404
|
});
|
|
1392
1405
|
}
|
|
@@ -1406,7 +1419,7 @@ class Ue {
|
|
|
1406
1419
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._chips.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
1407
1420
|
}
|
|
1408
1421
|
}
|
|
1409
|
-
class
|
|
1422
|
+
class Ue {
|
|
1410
1423
|
constructor(e, t) {
|
|
1411
1424
|
this.state = e, this.filterManager = t, this.element = null, this._filterCards = /* @__PURE__ */ new Map(), this._scrollIndex = 0, this._unsubscribers = [], this._onToggle = null, this._onSelect = null;
|
|
1412
1425
|
}
|
|
@@ -1416,13 +1429,13 @@ class De {
|
|
|
1416
1429
|
* @returns {HTMLElement}
|
|
1417
1430
|
*/
|
|
1418
1431
|
render({ onToggle: e, onSelect: t }) {
|
|
1419
|
-
return this._onToggle = e, this._onSelect = t, this.element = u("div", { className: "filter-carousel-container" }), this._leftBtn =
|
|
1420
|
-
icon:
|
|
1432
|
+
return this._onToggle = e, this._onSelect = t, this.element = u("div", { className: "filter-carousel-container" }), this._leftBtn = C({
|
|
1433
|
+
icon: le,
|
|
1421
1434
|
title: "Previous filters",
|
|
1422
1435
|
className: "carousel-nav carousel-nav-left",
|
|
1423
1436
|
onClick: () => this._scrollLeft()
|
|
1424
|
-
}), this._carousel = u("div", { className: "filter-carousel" }), this._rightBtn =
|
|
1425
|
-
icon:
|
|
1437
|
+
}), this._carousel = u("div", { className: "filter-carousel" }), this._rightBtn = C({
|
|
1438
|
+
icon: ce,
|
|
1426
1439
|
title: "Next filters",
|
|
1427
1440
|
className: "carousel-nav carousel-nav-right",
|
|
1428
1441
|
onClick: () => this._scrollRight()
|
|
@@ -1452,11 +1465,11 @@ class De {
|
|
|
1452
1465
|
this._carousel.innerHTML = "", this._filterCards.clear(), this._scrollIndex = 0;
|
|
1453
1466
|
const e = this.state.get("selectedCategory");
|
|
1454
1467
|
if (e === "crop") return;
|
|
1455
|
-
const t = this.filterManager.getFiltersByCategory(e), i = this.state.get("activeFilters"),
|
|
1468
|
+
const t = this.filterManager.getFiltersByCategory(e), i = this.state.get("activeFilters"), r = this.state.get("selectedFilter");
|
|
1456
1469
|
t.forEach((a) => {
|
|
1457
1470
|
const o = this._createFilterCard(a, {
|
|
1458
1471
|
isActive: i.has(a.id),
|
|
1459
|
-
isSelected:
|
|
1472
|
+
isSelected: r === a.id
|
|
1460
1473
|
});
|
|
1461
1474
|
this._filterCards.set(a.id, o), this._carousel.appendChild(o);
|
|
1462
1475
|
}), this._updateNavButtons();
|
|
@@ -1468,7 +1481,7 @@ class De {
|
|
|
1468
1481
|
* @returns {HTMLElement}
|
|
1469
1482
|
*/
|
|
1470
1483
|
_createFilterCard(e, { isActive: t, isSelected: i }) {
|
|
1471
|
-
const
|
|
1484
|
+
const r = u("div", {
|
|
1472
1485
|
className: `filter-card ${t ? "active" : ""} ${i ? "selected" : ""}`,
|
|
1473
1486
|
"data-filter": e.id,
|
|
1474
1487
|
"data-testid": `filter-${e.id}`,
|
|
@@ -1484,7 +1497,7 @@ class De {
|
|
|
1484
1497
|
this._handleToggle(e.id, h), h && (this.state.set("selectedFilter", e.id), (p = this._onSelect) == null || p.call(this, e.id));
|
|
1485
1498
|
}
|
|
1486
1499
|
});
|
|
1487
|
-
return l.innerHTML = t ?
|
|
1500
|
+
return l.innerHTML = t ? W : "", r.appendChild(a), r.appendChild(n), r.appendChild(l), r._toggle = l, r._isActive = t, r;
|
|
1488
1501
|
}
|
|
1489
1502
|
/**
|
|
1490
1503
|
* Handle filter card click (select)
|
|
@@ -1509,8 +1522,8 @@ class De {
|
|
|
1509
1522
|
_updateActiveStates() {
|
|
1510
1523
|
const e = this.state.get("activeFilters");
|
|
1511
1524
|
this._filterCards.forEach((t, i) => {
|
|
1512
|
-
const
|
|
1513
|
-
t.classList.toggle("active",
|
|
1525
|
+
const r = e.has(i);
|
|
1526
|
+
t.classList.toggle("active", r), t._toggle.classList.toggle("active", r), t._toggle.innerHTML = r ? W : "", t._isActive = r;
|
|
1514
1527
|
});
|
|
1515
1528
|
}
|
|
1516
1529
|
/**
|
|
@@ -1608,16 +1621,16 @@ class Ve {
|
|
|
1608
1621
|
return;
|
|
1609
1622
|
}
|
|
1610
1623
|
const i = u("div", { className: "adjustments-header" });
|
|
1611
|
-
i.appendChild(u("span", { className: "adjustments-title" }, t.name)), i.appendChild(
|
|
1624
|
+
i.appendChild(u("span", { className: "adjustments-title" }, t.name)), i.appendChild(F({
|
|
1612
1625
|
label: "Reset",
|
|
1613
1626
|
className: "btn-text",
|
|
1614
1627
|
onClick: () => this._handleReset(e)
|
|
1615
1628
|
})), this.element.appendChild(i);
|
|
1616
|
-
const
|
|
1629
|
+
const r = u("div", { className: "adjustments-grid" }), a = this.state.getFilterValues(e);
|
|
1617
1630
|
t.controls.forEach((o) => {
|
|
1618
1631
|
const n = this._createControl(e, o, a[o.id] ?? o.default);
|
|
1619
|
-
n && (this._controls.set(o.id, n),
|
|
1620
|
-
}), this.element.appendChild(
|
|
1632
|
+
n && (this._controls.set(o.id, n), r.appendChild(n));
|
|
1633
|
+
}), this.element.appendChild(r);
|
|
1621
1634
|
}
|
|
1622
1635
|
/**
|
|
1623
1636
|
* Create a control element based on type
|
|
@@ -1628,12 +1641,12 @@ class Ve {
|
|
|
1628
1641
|
*/
|
|
1629
1642
|
_createControl(e, t, i) {
|
|
1630
1643
|
if (t.hidden) return null;
|
|
1631
|
-
const
|
|
1644
|
+
const r = t.label || t.id;
|
|
1632
1645
|
switch (this._normalizeControlType(t.type)) {
|
|
1633
1646
|
case "slider":
|
|
1634
|
-
return
|
|
1647
|
+
return se({
|
|
1635
1648
|
id: `${e}-${t.id}`,
|
|
1636
|
-
label:
|
|
1649
|
+
label: r,
|
|
1637
1650
|
min: t.min ?? 0,
|
|
1638
1651
|
max: t.max ?? 1,
|
|
1639
1652
|
step: t.step ?? 0.01,
|
|
@@ -1641,32 +1654,32 @@ class Ve {
|
|
|
1641
1654
|
onChange: (l) => this._handleChange(e, t.id, l)
|
|
1642
1655
|
});
|
|
1643
1656
|
case "toggle":
|
|
1644
|
-
return
|
|
1657
|
+
return ae({
|
|
1645
1658
|
id: `${e}-${t.id}`,
|
|
1646
|
-
label:
|
|
1659
|
+
label: r,
|
|
1647
1660
|
checked: !!i,
|
|
1648
1661
|
onChange: (l) => this._handleChange(e, t.id, l)
|
|
1649
1662
|
});
|
|
1650
1663
|
case "color":
|
|
1651
|
-
return
|
|
1664
|
+
return oe({
|
|
1652
1665
|
id: `${e}-${t.id}`,
|
|
1653
|
-
label:
|
|
1666
|
+
label: r,
|
|
1654
1667
|
value: typeof i == "string" && i.startsWith("#") ? i : t.default || "#000000",
|
|
1655
1668
|
onChange: (l) => this._handleChange(e, t.id, l)
|
|
1656
1669
|
});
|
|
1657
1670
|
case "select":
|
|
1658
1671
|
const o = this._normalizeOptions(t.options);
|
|
1659
|
-
return
|
|
1672
|
+
return ne({
|
|
1660
1673
|
id: `${e}-${t.id}`,
|
|
1661
|
-
label:
|
|
1674
|
+
label: r,
|
|
1662
1675
|
options: o,
|
|
1663
1676
|
value: i ?? t.default,
|
|
1664
1677
|
onChange: (l) => this._handleChange(e, t.id, l)
|
|
1665
1678
|
});
|
|
1666
1679
|
case "button":
|
|
1667
1680
|
const n = u("div", { className: "button-control" });
|
|
1668
|
-
return n.appendChild(
|
|
1669
|
-
label:
|
|
1681
|
+
return n.appendChild(F({
|
|
1682
|
+
label: r,
|
|
1670
1683
|
className: "btn-secondary",
|
|
1671
1684
|
onClick: () => this._handleAction(e, t.action || t.id)
|
|
1672
1685
|
})), n;
|
|
@@ -1711,8 +1724,8 @@ class Ve {
|
|
|
1711
1724
|
* @param {*} value
|
|
1712
1725
|
*/
|
|
1713
1726
|
_handleChange(e, t, i) {
|
|
1714
|
-
var
|
|
1715
|
-
(
|
|
1727
|
+
var r;
|
|
1728
|
+
(r = this._onChange) == null || r.call(this, e, t, i);
|
|
1716
1729
|
}
|
|
1717
1730
|
/**
|
|
1718
1731
|
* Handle reset button
|
|
@@ -1738,10 +1751,10 @@ class Ve {
|
|
|
1738
1751
|
const e = this.state.get("selectedFilter");
|
|
1739
1752
|
if (!e) return;
|
|
1740
1753
|
const t = this.state.getFilterValues(e), i = this.filterManager.getFilterDef(e);
|
|
1741
|
-
i && i.controls.forEach((
|
|
1742
|
-
const a = this._controls.get(
|
|
1754
|
+
i && i.controls.forEach((r) => {
|
|
1755
|
+
const a = this._controls.get(r.id);
|
|
1743
1756
|
if (a && typeof a.setValue == "function") {
|
|
1744
|
-
const o = t[
|
|
1757
|
+
const o = t[r.id] ?? r.default;
|
|
1745
1758
|
a.setValue(o);
|
|
1746
1759
|
}
|
|
1747
1760
|
});
|
|
@@ -1766,11 +1779,280 @@ class Ve {
|
|
|
1766
1779
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._controls.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
1767
1780
|
}
|
|
1768
1781
|
}
|
|
1769
|
-
|
|
1782
|
+
class je {
|
|
1783
|
+
constructor(e, t) {
|
|
1784
|
+
this.state = e, this.filterManager = t, this._drawer = null, this._body = null, this._titleEl = null, this._isOpen = !1, this._currentFilterId = null, this._controls = /* @__PURE__ */ new Map(), this._onChange = null, this._onReset = null, this._onRemove = null, this._onAction = null, this._container = null;
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Build the drawer DOM and append to container (should be the controls section)
|
|
1788
|
+
* @param {HTMLElement} container - Parent element (controls-section)
|
|
1789
|
+
* @param {Object} callbacks - { onChange, onReset, onRemove, onAction }
|
|
1790
|
+
*/
|
|
1791
|
+
build(e, { onChange: t, onReset: i, onRemove: r, onAction: a }) {
|
|
1792
|
+
this._onChange = t, this._onReset = i, this._onRemove = r, this._onAction = a, this._container = e, this._drawer = u("div", { className: "mobile-filter-drawer" });
|
|
1793
|
+
const o = u("div", { className: "drawer-header" });
|
|
1794
|
+
this._titleEl = u("span", { className: "drawer-title" }, "Filter");
|
|
1795
|
+
const n = u("div", { className: "drawer-header-actions" }), l = F({
|
|
1796
|
+
label: "Reset",
|
|
1797
|
+
className: "btn-text",
|
|
1798
|
+
onClick: () => {
|
|
1799
|
+
var h;
|
|
1800
|
+
this._currentFilterId && ((h = this._onReset) == null || h.call(this, this._currentFilterId), this._renderControls());
|
|
1801
|
+
}
|
|
1802
|
+
}), c = F({
|
|
1803
|
+
label: "Remove",
|
|
1804
|
+
className: "btn-text btn-danger",
|
|
1805
|
+
onClick: () => {
|
|
1806
|
+
var h;
|
|
1807
|
+
this._currentFilterId && ((h = this._onRemove) == null || h.call(this, this._currentFilterId), this.close());
|
|
1808
|
+
}
|
|
1809
|
+
}), d = C({
|
|
1810
|
+
icon: Z,
|
|
1811
|
+
title: "Close",
|
|
1812
|
+
className: "btn-icon-sm",
|
|
1813
|
+
ariaLabel: "Close drawer",
|
|
1814
|
+
onClick: () => this.close()
|
|
1815
|
+
});
|
|
1816
|
+
n.appendChild(l), n.appendChild(c), n.appendChild(d), o.appendChild(this._titleEl), o.appendChild(n), this._drawer.appendChild(o), this._body = u("div", { className: "drawer-body" }), this._drawer.appendChild(this._body), e.appendChild(this._drawer);
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Open the drawer for a specific filter
|
|
1820
|
+
* @param {string} filterId
|
|
1821
|
+
*/
|
|
1822
|
+
open(e) {
|
|
1823
|
+
this._isOpen && this._currentFilterId === e || (this._currentFilterId = e, this._renderControls(), this._isOpen || (this._isOpen = !0, this._sizeToContainer(), this._animateOpen()));
|
|
1824
|
+
}
|
|
1825
|
+
/**
|
|
1826
|
+
* Close the drawer
|
|
1827
|
+
*/
|
|
1828
|
+
close() {
|
|
1829
|
+
this._isOpen && (this._isOpen = !1, this._animateClose(), this._currentFilterId = null);
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Check if drawer is open
|
|
1833
|
+
* @returns {boolean}
|
|
1834
|
+
*/
|
|
1835
|
+
get isOpen() {
|
|
1836
|
+
return this._isOpen;
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Size the drawer to match the container (controls section) height
|
|
1840
|
+
*/
|
|
1841
|
+
_sizeToContainer() {
|
|
1842
|
+
if (!this._container || !this._drawer) return;
|
|
1843
|
+
const e = this._container.offsetHeight;
|
|
1844
|
+
e > 0 && (this._drawer.style.height = e + "px");
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Animate drawer open (CSS transition)
|
|
1848
|
+
*/
|
|
1849
|
+
_animateOpen() {
|
|
1850
|
+
this._drawer.style.transition = "none", this._drawer.style.transform = "translateY(100%)", this._drawer.offsetHeight, this._drawer.style.transition = "transform 0.25s cubic-bezier(0.33, 1, 0.68, 1)", this._drawer.style.transform = "translateY(0)";
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Animate drawer close (CSS transition)
|
|
1854
|
+
*/
|
|
1855
|
+
_animateClose() {
|
|
1856
|
+
this._drawer.style.transition = "transform 0.2s cubic-bezier(0.32, 0, 0.67, 0)", this._drawer.style.transform = "translateY(100%)";
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Render controls for the current filter
|
|
1860
|
+
*/
|
|
1861
|
+
_renderControls() {
|
|
1862
|
+
if (this._body.innerHTML = "", this._controls.clear(), !this._currentFilterId) return;
|
|
1863
|
+
const e = this.filterManager.getFilterDef(this._currentFilterId);
|
|
1864
|
+
if (!e) return;
|
|
1865
|
+
this._titleEl.textContent = e.name;
|
|
1866
|
+
const t = u("div", { className: "adjustments-grid" }), i = this.state.getFilterValues(this._currentFilterId);
|
|
1867
|
+
e.controls.forEach((r) => {
|
|
1868
|
+
if (r.hidden) return;
|
|
1869
|
+
const a = this._createControl(this._currentFilterId, r, i[r.id] ?? r.default);
|
|
1870
|
+
a && (this._controls.set(r.id, a), t.appendChild(a));
|
|
1871
|
+
}), this._body.appendChild(t);
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Create a control element based on type
|
|
1875
|
+
* @param {string} filterId
|
|
1876
|
+
* @param {Object} ctl
|
|
1877
|
+
* @param {*} value
|
|
1878
|
+
* @returns {HTMLElement|null}
|
|
1879
|
+
*/
|
|
1880
|
+
_createControl(e, t, i) {
|
|
1881
|
+
const r = t.label || t.id;
|
|
1882
|
+
switch (this._normalizeControlType(t.type)) {
|
|
1883
|
+
case "slider":
|
|
1884
|
+
return se({
|
|
1885
|
+
id: `drawer-${e}-${t.id}`,
|
|
1886
|
+
label: r,
|
|
1887
|
+
min: t.min ?? 0,
|
|
1888
|
+
max: t.max ?? 1,
|
|
1889
|
+
step: t.step ?? 0.01,
|
|
1890
|
+
value: typeof i == "number" ? i : t.default ?? 0,
|
|
1891
|
+
onChange: (o) => {
|
|
1892
|
+
var n;
|
|
1893
|
+
return (n = this._onChange) == null ? void 0 : n.call(this, e, t.id, o);
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
case "toggle":
|
|
1897
|
+
return ae({
|
|
1898
|
+
id: `drawer-${e}-${t.id}`,
|
|
1899
|
+
label: r,
|
|
1900
|
+
checked: !!i,
|
|
1901
|
+
onChange: (o) => {
|
|
1902
|
+
var n;
|
|
1903
|
+
return (n = this._onChange) == null ? void 0 : n.call(this, e, t.id, o);
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
case "color":
|
|
1907
|
+
return oe({
|
|
1908
|
+
id: `drawer-${e}-${t.id}`,
|
|
1909
|
+
label: r,
|
|
1910
|
+
value: typeof i == "string" && i.startsWith("#") ? i : t.default || "#000000",
|
|
1911
|
+
onChange: (o) => {
|
|
1912
|
+
var n;
|
|
1913
|
+
return (n = this._onChange) == null ? void 0 : n.call(this, e, t.id, o);
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
case "select": {
|
|
1917
|
+
const o = this._normalizeOptions(t.options);
|
|
1918
|
+
return ne({
|
|
1919
|
+
id: `drawer-${e}-${t.id}`,
|
|
1920
|
+
label: r,
|
|
1921
|
+
options: o,
|
|
1922
|
+
value: i ?? t.default,
|
|
1923
|
+
onChange: (n) => {
|
|
1924
|
+
var l;
|
|
1925
|
+
return (l = this._onChange) == null ? void 0 : l.call(this, e, t.id, n);
|
|
1926
|
+
}
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
case "button": {
|
|
1930
|
+
const o = u("div", { className: "button-control" });
|
|
1931
|
+
return o.appendChild(F({
|
|
1932
|
+
label: r,
|
|
1933
|
+
className: "btn-secondary",
|
|
1934
|
+
onClick: () => {
|
|
1935
|
+
var n;
|
|
1936
|
+
return (n = this._onAction) == null ? void 0 : n.call(this, e, t.action || t.id);
|
|
1937
|
+
}
|
|
1938
|
+
})), o;
|
|
1939
|
+
}
|
|
1940
|
+
default:
|
|
1941
|
+
return null;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Normalize control type
|
|
1946
|
+
* @param {string} type
|
|
1947
|
+
* @returns {string}
|
|
1948
|
+
*/
|
|
1949
|
+
_normalizeControlType(e) {
|
|
1950
|
+
return {
|
|
1951
|
+
slider: "slider",
|
|
1952
|
+
range: "slider",
|
|
1953
|
+
toggle: "toggle",
|
|
1954
|
+
checkbox: "toggle",
|
|
1955
|
+
color: "color",
|
|
1956
|
+
select: "select",
|
|
1957
|
+
dropdown: "select",
|
|
1958
|
+
button: "button",
|
|
1959
|
+
text: "slider"
|
|
1960
|
+
}[e] || e;
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Normalize options array
|
|
1964
|
+
* @param {Array} options
|
|
1965
|
+
* @returns {Array}
|
|
1966
|
+
*/
|
|
1967
|
+
_normalizeOptions(e) {
|
|
1968
|
+
return !e || !Array.isArray(e) ? [] : e.map((t) => typeof t == "object" && t.value !== void 0 ? { value: t.value, label: t.label || String(t.value) } : typeof t == "string" ? { value: t, label: t } : typeof t == "number" ? { value: t, label: String(t) } : { value: t, label: String(t) });
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Clean up
|
|
1972
|
+
*/
|
|
1973
|
+
destroy() {
|
|
1974
|
+
var e;
|
|
1975
|
+
this._controls.clear(), (e = this._drawer) == null || e.remove(), this._drawer = null, this._isOpen = !1, this._currentFilterId = null, this._container = null;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
class qe {
|
|
1979
|
+
constructor(e, t) {
|
|
1980
|
+
this.state = e, this.filterManager = t, this.element = null, this._scrollContainer = null, this._chips = /* @__PURE__ */ new Map(), this._unsubscribers = [], this._onToggle = null, this._onSelect = null;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* @param {Object} callbacks - { onToggle(filterId, enabled), onSelect(filterId) }
|
|
1984
|
+
* @returns {HTMLElement}
|
|
1985
|
+
*/
|
|
1986
|
+
render({ onToggle: e, onSelect: t }) {
|
|
1987
|
+
return this._onToggle = e, this._onSelect = t, this.element = u("div", {
|
|
1988
|
+
className: "mobile-active-filters",
|
|
1989
|
+
"data-testid": "mobile-active-filters"
|
|
1990
|
+
}), this._scrollContainer = u("div", { className: "mobile-active-filters-scroll" }), this.element.appendChild(this._scrollContainer), this._subscribeToState(), this._renderChips(), this.element;
|
|
1991
|
+
}
|
|
1992
|
+
_subscribeToState() {
|
|
1993
|
+
const e = this.state.on("change:activeFilters", () => {
|
|
1994
|
+
this._renderChips();
|
|
1995
|
+
});
|
|
1996
|
+
this._unsubscribers.push(e);
|
|
1997
|
+
const t = this.state.on("change:selectedFilter", () => {
|
|
1998
|
+
this._updateSelectedState();
|
|
1999
|
+
});
|
|
2000
|
+
this._unsubscribers.push(t);
|
|
2001
|
+
}
|
|
2002
|
+
_renderChips() {
|
|
2003
|
+
this._scrollContainer.innerHTML = "", this._chips.clear();
|
|
2004
|
+
const e = this.state.get("activeFilters");
|
|
2005
|
+
if (!e || e.size === 0) {
|
|
2006
|
+
const t = u("div", {
|
|
2007
|
+
className: "active-filter-placeholder"
|
|
2008
|
+
}, "No active filters");
|
|
2009
|
+
this._scrollContainer.appendChild(t);
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
e.forEach((t) => {
|
|
2013
|
+
const i = this.filterManager.getFilterDef(t);
|
|
2014
|
+
if (!i) return;
|
|
2015
|
+
const r = this._createChip(t, i);
|
|
2016
|
+
this._chips.set(t, r), this._scrollContainer.appendChild(r);
|
|
2017
|
+
}), this._updateSelectedState();
|
|
2018
|
+
}
|
|
2019
|
+
_createChip(e, t) {
|
|
2020
|
+
const i = u("div", {
|
|
2021
|
+
className: "active-filter-chip",
|
|
2022
|
+
"data-filter-id": e,
|
|
2023
|
+
"data-testid": `active-chip-${e}`
|
|
2024
|
+
}), r = u("span", {
|
|
2025
|
+
className: "active-filter-chip-label",
|
|
2026
|
+
onClick: (o) => {
|
|
2027
|
+
var n;
|
|
2028
|
+
o.stopPropagation(), (n = this._onSelect) == null || n.call(this, e);
|
|
2029
|
+
}
|
|
2030
|
+
}, t.name), a = u("button", {
|
|
2031
|
+
className: "active-filter-chip-check",
|
|
2032
|
+
"aria-label": `Remove ${t.name} filter`,
|
|
2033
|
+
onClick: (o) => {
|
|
2034
|
+
var n;
|
|
2035
|
+
o.stopPropagation(), (n = this._onToggle) == null || n.call(this, e, !1);
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
return a.innerHTML = '<svg width="10" height="10" viewBox="0 0 12 12"><path d="M2 6l3 3 5-5" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>', i.appendChild(r), i.appendChild(a), i;
|
|
2039
|
+
}
|
|
2040
|
+
_updateSelectedState() {
|
|
2041
|
+
const e = this.state.get("selectedFilter");
|
|
2042
|
+
this._chips.forEach((t, i) => {
|
|
2043
|
+
t.classList.toggle("selected", i === e);
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
destroy() {
|
|
2047
|
+
var e;
|
|
2048
|
+
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._chips.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
const He = [
|
|
1770
2052
|
{ id: "free", name: "Free", icon: Be },
|
|
1771
|
-
{ id: "square", name: "Square", icon:
|
|
2053
|
+
{ id: "square", name: "Square", icon: Xe },
|
|
1772
2054
|
{ id: "circle", name: "Circle", icon: Ye }
|
|
1773
|
-
],
|
|
2055
|
+
], $e = [
|
|
1774
2056
|
{ id: "free", name: "Free" },
|
|
1775
2057
|
{ id: "1:1", name: "1:1" },
|
|
1776
2058
|
{ id: "4:3", name: "4:3" },
|
|
@@ -1778,7 +2060,7 @@ const je = [
|
|
|
1778
2060
|
{ id: "3:2", name: "3:2" },
|
|
1779
2061
|
{ id: "2:3", name: "2:3" }
|
|
1780
2062
|
];
|
|
1781
|
-
class
|
|
2063
|
+
class We {
|
|
1782
2064
|
constructor(e, t) {
|
|
1783
2065
|
this.state = e, this.cropManager = t, this.element = null, this._shapeChips = /* @__PURE__ */ new Map(), this._aspectChips = /* @__PURE__ */ new Map(), this._unsubscribers = [];
|
|
1784
2066
|
}
|
|
@@ -1794,7 +2076,7 @@ class He {
|
|
|
1794
2076
|
const e = u("div", { className: "crop-section" });
|
|
1795
2077
|
e.appendChild(u("label", { className: "section-label" }, "Shape"));
|
|
1796
2078
|
const t = u("div", { className: "chip-row" }), i = this.state.get("crop.shape");
|
|
1797
|
-
|
|
2079
|
+
He.forEach((c) => {
|
|
1798
2080
|
const d = $({
|
|
1799
2081
|
label: c.name,
|
|
1800
2082
|
icon: c.icon,
|
|
@@ -1803,26 +2085,26 @@ class He {
|
|
|
1803
2085
|
});
|
|
1804
2086
|
d.dataset.shape = c.id, d.dataset.testid = `crop-shape-${c.id}`, this._shapeChips.set(c.id, d), t.appendChild(d);
|
|
1805
2087
|
}), e.appendChild(t), this.element.appendChild(e), this.state.get("lockCropShape") && (e.style.display = "none"), this._shapeSection = e, this._aspectSection = u("div", { className: "crop-section" }), this._aspectSection.appendChild(u("label", { className: "section-label" }, "Aspect Ratio"));
|
|
1806
|
-
const
|
|
1807
|
-
|
|
2088
|
+
const r = u("div", { className: "chip-row aspect-row" }), a = this.state.get("crop.aspect");
|
|
2089
|
+
$e.forEach((c) => {
|
|
1808
2090
|
const d = $({
|
|
1809
2091
|
label: c.name,
|
|
1810
2092
|
active: a === c.id,
|
|
1811
2093
|
onClick: () => this._selectAspect(c.id)
|
|
1812
2094
|
});
|
|
1813
|
-
d.dataset.ratio = c.id, d.dataset.testid = `crop-ratio-${c.id}`, this._aspectChips.set(c.id, d),
|
|
1814
|
-
}), this._aspectSection.appendChild(
|
|
1815
|
-
const o = u("div", { className: "crop-actions" }), n =
|
|
2095
|
+
d.dataset.ratio = c.id, d.dataset.testid = `crop-ratio-${c.id}`, this._aspectChips.set(c.id, d), r.appendChild(d);
|
|
2096
|
+
}), this._aspectSection.appendChild(r), this.element.appendChild(this._aspectSection), this._updateAspectVisibility();
|
|
2097
|
+
const o = u("div", { className: "crop-actions" }), n = F({
|
|
1816
2098
|
label: "Cancel",
|
|
1817
2099
|
className: "btn-secondary crop-cancel-btn",
|
|
1818
|
-
icon:
|
|
2100
|
+
icon: Z,
|
|
1819
2101
|
onClick: () => this.cropManager.cancel()
|
|
1820
2102
|
});
|
|
1821
2103
|
n.dataset.testid = "cancel-crop";
|
|
1822
|
-
const l =
|
|
2104
|
+
const l = F({
|
|
1823
2105
|
label: "Apply Crop",
|
|
1824
2106
|
className: "btn-primary crop-apply-btn",
|
|
1825
|
-
icon:
|
|
2107
|
+
icon: W,
|
|
1826
2108
|
onClick: () => this.cropManager.apply()
|
|
1827
2109
|
});
|
|
1828
2110
|
return l.dataset.testid = "apply-crop", o.appendChild(n), o.appendChild(l), this.element.appendChild(o), this._subscribeToState(), this.element;
|
|
@@ -1832,14 +2114,14 @@ class He {
|
|
|
1832
2114
|
*/
|
|
1833
2115
|
_subscribeToState() {
|
|
1834
2116
|
const e = this.state.on("change:crop.shape", ({ value: i }) => {
|
|
1835
|
-
this._shapeChips.forEach((
|
|
1836
|
-
|
|
2117
|
+
this._shapeChips.forEach((r, a) => {
|
|
2118
|
+
r.setActive(a === i);
|
|
1837
2119
|
}), this._updateAspectVisibility();
|
|
1838
2120
|
});
|
|
1839
2121
|
this._unsubscribers.push(e);
|
|
1840
2122
|
const t = this.state.on("change:crop.aspect", ({ value: i }) => {
|
|
1841
|
-
this._aspectChips.forEach((
|
|
1842
|
-
|
|
2123
|
+
this._aspectChips.forEach((r, a) => {
|
|
2124
|
+
r.setActive(a === i);
|
|
1843
2125
|
});
|
|
1844
2126
|
});
|
|
1845
2127
|
this._unsubscribers.push(t);
|
|
@@ -1885,7 +2167,7 @@ class He {
|
|
|
1885
2167
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._shapeChips.clear(), this._aspectChips.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
1886
2168
|
}
|
|
1887
2169
|
}
|
|
1888
|
-
class
|
|
2170
|
+
class Ze {
|
|
1889
2171
|
constructor(e, t) {
|
|
1890
2172
|
this.state = e, this.filterManager = t, this.element = null, this._filterItems = /* @__PURE__ */ new Map(), this._unsubscribers = [], this._onRemove = null, this._onReset = null, this._onClearAll = null, this._onUpdateValue = null, this._onSelect = null;
|
|
1891
2173
|
}
|
|
@@ -1894,14 +2176,14 @@ class $e {
|
|
|
1894
2176
|
* @param {Object} options - { onRemove, onReset, onClearAll, onUpdateValue, onSelect }
|
|
1895
2177
|
* @returns {HTMLElement}
|
|
1896
2178
|
*/
|
|
1897
|
-
render({ onRemove: e, onReset: t, onClearAll: i, onUpdateValue:
|
|
1898
|
-
this._onRemove = e, this._onReset = t, this._onClearAll = i, this._onUpdateValue =
|
|
2179
|
+
render({ onRemove: e, onReset: t, onClearAll: i, onUpdateValue: r, onSelect: a }) {
|
|
2180
|
+
this._onRemove = e, this._onReset = t, this._onClearAll = i, this._onUpdateValue = r, this._onSelect = a, this.element = u("div", {
|
|
1899
2181
|
className: "active-filters-panel",
|
|
1900
2182
|
"data-testid": "active-filters-panel"
|
|
1901
2183
|
});
|
|
1902
2184
|
const o = u("div", { className: "panel-header" });
|
|
1903
2185
|
o.appendChild(u("h3", { className: "panel-title" }, "Active Filters"));
|
|
1904
|
-
const n =
|
|
2186
|
+
const n = F({
|
|
1905
2187
|
label: "Clear All",
|
|
1906
2188
|
className: "btn-text btn-danger",
|
|
1907
2189
|
onClick: () => this._handleClearAll()
|
|
@@ -1949,8 +2231,8 @@ class $e {
|
|
|
1949
2231
|
e.forEach((t) => {
|
|
1950
2232
|
const i = this.filterManager.getFilterDef(t);
|
|
1951
2233
|
if (!i) return;
|
|
1952
|
-
const
|
|
1953
|
-
this._filterItems.set(t,
|
|
2234
|
+
const r = this._createFilterItem(t, i);
|
|
2235
|
+
this._filterItems.set(t, r), this._listContainer.appendChild(r);
|
|
1954
2236
|
});
|
|
1955
2237
|
}
|
|
1956
2238
|
/**
|
|
@@ -1960,19 +2242,19 @@ class $e {
|
|
|
1960
2242
|
* @returns {HTMLElement}
|
|
1961
2243
|
*/
|
|
1962
2244
|
_createFilterItem(e, t) {
|
|
1963
|
-
const
|
|
1964
|
-
className: `active-filter-item ${
|
|
2245
|
+
const r = this.state.get("selectedFilter") === e, a = u("div", {
|
|
2246
|
+
className: `active-filter-item ${r ? "selected" : ""}`,
|
|
1965
2247
|
"data-active-filter": e,
|
|
1966
2248
|
"data-testid": `active-filter-${e}`,
|
|
1967
2249
|
onClick: (m) => {
|
|
1968
2250
|
m.target.closest(".filter-item-actions") || this._handleSelect(e);
|
|
1969
2251
|
}
|
|
1970
|
-
}), o = u("div", { className: "filter-item-header" }), n = u("span", { className: "filter-item-name" }, t.name), l = u("div", { className: "filter-item-actions" }), c =
|
|
1971
|
-
icon:
|
|
2252
|
+
}), o = u("div", { className: "filter-item-header" }), n = u("span", { className: "filter-item-name" }, t.name), l = u("div", { className: "filter-item-actions" }), c = C({
|
|
2253
|
+
icon: de,
|
|
1972
2254
|
title: "Reset filter",
|
|
1973
2255
|
className: "btn-icon-sm",
|
|
1974
2256
|
onClick: () => this._handleReset(e)
|
|
1975
|
-
}), d =
|
|
2257
|
+
}), d = C({
|
|
1976
2258
|
icon: Ie,
|
|
1977
2259
|
title: "Remove filter",
|
|
1978
2260
|
className: "btn-icon-sm btn-danger",
|
|
@@ -2009,11 +2291,11 @@ class $e {
|
|
|
2009
2291
|
if (!e.controls || !Array.isArray(e.controls))
|
|
2010
2292
|
return "Default values";
|
|
2011
2293
|
const i = [];
|
|
2012
|
-
return e.controls.forEach((
|
|
2013
|
-
const a = this._normalizeControlType(
|
|
2294
|
+
return e.controls.forEach((r) => {
|
|
2295
|
+
const a = this._normalizeControlType(r.type);
|
|
2014
2296
|
if (a === "button") return;
|
|
2015
|
-
const o =
|
|
2016
|
-
n !==
|
|
2297
|
+
const o = r.label || r.id, n = t[r.id] ?? r.default;
|
|
2298
|
+
n !== r.default && (a === "slider" ? i.push(`${o}: ${this._formatValue(n)}`) : a === "toggle" ? n && i.push(o) : a === "color" ? i.push(`${o}: ${n}`) : a === "select" && i.push(`${o}: ${n}`));
|
|
2017
2299
|
}), i.length > 0 ? i.join(", ") : "Default values";
|
|
2018
2300
|
}
|
|
2019
2301
|
/**
|
|
@@ -2031,8 +2313,8 @@ class $e {
|
|
|
2031
2313
|
this._filterItems.forEach((e, t) => {
|
|
2032
2314
|
const i = this.filterManager.getFilterDef(t);
|
|
2033
2315
|
if (!i || !e._summaryEl) return;
|
|
2034
|
-
const
|
|
2035
|
-
e._summaryEl.textContent = this._getValuesSummary(i,
|
|
2316
|
+
const r = this.state.getFilterValues(t);
|
|
2317
|
+
e._summaryEl.textContent = this._getValuesSummary(i, r);
|
|
2036
2318
|
});
|
|
2037
2319
|
}
|
|
2038
2320
|
/**
|
|
@@ -2086,7 +2368,7 @@ class $e {
|
|
|
2086
2368
|
this._unsubscribers.forEach((t) => t()), this._unsubscribers = [], this._filterItems.clear(), (e = this.element) == null || e.remove(), this.element = null;
|
|
2087
2369
|
}
|
|
2088
2370
|
}
|
|
2089
|
-
const
|
|
2371
|
+
const Y = {
|
|
2090
2372
|
name: "free",
|
|
2091
2373
|
initialMode: "filters",
|
|
2092
2374
|
cropShape: "free",
|
|
@@ -2100,10 +2382,10 @@ const E = {
|
|
|
2100
2382
|
maxExportHeight: void 0
|
|
2101
2383
|
}, j = {
|
|
2102
2384
|
free: {
|
|
2103
|
-
...
|
|
2385
|
+
...Y
|
|
2104
2386
|
},
|
|
2105
2387
|
avatar: {
|
|
2106
|
-
...
|
|
2388
|
+
...Y,
|
|
2107
2389
|
name: "avatar",
|
|
2108
2390
|
initialMode: "crop",
|
|
2109
2391
|
cropShape: "circle",
|
|
@@ -2113,7 +2395,7 @@ const E = {
|
|
|
2113
2395
|
lockAspectRatio: !0
|
|
2114
2396
|
},
|
|
2115
2397
|
banner: {
|
|
2116
|
-
...
|
|
2398
|
+
...Y,
|
|
2117
2399
|
name: "banner",
|
|
2118
2400
|
initialMode: "crop",
|
|
2119
2401
|
cropShape: "square",
|
|
@@ -2123,7 +2405,7 @@ const E = {
|
|
|
2123
2405
|
lockAspectRatio: !0
|
|
2124
2406
|
},
|
|
2125
2407
|
product: {
|
|
2126
|
-
...
|
|
2408
|
+
...Y,
|
|
2127
2409
|
name: "product",
|
|
2128
2410
|
initialMode: "filters",
|
|
2129
2411
|
cropShape: "square",
|
|
@@ -2133,15 +2415,15 @@ const E = {
|
|
|
2133
2415
|
lockAspectRatio: !1
|
|
2134
2416
|
}
|
|
2135
2417
|
};
|
|
2136
|
-
function
|
|
2137
|
-
if (!
|
|
2418
|
+
function Ge(s) {
|
|
2419
|
+
if (!s)
|
|
2138
2420
|
return { ...j.free };
|
|
2139
|
-
if (typeof
|
|
2140
|
-
return { ...
|
|
2141
|
-
const e = j[
|
|
2421
|
+
if (typeof s == "object" && s !== null)
|
|
2422
|
+
return { ...Y, ...s };
|
|
2423
|
+
const e = j[s];
|
|
2142
2424
|
return e ? { ...e } : { ...j.free };
|
|
2143
2425
|
}
|
|
2144
|
-
class
|
|
2426
|
+
class Gt extends B {
|
|
2145
2427
|
/**
|
|
2146
2428
|
* Create a new VanillaImageEditor
|
|
2147
2429
|
* @param {HTMLElement} container - Container element to mount the editor
|
|
@@ -2152,7 +2434,7 @@ class Zt extends B {
|
|
|
2152
2434
|
if (super(), !e)
|
|
2153
2435
|
throw new Error("VanillaImageEditor: container element is required");
|
|
2154
2436
|
this._container = e;
|
|
2155
|
-
const i = t.preset ?
|
|
2437
|
+
const i = t.preset ? Ge(t.preset) : null, r = i ? {
|
|
2156
2438
|
initialMode: i.initialMode === "crop" ? "crop" : "adjust",
|
|
2157
2439
|
cropShape: i.cropShape,
|
|
2158
2440
|
initialAspectRatio: i.aspectRatio
|
|
@@ -2168,12 +2450,12 @@ class Zt extends B {
|
|
|
2168
2450
|
endpoint: "/api/v1/media/remove-bg",
|
|
2169
2451
|
fallbackEndpoint: null
|
|
2170
2452
|
},
|
|
2171
|
-
...
|
|
2453
|
+
...r,
|
|
2172
2454
|
...t
|
|
2173
|
-
}, this._preset = i, this._state =
|
|
2455
|
+
}, this._preset = i, this._state = _e(), this._state.set("theme", this._options.theme), this._state.set("crop.shape", this._options.cropShape), this._state.set("crop.aspect", this._options.initialAspectRatio), this._preset && (this._state.set("lockCropShape", !!this._preset.lockCropShape), this._state.set("lockAspectRatio", !!this._preset.lockAspectRatio), this._state.set("showFilters", this._preset.showFilters !== !1), this._state.set("showCropControls", this._preset.showCropControls !== !1), this._state.set("autoZoomOnCropOverflow", !!this._preset.autoZoomOnCropOverflow)), this._renderer = new xe(), this._filterManager = new we(this._state, this._renderer), this._cropManager = new H(this._state, this._renderer), this._removeBgManager = null, ((a = this._options.backgroundRemoval) == null ? void 0 : a.enabled) !== !1 && (this._removeBgManager = new Se({
|
|
2174
2456
|
endpoint: (o = this._options.backgroundRemoval) == null ? void 0 : o.endpoint,
|
|
2175
2457
|
fallbackEndpoint: (n = this._options.backgroundRemoval) == null ? void 0 : n.fallbackEndpoint
|
|
2176
|
-
})), this._loadingOverlay = null, this._toolbar = null, this._categoryCarousel = null, this._filterCarousel = null, this._filterAdjustments = null, this._cropControls = null, this._activeFiltersPanel = null, this._editorEl = null, this._canvasContainer = null, this._cropOverlay = null, this._controlsSection = null, this._filterControlsEl = null, this._fileInput = null, this._resizeObserver = null, this._init();
|
|
2458
|
+
})), this._loadingOverlay = null, this._isMobile = typeof window < "u" ? window.innerWidth <= 768 : !1, this._toolbar = null, this._categoryCarousel = null, this._filterCarousel = null, this._filterAdjustments = null, this._mobileFilterDrawer = null, this._mobileActiveFilters = null, this._cropControls = null, this._activeFiltersPanel = null, this._editorEl = null, this._canvasContainer = null, this._cropOverlay = null, this._controlsSection = null, this._filterControlsEl = null, this._fileInput = null, this._resizeObserver = null, this._init();
|
|
2177
2459
|
}
|
|
2178
2460
|
/**
|
|
2179
2461
|
* Initialize the editor
|
|
@@ -2182,7 +2464,7 @@ class Zt extends B {
|
|
|
2182
2464
|
this._state.detectTheme(), this._buildDOM(), await this._renderer.mount(
|
|
2183
2465
|
this._canvasContainer,
|
|
2184
2466
|
this._state.get("isDarkMode") ? 657930 : 16777215
|
|
2185
|
-
), this._cropManager.setOverlayCanvas(this._cropOverlay), this._initUI(), this._setupResizeObserver(), this._subscribeToState(), this._options.initialImage && await this.loadImage(this._options.initialImage), this.emit("ready");
|
|
2467
|
+
), this._cropManager.setOverlayCanvas(this._cropOverlay), this._initUI(), this._setupResizeObserver(), this._setupWindowResize(), this._subscribeToState(), this._options.initialImage && await this.loadImage(this._options.initialImage), this.emit("ready");
|
|
2186
2468
|
}
|
|
2187
2469
|
/**
|
|
2188
2470
|
* Build DOM structure
|
|
@@ -2199,31 +2481,45 @@ class Zt extends B {
|
|
|
2199
2481
|
accept: "image/*",
|
|
2200
2482
|
className: "hidden-file-input",
|
|
2201
2483
|
"aria-label": "Choose image file to edit",
|
|
2202
|
-
onChange: (
|
|
2484
|
+
onChange: (r) => this._handleFileSelect(r)
|
|
2203
2485
|
}), this._editorEl.appendChild(this._fileInput), this._container.appendChild(this._editorEl);
|
|
2204
2486
|
}
|
|
2205
2487
|
/**
|
|
2206
2488
|
* Initialize UI components
|
|
2207
2489
|
*/
|
|
2208
2490
|
_initUI() {
|
|
2209
|
-
this._toolbar = new Le(this._state, this), this._toolbarContainer.appendChild(this._toolbar.render()), this._filterControlsEl = u("div", { className: "filter-controls-container" }), this._categoryCarousel = new
|
|
2491
|
+
this._toolbar = new Le(this._state, this), this._toolbarContainer.appendChild(this._toolbar.render()), this._filterControlsEl = u("div", { className: "filter-controls-container" }), this._categoryCarousel = new De(this._state, this), this._filterControlsEl.appendChild(this._categoryCarousel.render((r) => {
|
|
2210
2492
|
}));
|
|
2211
2493
|
const e = u("div", { className: "filter-layout" }), t = u("div", { className: "filter-left-column" });
|
|
2212
|
-
this._filterCarousel = new
|
|
2213
|
-
onToggle: (
|
|
2214
|
-
onSelect: (
|
|
2494
|
+
this._filterCarousel = new Ue(this._state, this._filterManager), t.appendChild(this._filterCarousel.render({
|
|
2495
|
+
onToggle: (r, a) => this._handleFilterToggle(r, a),
|
|
2496
|
+
onSelect: (r) => {
|
|
2497
|
+
this._handleFilterSelect(r), this._isMobile && this._mobileFilterDrawer && this._mobileFilterDrawer.open(r);
|
|
2498
|
+
}
|
|
2215
2499
|
})), this._filterAdjustments = new Ve(this._state, this._filterManager), t.appendChild(this._filterAdjustments.render({
|
|
2216
|
-
onChange: (
|
|
2217
|
-
onReset: (
|
|
2218
|
-
onAction: (
|
|
2500
|
+
onChange: (r, a, o) => this._handleFilterChange(r, a, o),
|
|
2501
|
+
onReset: (r) => this._handleFilterReset(r),
|
|
2502
|
+
onAction: (r, a) => this._handleFilterAction(r, a)
|
|
2219
2503
|
})), e.appendChild(t);
|
|
2220
2504
|
const i = u("div", { className: "filter-right-column" });
|
|
2221
|
-
this._activeFiltersPanel = new
|
|
2222
|
-
onRemove: (
|
|
2223
|
-
onReset: (
|
|
2505
|
+
this._activeFiltersPanel = new Ze(this._state, this._filterManager), i.appendChild(this._activeFiltersPanel.render({
|
|
2506
|
+
onRemove: (r) => this._handleFilterToggle(r, !1),
|
|
2507
|
+
onReset: (r) => this._handleFilterReset(r),
|
|
2224
2508
|
onClearAll: () => this.resetAll(),
|
|
2225
|
-
onSelect: (
|
|
2226
|
-
})), e.appendChild(i), this._filterControlsEl.appendChild(e), this.
|
|
2509
|
+
onSelect: (r) => this._handleFilterSelect(r)
|
|
2510
|
+
})), e.appendChild(i), this._filterControlsEl.appendChild(e), this._mobileActiveFilters = new qe(this._state, this._filterManager), this._filterControlsEl.appendChild(this._mobileActiveFilters.render({
|
|
2511
|
+
onToggle: (r, a) => this._handleFilterToggle(r, a),
|
|
2512
|
+
onSelect: (r) => {
|
|
2513
|
+
this._handleFilterSelect(r), this._isMobile && this._mobileFilterDrawer && this._mobileFilterDrawer.open(r);
|
|
2514
|
+
}
|
|
2515
|
+
})), this._cropControls = new We(this._state, this._cropManager), this._cropControlsEl = this._cropControls.render(), this._cropControlsEl.style.display = "none", this._controlsSection.appendChild(this._filterControlsEl), this._controlsSection.appendChild(this._cropControlsEl), this._mobileFilterDrawer = new je(this._state, this._filterManager), this._mobileFilterDrawer.build(this._controlsSection, {
|
|
2516
|
+
onChange: (r, a, o) => this._handleFilterChange(r, a, o),
|
|
2517
|
+
onReset: (r) => this._handleFilterReset(r),
|
|
2518
|
+
onRemove: (r) => {
|
|
2519
|
+
this._handleFilterToggle(r, !1), this._state.set("selectedFilter", null);
|
|
2520
|
+
},
|
|
2521
|
+
onAction: (r, a) => this._handleFilterAction(r, a)
|
|
2522
|
+
});
|
|
2227
2523
|
}
|
|
2228
2524
|
/**
|
|
2229
2525
|
* Set up resize observer with debounce to prevent infinite loops.
|
|
@@ -2240,12 +2536,21 @@ class Zt extends B {
|
|
|
2240
2536
|
}, 50);
|
|
2241
2537
|
}), this._resizeObserver.observe(this._canvasContainer);
|
|
2242
2538
|
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Set up window resize listener for mobile detection
|
|
2541
|
+
*/
|
|
2542
|
+
_setupWindowResize() {
|
|
2543
|
+
this._handleWindowResize = () => {
|
|
2544
|
+
var e;
|
|
2545
|
+
this._isMobile = window.innerWidth <= 768, !this._isMobile && ((e = this._mobileFilterDrawer) != null && e.isOpen) && this._mobileFilterDrawer.close();
|
|
2546
|
+
}, window.addEventListener("resize", this._handleWindowResize);
|
|
2547
|
+
}
|
|
2243
2548
|
/**
|
|
2244
2549
|
* Subscribe to state changes
|
|
2245
2550
|
*/
|
|
2246
2551
|
_subscribeToState() {
|
|
2247
2552
|
this._state.on("change:mode", ({ value: e }) => {
|
|
2248
|
-
this._updateModeUI(e);
|
|
2553
|
+
this._updateModeUI(e), e === "filters" && this._filterManager.applyFilters();
|
|
2249
2554
|
}), this._state.on("change:isDarkMode", ({ value: e }) => {
|
|
2250
2555
|
this._editorEl.classList.toggle("dark", e), this._editorEl.classList.toggle("light", !e), this._renderer.setBackgroundColor(e ? 657930 : 16777215);
|
|
2251
2556
|
}), this._state.on("change:hasImage", ({ value: e }) => {
|
|
@@ -2259,7 +2564,8 @@ class Zt extends B {
|
|
|
2259
2564
|
* @param {string} mode
|
|
2260
2565
|
*/
|
|
2261
2566
|
_updateModeUI(e) {
|
|
2262
|
-
|
|
2567
|
+
var t;
|
|
2568
|
+
e === "crop" ? (this._filterControlsEl.style.display = "none", this._cropControlsEl.style.display = "", (t = this._mobileFilterDrawer) != null && t.isOpen && this._mobileFilterDrawer.close()) : (this._filterControlsEl.style.display = "", this._cropControlsEl.style.display = "none");
|
|
2263
2569
|
}
|
|
2264
2570
|
/**
|
|
2265
2571
|
* Handle file selection
|
|
@@ -2333,8 +2639,8 @@ class Zt extends B {
|
|
|
2333
2639
|
*/
|
|
2334
2640
|
_fileToDataUrl(e) {
|
|
2335
2641
|
return new Promise((t, i) => {
|
|
2336
|
-
const
|
|
2337
|
-
|
|
2642
|
+
const r = new FileReader();
|
|
2643
|
+
r.onload = () => t(r.result), r.onerror = i, r.readAsDataURL(e);
|
|
2338
2644
|
});
|
|
2339
2645
|
}
|
|
2340
2646
|
/**
|
|
@@ -2363,11 +2669,11 @@ class Zt extends B {
|
|
|
2363
2669
|
try {
|
|
2364
2670
|
const i = this.exportImage("png", 0.92);
|
|
2365
2671
|
if (!i) throw new Error("Failed to export image");
|
|
2366
|
-
const
|
|
2672
|
+
const r = {
|
|
2367
2673
|
width: Math.round(((e = this._renderer.sprite) == null ? void 0 : e.width) || 0),
|
|
2368
2674
|
height: Math.round(((t = this._renderer.sprite) == null ? void 0 : t.height) || 0)
|
|
2369
2675
|
}, a = document.createElement("a");
|
|
2370
|
-
a.href = i, a.download = `edited-image-${Date.now()}.png`, document.body.appendChild(a), a.click(), document.body.removeChild(a), this.emit("save", { imageData: i, dimensions:
|
|
2676
|
+
a.href = i, a.download = `edited-image-${Date.now()}.png`, document.body.appendChild(a), a.click(), document.body.removeChild(a), this.emit("save", { imageData: i, dimensions: r });
|
|
2371
2677
|
} catch (i) {
|
|
2372
2678
|
this.emit("error", { error: i });
|
|
2373
2679
|
} finally {
|
|
@@ -2481,8 +2787,8 @@ class Zt extends B {
|
|
|
2481
2787
|
u("div", { className: "editor-loading-text" }, e)
|
|
2482
2788
|
]);
|
|
2483
2789
|
else {
|
|
2484
|
-
const
|
|
2485
|
-
|
|
2790
|
+
const r = this._loadingOverlay.querySelector(".editor-loading-text");
|
|
2791
|
+
r && (r.textContent = e);
|
|
2486
2792
|
}
|
|
2487
2793
|
const t = (i = this._canvasContainer) == null ? void 0 : i.parentElement;
|
|
2488
2794
|
t && !this._loadingOverlay.parentElement && t.appendChild(this._loadingOverlay);
|
|
@@ -2498,31 +2804,31 @@ class Zt extends B {
|
|
|
2498
2804
|
* Destroy the editor and clean up
|
|
2499
2805
|
*/
|
|
2500
2806
|
destroy() {
|
|
2501
|
-
var e, t, i,
|
|
2502
|
-
(e = this._resizeObserver) == null || e.disconnect(), this._renderer.destroy(), this._cropManager.disable(), (t = this._toolbar) == null || t.destroy(), (i = this._categoryCarousel) == null || i.destroy(), (
|
|
2807
|
+
var e, t, i, r, a, o, n, l, c, d;
|
|
2808
|
+
(e = this._resizeObserver) == null || e.disconnect(), this._renderer.destroy(), this._cropManager.disable(), this._handleWindowResize && window.removeEventListener("resize", this._handleWindowResize), (t = this._toolbar) == null || t.destroy(), (i = this._categoryCarousel) == null || i.destroy(), (r = this._filterCarousel) == null || r.destroy(), (a = this._filterAdjustments) == null || a.destroy(), (o = this._mobileFilterDrawer) == null || o.destroy(), (n = this._mobileActiveFilters) == null || n.destroy(), (l = this._cropControls) == null || l.destroy(), (c = this._activeFiltersPanel) == null || c.destroy(), (d = this._editorEl) == null || d.remove(), this._container = null, this._state = null, this.emit("destroyed"), this.removeAllListeners();
|
|
2503
2809
|
}
|
|
2504
2810
|
}
|
|
2505
|
-
const v = /* @__PURE__ */ new Map(),
|
|
2506
|
-
function
|
|
2507
|
-
return !Array.isArray(
|
|
2811
|
+
const v = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
|
|
2812
|
+
function Ke(s, e) {
|
|
2813
|
+
return !Array.isArray(s.mediaTargets) || s.mediaTargets.length === 0 ? !0 : s.mediaTargets.includes(e);
|
|
2508
2814
|
}
|
|
2509
|
-
function f(
|
|
2815
|
+
function f(s) {
|
|
2510
2816
|
var e;
|
|
2511
|
-
return v.has(
|
|
2817
|
+
return v.has(s.id), v.set(s.id, s), T.has(s.category) || T.set(s.category, []), (e = T.get(s.category)) == null || e.push(s.id), s;
|
|
2512
2818
|
}
|
|
2513
|
-
function
|
|
2514
|
-
return v.get(
|
|
2819
|
+
function Qe(s) {
|
|
2820
|
+
return v.get(s);
|
|
2515
2821
|
}
|
|
2516
|
-
function
|
|
2822
|
+
function D() {
|
|
2517
2823
|
return Array.from(v.values());
|
|
2518
2824
|
}
|
|
2519
|
-
function
|
|
2520
|
-
|
|
2825
|
+
function Je() {
|
|
2826
|
+
D().map((t) => t.id), Object.entries(g).filter(
|
|
2521
2827
|
(t) => /Filter$/.test(t[0]) && typeof t[1] == "function"
|
|
2522
2828
|
).forEach(([t, i]) => {
|
|
2523
|
-
const
|
|
2524
|
-
v.has(
|
|
2525
|
-
id:
|
|
2829
|
+
const r = t.replace(/Filter$/, "").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2830
|
+
v.has(r) || f({
|
|
2831
|
+
id: r,
|
|
2526
2832
|
name: t.replace(/Filter$/, ""),
|
|
2527
2833
|
category: "unlisted",
|
|
2528
2834
|
// Put in a category that won't be shown in UI
|
|
@@ -2540,51 +2846,51 @@ function Ke() {
|
|
|
2540
2846
|
});
|
|
2541
2847
|
});
|
|
2542
2848
|
}
|
|
2543
|
-
function
|
|
2544
|
-
return (
|
|
2849
|
+
function et(s) {
|
|
2850
|
+
return (T.get(s) || []).map((t) => v.get(t)).filter(Boolean);
|
|
2545
2851
|
}
|
|
2546
|
-
function
|
|
2547
|
-
return Array.from(
|
|
2852
|
+
function tt() {
|
|
2853
|
+
return Array.from(T.keys());
|
|
2548
2854
|
}
|
|
2549
|
-
function
|
|
2550
|
-
return v.has(
|
|
2855
|
+
function Kt(s) {
|
|
2856
|
+
return v.has(s);
|
|
2551
2857
|
}
|
|
2552
|
-
function
|
|
2553
|
-
const e = v.get(
|
|
2858
|
+
function it(s) {
|
|
2859
|
+
const e = v.get(s);
|
|
2554
2860
|
if (!e)
|
|
2555
2861
|
return !1;
|
|
2556
|
-
v.delete(
|
|
2557
|
-
const t =
|
|
2862
|
+
v.delete(s);
|
|
2863
|
+
const t = T.get(e.category);
|
|
2558
2864
|
if (t) {
|
|
2559
|
-
const i = t.indexOf(
|
|
2560
|
-
i !== -1 && t.splice(i, 1), t.length === 0 &&
|
|
2865
|
+
const i = t.indexOf(s);
|
|
2866
|
+
i !== -1 && t.splice(i, 1), t.length === 0 && T.delete(e.category);
|
|
2561
2867
|
}
|
|
2562
2868
|
return !0;
|
|
2563
2869
|
}
|
|
2564
|
-
function
|
|
2565
|
-
const t = v.get(
|
|
2566
|
-
return t ?
|
|
2870
|
+
function Qt(s, e) {
|
|
2871
|
+
const t = v.get(s);
|
|
2872
|
+
return t ? Ke(t, e) : !1;
|
|
2567
2873
|
}
|
|
2568
|
-
function
|
|
2569
|
-
return Array.from(v.values()).map((
|
|
2570
|
-
id:
|
|
2571
|
-
name:
|
|
2572
|
-
category:
|
|
2573
|
-
controls:
|
|
2874
|
+
function rt() {
|
|
2875
|
+
return Array.from(v.values()).map((s) => ({
|
|
2876
|
+
id: s.id,
|
|
2877
|
+
name: s.name,
|
|
2878
|
+
category: s.category,
|
|
2879
|
+
controls: s.controls
|
|
2574
2880
|
}));
|
|
2575
2881
|
}
|
|
2576
2882
|
if (typeof window < "u") {
|
|
2577
|
-
window.__DEBUG_FILTERS_LIST = Array.from(v.keys()), window.getAllFilters =
|
|
2578
|
-
const
|
|
2883
|
+
window.__DEBUG_FILTERS_LIST = Array.from(v.keys()), window.getAllFilters = D, window.getFilter = Qe, window.getFiltersByCategory = et, window.getRegisteredFilters = rt;
|
|
2884
|
+
const s = f;
|
|
2579
2885
|
window.registerFilter = (e) => {
|
|
2580
|
-
const t =
|
|
2886
|
+
const t = s(e);
|
|
2581
2887
|
return window.__DEBUG_FILTERS_LIST = Array.from(v.keys()), t;
|
|
2582
2888
|
};
|
|
2583
2889
|
}
|
|
2584
2890
|
typeof window < "u" && (window.initializeFilterRegistry = window.initializeFilterRegistry || function() {
|
|
2585
2891
|
return [];
|
|
2586
2892
|
});
|
|
2587
|
-
const { AdjustmentFilter:
|
|
2893
|
+
const { AdjustmentFilter: st } = g, { ColorMatrixFilter: at } = w, k = {
|
|
2588
2894
|
gamma: 1,
|
|
2589
2895
|
saturation: 1,
|
|
2590
2896
|
contrast: 1,
|
|
@@ -2593,7 +2899,7 @@ const { AdjustmentFilter: it } = g, { ColorMatrixFilter: rt } = C, k = {
|
|
|
2593
2899
|
green: 1,
|
|
2594
2900
|
blue: 1,
|
|
2595
2901
|
alpha: 1
|
|
2596
|
-
},
|
|
2902
|
+
}, ot = /* @__PURE__ */ new Set([
|
|
2597
2903
|
"gamma",
|
|
2598
2904
|
"saturation",
|
|
2599
2905
|
"contrast",
|
|
@@ -2603,33 +2909,33 @@ const { AdjustmentFilter: it } = g, { ColorMatrixFilter: rt } = C, k = {
|
|
|
2603
2909
|
"blue",
|
|
2604
2910
|
"alpha"
|
|
2605
2911
|
]);
|
|
2606
|
-
function P(
|
|
2607
|
-
if (typeof
|
|
2608
|
-
return
|
|
2609
|
-
if (typeof
|
|
2610
|
-
const t = Number(
|
|
2912
|
+
function P(s, e) {
|
|
2913
|
+
if (typeof s == "number" && Number.isFinite(s))
|
|
2914
|
+
return s;
|
|
2915
|
+
if (typeof s == "string") {
|
|
2916
|
+
const t = Number(s);
|
|
2611
2917
|
if (Number.isFinite(t))
|
|
2612
2918
|
return t;
|
|
2613
2919
|
}
|
|
2614
2920
|
return e;
|
|
2615
2921
|
}
|
|
2616
|
-
function
|
|
2617
|
-
return
|
|
2922
|
+
function Q(s) {
|
|
2923
|
+
return ot.has(s);
|
|
2618
2924
|
}
|
|
2619
|
-
function
|
|
2925
|
+
function nt(s) {
|
|
2620
2926
|
return {
|
|
2621
|
-
gamma: P(
|
|
2622
|
-
saturation: P(
|
|
2623
|
-
contrast: P(
|
|
2624
|
-
brightness: P(
|
|
2625
|
-
red: P(
|
|
2626
|
-
green: P(
|
|
2627
|
-
blue: P(
|
|
2628
|
-
alpha: P(
|
|
2927
|
+
gamma: P(s.gamma, k.gamma),
|
|
2928
|
+
saturation: P(s.saturation, k.saturation),
|
|
2929
|
+
contrast: P(s.contrast, k.contrast),
|
|
2930
|
+
brightness: P(s.brightness, k.brightness),
|
|
2931
|
+
red: P(s.red, k.red),
|
|
2932
|
+
green: P(s.green, k.green),
|
|
2933
|
+
blue: P(s.blue, k.blue),
|
|
2934
|
+
alpha: P(s.alpha, k.alpha)
|
|
2629
2935
|
};
|
|
2630
2936
|
}
|
|
2631
|
-
function
|
|
2632
|
-
|
|
2937
|
+
function J(s, e) {
|
|
2938
|
+
s.reset(), s.brightness(e.brightness, !0), s.contrast(e.contrast, !0), s.saturate(e.saturation, !0);
|
|
2633
2939
|
}
|
|
2634
2940
|
f({
|
|
2635
2941
|
id: "adjustment",
|
|
@@ -2637,14 +2943,14 @@ f({
|
|
|
2637
2943
|
category: "adjust",
|
|
2638
2944
|
description: "Adjust basic image properties like brightness, contrast, and saturation",
|
|
2639
2945
|
// Create an instance of the AdjustmentFilter with the provided parameters
|
|
2640
|
-
createFilter: (
|
|
2946
|
+
createFilter: (s) => {
|
|
2641
2947
|
try {
|
|
2642
|
-
const e =
|
|
2948
|
+
const e = nt(s ?? {}), t = { ...e };
|
|
2643
2949
|
try {
|
|
2644
|
-
const i = new
|
|
2645
|
-
return
|
|
2950
|
+
const i = new st(t), r = i;
|
|
2951
|
+
return r._customParams = { ...e }, r.updateUIParam = function(o, n) {
|
|
2646
2952
|
try {
|
|
2647
|
-
if (!
|
|
2953
|
+
if (!Q(o))
|
|
2648
2954
|
return;
|
|
2649
2955
|
const l = this._customParams ?? { ...k }, c = P(n, l[o]);
|
|
2650
2956
|
l[o] = c, this._customParams = l;
|
|
@@ -2654,16 +2960,16 @@ f({
|
|
|
2654
2960
|
}
|
|
2655
2961
|
}, i;
|
|
2656
2962
|
} catch {
|
|
2657
|
-
const
|
|
2658
|
-
return a._customParams = { ...e },
|
|
2963
|
+
const r = new at(), a = r;
|
|
2964
|
+
return a._customParams = { ...e }, J(r, e), a.updateUIParam = function(n, l) {
|
|
2659
2965
|
try {
|
|
2660
|
-
if (!
|
|
2966
|
+
if (!Q(n))
|
|
2661
2967
|
return;
|
|
2662
2968
|
const c = this._customParams ?? { ...k }, d = P(l, c[n]);
|
|
2663
|
-
c[n] = d, this._customParams = c,
|
|
2969
|
+
c[n] = d, this._customParams = c, J(this, c);
|
|
2664
2970
|
} catch {
|
|
2665
2971
|
}
|
|
2666
|
-
},
|
|
2972
|
+
}, r;
|
|
2667
2973
|
}
|
|
2668
2974
|
} catch {
|
|
2669
2975
|
return null;
|
|
@@ -2764,14 +3070,14 @@ f({
|
|
|
2764
3070
|
}
|
|
2765
3071
|
]
|
|
2766
3072
|
});
|
|
2767
|
-
const { ColorMatrixFilter:
|
|
3073
|
+
const { ColorMatrixFilter: lt } = w, N = {
|
|
2768
3074
|
brightness: 1,
|
|
2769
3075
|
contrast: 1,
|
|
2770
3076
|
saturation: 1,
|
|
2771
3077
|
hue: 0,
|
|
2772
3078
|
sepia: 0,
|
|
2773
3079
|
negative: !1
|
|
2774
|
-
},
|
|
3080
|
+
}, ct = /* @__PURE__ */ new Set([
|
|
2775
3081
|
"brightness",
|
|
2776
3082
|
"contrast",
|
|
2777
3083
|
"saturation",
|
|
@@ -2779,42 +3085,42 @@ const { ColorMatrixFilter: ot } = C, z = {
|
|
|
2779
3085
|
"sepia",
|
|
2780
3086
|
"negative"
|
|
2781
3087
|
]);
|
|
2782
|
-
function
|
|
2783
|
-
return
|
|
3088
|
+
function ht(s) {
|
|
3089
|
+
return ct.has(s);
|
|
2784
3090
|
}
|
|
2785
|
-
function X(
|
|
2786
|
-
if (typeof
|
|
2787
|
-
return
|
|
2788
|
-
if (typeof
|
|
2789
|
-
const t = Number(
|
|
3091
|
+
function X(s, e) {
|
|
3092
|
+
if (typeof s == "number" && Number.isFinite(s))
|
|
3093
|
+
return s;
|
|
3094
|
+
if (typeof s == "string") {
|
|
3095
|
+
const t = Number(s);
|
|
2790
3096
|
if (Number.isFinite(t))
|
|
2791
3097
|
return t;
|
|
2792
3098
|
}
|
|
2793
3099
|
return e;
|
|
2794
3100
|
}
|
|
2795
|
-
function
|
|
2796
|
-
if (typeof
|
|
2797
|
-
return
|
|
2798
|
-
if (typeof
|
|
2799
|
-
if (
|
|
3101
|
+
function ue(s, e) {
|
|
3102
|
+
if (typeof s == "boolean")
|
|
3103
|
+
return s;
|
|
3104
|
+
if (typeof s == "string") {
|
|
3105
|
+
if (s === "true")
|
|
2800
3106
|
return !0;
|
|
2801
|
-
if (
|
|
3107
|
+
if (s === "false")
|
|
2802
3108
|
return !1;
|
|
2803
3109
|
}
|
|
2804
3110
|
return e;
|
|
2805
3111
|
}
|
|
2806
|
-
function
|
|
3112
|
+
function dt(s) {
|
|
2807
3113
|
return {
|
|
2808
|
-
brightness: X(
|
|
2809
|
-
contrast: X(
|
|
2810
|
-
saturation: X(
|
|
2811
|
-
hue: X(
|
|
2812
|
-
sepia: X(
|
|
2813
|
-
negative:
|
|
3114
|
+
brightness: X(s.brightness, N.brightness),
|
|
3115
|
+
contrast: X(s.contrast, N.contrast),
|
|
3116
|
+
saturation: X(s.saturation, N.saturation),
|
|
3117
|
+
hue: X(s.hue, N.hue),
|
|
3118
|
+
sepia: X(s.sepia, N.sepia),
|
|
3119
|
+
negative: ue(s.negative, N.negative)
|
|
2814
3120
|
};
|
|
2815
3121
|
}
|
|
2816
|
-
function
|
|
2817
|
-
|
|
3122
|
+
function ee(s, e) {
|
|
3123
|
+
s.reset(), e.brightness !== 1 && s.brightness(e.brightness, !0), e.contrast !== 1 && s.contrast(e.contrast, !0), e.saturation !== 1 && s.saturate(e.saturation, !0), e.hue !== 0 && s.hue(e.hue, !0), e.sepia > 0 && s.sepia(!0), e.negative && s.negative(!0);
|
|
2818
3124
|
}
|
|
2819
3125
|
f({
|
|
2820
3126
|
id: "adjustment-advanced",
|
|
@@ -2822,21 +3128,21 @@ f({
|
|
|
2822
3128
|
category: "adjust",
|
|
2823
3129
|
description: "Comprehensive image adjustments including brightness, contrast, saturation, hue, and more",
|
|
2824
3130
|
// Create an instance of the ColorMatrixFilter with the provided parameters
|
|
2825
|
-
createFilter: (
|
|
3131
|
+
createFilter: (s) => {
|
|
2826
3132
|
try {
|
|
2827
|
-
const e =
|
|
2828
|
-
return i._customParams = { ...e },
|
|
3133
|
+
const e = dt(s ?? {}), t = new lt(), i = t;
|
|
3134
|
+
return i._customParams = { ...e }, ee(t, e), i.updateUIParam = function(a, o) {
|
|
2829
3135
|
try {
|
|
2830
|
-
if (!
|
|
3136
|
+
if (!ht(a))
|
|
2831
3137
|
return;
|
|
2832
|
-
const n = this._customParams ?? { ...
|
|
3138
|
+
const n = this._customParams ?? { ...N };
|
|
2833
3139
|
if (a === "negative")
|
|
2834
|
-
n.negative =
|
|
3140
|
+
n.negative = ue(o, n.negative);
|
|
2835
3141
|
else {
|
|
2836
3142
|
const l = a;
|
|
2837
3143
|
n[l] = X(o, n[l]);
|
|
2838
3144
|
}
|
|
2839
|
-
this._customParams = n,
|
|
3145
|
+
this._customParams = n, ee(this, n);
|
|
2840
3146
|
} catch {
|
|
2841
3147
|
}
|
|
2842
3148
|
}, t;
|
|
@@ -2920,19 +3226,19 @@ f({
|
|
|
2920
3226
|
category: "adjust",
|
|
2921
3227
|
description: "Adjust the transparency of the image",
|
|
2922
3228
|
// Create an instance of the ColorMatrixFilter with alpha adjustment
|
|
2923
|
-
createFilter: (
|
|
3229
|
+
createFilter: (s) => {
|
|
2924
3230
|
try {
|
|
2925
|
-
const e =
|
|
3231
|
+
const e = s.alpha !== void 0 ? s.alpha : 1, t = new w.ColorMatrixFilter();
|
|
2926
3232
|
return t.alpha = e, t._customParams = {
|
|
2927
3233
|
alpha: e
|
|
2928
|
-
}, t.updateUIParam = function(i,
|
|
3234
|
+
}, t.updateUIParam = function(i, r) {
|
|
2929
3235
|
try {
|
|
2930
3236
|
const a = this._customParams || {};
|
|
2931
3237
|
if (this._customParams = a, i === "alpha") {
|
|
2932
|
-
const o = Number(
|
|
3238
|
+
const o = Number(r);
|
|
2933
3239
|
this.alpha = o, a.alpha = o;
|
|
2934
3240
|
} else
|
|
2935
|
-
i in this && (this[i] =
|
|
3241
|
+
i in this && (this[i] = r);
|
|
2936
3242
|
} catch {
|
|
2937
3243
|
}
|
|
2938
3244
|
}, t;
|
|
@@ -2967,15 +3273,15 @@ f({
|
|
|
2967
3273
|
* Create an instance of the BlurFilter from pixi.js package
|
|
2968
3274
|
* This implementation matches the PixiJS example exactly, using 'blur' and 'quality' parameters
|
|
2969
3275
|
*/
|
|
2970
|
-
createFilter: (
|
|
3276
|
+
createFilter: (s) => {
|
|
2971
3277
|
try {
|
|
2972
|
-
const e = new
|
|
2973
|
-
strength:
|
|
2974
|
-
quality:
|
|
3278
|
+
const e = new w.BlurFilter({
|
|
3279
|
+
strength: s.blur || 8,
|
|
3280
|
+
quality: s.quality || 4
|
|
2975
3281
|
});
|
|
2976
|
-
return e._customParams = { ...
|
|
2977
|
-
const
|
|
2978
|
-
switch (this._customParams =
|
|
3282
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
3283
|
+
const r = this._customParams || {};
|
|
3284
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
2979
3285
|
case "blur":
|
|
2980
3286
|
this.strength = i;
|
|
2981
3287
|
break;
|
|
@@ -3027,13 +3333,13 @@ f({
|
|
|
3027
3333
|
category: "advanced",
|
|
3028
3334
|
description: "Advanced color adjustments including sepia, hue rotation, and more",
|
|
3029
3335
|
// Create an instance of the ColorMatrixFilter with the provided parameters
|
|
3030
|
-
createFilter: (
|
|
3031
|
-
const e =
|
|
3336
|
+
createFilter: (s) => {
|
|
3337
|
+
const e = w.ColorMatrixFilter;
|
|
3032
3338
|
if (!e)
|
|
3033
3339
|
return null;
|
|
3034
3340
|
const t = new e();
|
|
3035
3341
|
try {
|
|
3036
|
-
return typeof t.reset == "function" && t.reset(),
|
|
3342
|
+
return typeof t.reset == "function" && t.reset(), s.brightness !== 1 && typeof t.brightness == "function" && t.brightness(s.brightness, !1), s.contrast !== 1 && typeof t.contrast == "function" && t.contrast(s.contrast, !1), s.saturation !== 1 && typeof t.saturate == "function" && t.saturate(s.saturation, !1), s.hue !== 0 && typeof t.hue == "function" && t.hue(s.hue, !1), s.sepia > 0 && typeof t.sepia == "function" && t.sepia(s.sepia), s.negative && typeof t.negative == "function" && t.negative(!1), t;
|
|
3037
3343
|
} catch {
|
|
3038
3344
|
return t;
|
|
3039
3345
|
}
|
|
@@ -3108,7 +3414,7 @@ f({
|
|
|
3108
3414
|
}
|
|
3109
3415
|
]
|
|
3110
3416
|
});
|
|
3111
|
-
const { ColorOverlayFilter:
|
|
3417
|
+
const { ColorOverlayFilter: ut } = g;
|
|
3112
3418
|
f({
|
|
3113
3419
|
id: "colorOverlay",
|
|
3114
3420
|
name: "Color Overlay",
|
|
@@ -3119,26 +3425,26 @@ f({
|
|
|
3119
3425
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
3120
3426
|
* proper parameter handling with an updateUIParam method
|
|
3121
3427
|
*/
|
|
3122
|
-
createFilter: (
|
|
3428
|
+
createFilter: (s) => {
|
|
3123
3429
|
try {
|
|
3124
3430
|
let e = 16711680;
|
|
3125
|
-
|
|
3126
|
-
const t = new
|
|
3431
|
+
s.color && (typeof s.color == "string" ? e = parseInt(s.color.replace("#", "0x"), 16) : typeof s.color == "number" && (e = s.color));
|
|
3432
|
+
const t = new ut({
|
|
3127
3433
|
color: e,
|
|
3128
|
-
alpha:
|
|
3434
|
+
alpha: s.alpha || 0.5
|
|
3129
3435
|
});
|
|
3130
|
-
return t._customParams = { ...
|
|
3436
|
+
return t._customParams = { ...s }, t.updateUIParam = function(i, r) {
|
|
3131
3437
|
const a = this._customParams || {};
|
|
3132
|
-
switch (this._customParams = a, a[i] =
|
|
3438
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
3133
3439
|
case "color":
|
|
3134
3440
|
let o;
|
|
3135
|
-
typeof
|
|
3441
|
+
typeof r == "string" ? o = parseInt(r.replace("#", "0x"), 16) : o = Number(r), this.color = o, this.uniforms && (this.uniforms.uColor = o);
|
|
3136
3442
|
break;
|
|
3137
3443
|
case "alpha":
|
|
3138
|
-
this.alpha = Number(
|
|
3444
|
+
this.alpha = Number(r), this.uniforms && (this.uniforms.uAlpha = Number(r));
|
|
3139
3445
|
break;
|
|
3140
3446
|
default:
|
|
3141
|
-
i in this && (this[i] =
|
|
3447
|
+
i in this && (this[i] = r);
|
|
3142
3448
|
break;
|
|
3143
3449
|
}
|
|
3144
3450
|
return !0;
|
|
@@ -3182,27 +3488,27 @@ f({
|
|
|
3182
3488
|
* Create an instance of the DropShadowFilter with the provided parameters
|
|
3183
3489
|
* Using the official pixi-filters implementation
|
|
3184
3490
|
*/
|
|
3185
|
-
createFilter: (
|
|
3491
|
+
createFilter: (s) => {
|
|
3186
3492
|
try {
|
|
3187
|
-
const e =
|
|
3493
|
+
const e = s.color ? s.color.replace("#", "0x") : "0x000000", t = s.distance !== void 0 ? s.distance : 5, i = s.angle !== void 0 ? s.angle : 90, r = {
|
|
3188
3494
|
x: t * Math.cos(i * Math.PI / 180),
|
|
3189
3495
|
y: t * Math.sin(i * Math.PI / 180)
|
|
3190
3496
|
}, a = new g.DropShadowFilter({
|
|
3191
|
-
offset:
|
|
3497
|
+
offset: r,
|
|
3192
3498
|
color: parseInt(e, 16),
|
|
3193
|
-
alpha:
|
|
3194
|
-
blur:
|
|
3195
|
-
quality:
|
|
3196
|
-
shadowOnly:
|
|
3499
|
+
alpha: s.alpha !== void 0 ? s.alpha : 0.5,
|
|
3500
|
+
blur: s.blur !== void 0 ? s.blur : 2,
|
|
3501
|
+
quality: s.quality !== void 0 ? s.quality : 3,
|
|
3502
|
+
shadowOnly: s.shadowOnly !== void 0 ? s.shadowOnly : !1,
|
|
3197
3503
|
pixelSize: {
|
|
3198
|
-
x:
|
|
3199
|
-
y:
|
|
3504
|
+
x: s.pixelSizeX !== void 0 ? s.pixelSizeX : 1,
|
|
3505
|
+
y: s.pixelSizeY !== void 0 ? s.pixelSizeY : 1
|
|
3200
3506
|
}
|
|
3201
3507
|
});
|
|
3202
3508
|
return a._customParams = {
|
|
3203
|
-
...
|
|
3509
|
+
...s,
|
|
3204
3510
|
// Also store the calculated offset for use in updateUIParam
|
|
3205
|
-
_offset:
|
|
3511
|
+
_offset: r,
|
|
3206
3512
|
_distance: t,
|
|
3207
3513
|
_angle: i
|
|
3208
3514
|
}, a.updateUIParam = function(o, n) {
|
|
@@ -3355,7 +3661,7 @@ f({
|
|
|
3355
3661
|
}
|
|
3356
3662
|
]
|
|
3357
3663
|
});
|
|
3358
|
-
const { ColorMatrixFilter:
|
|
3664
|
+
const { ColorMatrixFilter: pt } = w;
|
|
3359
3665
|
f({
|
|
3360
3666
|
id: "grayscale",
|
|
3361
3667
|
name: "Grayscale",
|
|
@@ -3366,19 +3672,19 @@ f({
|
|
|
3366
3672
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
3367
3673
|
* proper parameter handling with an updateUIParam method
|
|
3368
3674
|
*/
|
|
3369
|
-
createFilter: (
|
|
3675
|
+
createFilter: (s) => {
|
|
3370
3676
|
try {
|
|
3371
|
-
const e = new
|
|
3372
|
-
e._customParams = { ...
|
|
3373
|
-
const t =
|
|
3374
|
-
return
|
|
3677
|
+
const e = new pt();
|
|
3678
|
+
e._customParams = { ...s };
|
|
3679
|
+
const t = s.intensity !== void 0 ? s.intensity : 1;
|
|
3680
|
+
return te(e, t), e.updateUIParam = function(i, r) {
|
|
3375
3681
|
const a = this._customParams || {};
|
|
3376
|
-
switch (this._customParams = a, a[i] =
|
|
3682
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
3377
3683
|
case "intensity":
|
|
3378
|
-
|
|
3684
|
+
te(this, r);
|
|
3379
3685
|
break;
|
|
3380
3686
|
default:
|
|
3381
|
-
i in this && (this[i] =
|
|
3687
|
+
i in this && (this[i] = r);
|
|
3382
3688
|
break;
|
|
3383
3689
|
}
|
|
3384
3690
|
return !0;
|
|
@@ -3405,10 +3711,10 @@ f({
|
|
|
3405
3711
|
}
|
|
3406
3712
|
]
|
|
3407
3713
|
});
|
|
3408
|
-
function
|
|
3409
|
-
|
|
3714
|
+
function te(s, e) {
|
|
3715
|
+
s.reset(), s.greyscale(e);
|
|
3410
3716
|
}
|
|
3411
|
-
const { HslAdjustmentFilter:
|
|
3717
|
+
const { HslAdjustmentFilter: ft } = g;
|
|
3412
3718
|
f({
|
|
3413
3719
|
id: "hsl-adjustment",
|
|
3414
3720
|
name: "HSL Adjustment",
|
|
@@ -3418,19 +3724,19 @@ f({
|
|
|
3418
3724
|
* Create an instance of the HslAdjustmentFilter with the provided parameters
|
|
3419
3725
|
* Using the official pixi-filters implementation instead of a custom one
|
|
3420
3726
|
*/
|
|
3421
|
-
createFilter: (
|
|
3727
|
+
createFilter: (s) => {
|
|
3422
3728
|
try {
|
|
3423
|
-
const e = new
|
|
3424
|
-
hue:
|
|
3425
|
-
saturation:
|
|
3426
|
-
lightness:
|
|
3427
|
-
colorize:
|
|
3428
|
-
alpha:
|
|
3729
|
+
const e = new ft({
|
|
3730
|
+
hue: s.hue !== void 0 ? s.hue : 0,
|
|
3731
|
+
saturation: s.saturation !== void 0 ? s.saturation : 0,
|
|
3732
|
+
lightness: s.lightness !== void 0 ? s.lightness : 0,
|
|
3733
|
+
colorize: s.colorize !== void 0 ? s.colorize : !1,
|
|
3734
|
+
alpha: s.alpha !== void 0 ? s.alpha : 1
|
|
3429
3735
|
});
|
|
3430
|
-
return e._customParams = { ...
|
|
3736
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
3431
3737
|
try {
|
|
3432
|
-
const
|
|
3433
|
-
switch (this._customParams =
|
|
3738
|
+
const r = this._customParams || {};
|
|
3739
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
3434
3740
|
case "hue":
|
|
3435
3741
|
this.hue = Number(i), this.uniforms && (this.uniforms.uHue = Number(i));
|
|
3436
3742
|
break;
|
|
@@ -3518,7 +3824,7 @@ f({
|
|
|
3518
3824
|
}
|
|
3519
3825
|
]
|
|
3520
3826
|
});
|
|
3521
|
-
const { KawaseBlurFilter:
|
|
3827
|
+
const { KawaseBlurFilter: mt } = g;
|
|
3522
3828
|
f({
|
|
3523
3829
|
id: "kawase-blur",
|
|
3524
3830
|
name: "Kawase Blur",
|
|
@@ -3529,17 +3835,17 @@ f({
|
|
|
3529
3835
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
3530
3836
|
* proper parameter handling with an updateUIParam method
|
|
3531
3837
|
*/
|
|
3532
|
-
createFilter: (
|
|
3838
|
+
createFilter: (s) => {
|
|
3533
3839
|
try {
|
|
3534
|
-
const e = new
|
|
3535
|
-
strength:
|
|
3536
|
-
quality:
|
|
3537
|
-
clamp:
|
|
3538
|
-
pixelSize:
|
|
3840
|
+
const e = new mt({
|
|
3841
|
+
strength: s.strength || 4,
|
|
3842
|
+
quality: s.quality || 3,
|
|
3843
|
+
clamp: s.clamp || !1,
|
|
3844
|
+
pixelSize: s.pixelSize || 1
|
|
3539
3845
|
});
|
|
3540
|
-
return e._customParams = { ...
|
|
3541
|
-
const
|
|
3542
|
-
switch (this._customParams =
|
|
3846
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
3847
|
+
const r = this._customParams || {};
|
|
3848
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
3543
3849
|
case "strength":
|
|
3544
3850
|
this.strength = i;
|
|
3545
3851
|
break;
|
|
@@ -3636,7 +3942,7 @@ f({
|
|
|
3636
3942
|
}
|
|
3637
3943
|
]
|
|
3638
3944
|
});
|
|
3639
|
-
const { MotionBlurFilter:
|
|
3945
|
+
const { MotionBlurFilter: gt } = g;
|
|
3640
3946
|
f({
|
|
3641
3947
|
id: "motion-blur",
|
|
3642
3948
|
name: "Motion Blur",
|
|
@@ -3647,19 +3953,19 @@ f({
|
|
|
3647
3953
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
3648
3954
|
* proper parameter handling with an updateUIParam method
|
|
3649
3955
|
*/
|
|
3650
|
-
createFilter: (
|
|
3956
|
+
createFilter: (s) => {
|
|
3651
3957
|
try {
|
|
3652
|
-
const e = new
|
|
3958
|
+
const e = new gt({
|
|
3653
3959
|
velocity: {
|
|
3654
|
-
x:
|
|
3655
|
-
y:
|
|
3960
|
+
x: s.velocityX !== void 0 ? s.velocityX : 0,
|
|
3961
|
+
y: s.velocityY !== void 0 ? s.velocityY : 0
|
|
3656
3962
|
},
|
|
3657
|
-
kernelSize:
|
|
3658
|
-
offset:
|
|
3963
|
+
kernelSize: s.kernelSize || 5,
|
|
3964
|
+
offset: s.offset !== void 0 ? s.offset : 0
|
|
3659
3965
|
});
|
|
3660
|
-
return e._customParams = { ...
|
|
3661
|
-
const
|
|
3662
|
-
switch (this._customParams =
|
|
3966
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
3967
|
+
const r = this._customParams || {};
|
|
3968
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
3663
3969
|
case "velocityX":
|
|
3664
3970
|
this.velocityX = i;
|
|
3665
3971
|
break;
|
|
@@ -3744,24 +4050,24 @@ f({
|
|
|
3744
4050
|
}
|
|
3745
4051
|
]
|
|
3746
4052
|
});
|
|
3747
|
-
const { RadialBlurFilter:
|
|
4053
|
+
const { RadialBlurFilter: bt } = g;
|
|
3748
4054
|
f({
|
|
3749
4055
|
id: "radial-blur",
|
|
3750
4056
|
name: "Radial Blur",
|
|
3751
4057
|
category: "blur",
|
|
3752
4058
|
description: "Creates a circular blur effect emanating from a center point",
|
|
3753
4059
|
// Create an instance of the RadialBlurFilter with the provided parameters
|
|
3754
|
-
createFilter: (
|
|
4060
|
+
createFilter: (s) => {
|
|
3755
4061
|
try {
|
|
3756
|
-
const e = new
|
|
3757
|
-
angle:
|
|
3758
|
-
center: { x:
|
|
3759
|
-
kernelSize:
|
|
3760
|
-
radius:
|
|
4062
|
+
const e = new bt({
|
|
4063
|
+
angle: s.angle ?? 20,
|
|
4064
|
+
center: { x: s.centerX ?? 0, y: s.centerY ?? 0 },
|
|
4065
|
+
kernelSize: s.kernelSize ?? 15,
|
|
4066
|
+
radius: s.radius ?? 300
|
|
3761
4067
|
});
|
|
3762
4068
|
return e._customParams = {
|
|
3763
|
-
centerX:
|
|
3764
|
-
centerY:
|
|
4069
|
+
centerX: s.centerX ?? 0,
|
|
4070
|
+
centerY: s.centerY ?? 0
|
|
3765
4071
|
}, e.updateUIParam = function(t, i) {
|
|
3766
4072
|
try {
|
|
3767
4073
|
switch (t) {
|
|
@@ -3868,26 +4174,26 @@ f({
|
|
|
3868
4174
|
}
|
|
3869
4175
|
]
|
|
3870
4176
|
});
|
|
3871
|
-
const { TiltShiftFilter:
|
|
4177
|
+
const { TiltShiftFilter: yt } = g;
|
|
3872
4178
|
f({
|
|
3873
4179
|
id: "tilt-shift",
|
|
3874
4180
|
name: "Tilt Shift",
|
|
3875
4181
|
category: "blur",
|
|
3876
4182
|
description: "Creates a depth-of-field effect simulating miniature photography",
|
|
3877
4183
|
// Create an instance of the TiltShiftFilter with the provided parameters
|
|
3878
|
-
createFilter: (
|
|
4184
|
+
createFilter: (s) => {
|
|
3879
4185
|
try {
|
|
3880
|
-
const e = typeof
|
|
4186
|
+
const e = typeof s.blur == "number" ? s.blur : 100, t = typeof s.gradientBlur == "number" ? s.gradientBlur : 600, i = typeof s.startX == "number" ? s.startX : 0, r = typeof s.startY == "number" ? s.startY : 0.5, a = typeof s.endX == "number" ? s.endX : 1, o = typeof s.endY == "number" ? s.endY : 0.5, n = new yt({
|
|
3881
4187
|
blur: Number(e),
|
|
3882
4188
|
gradientBlur: Number(t),
|
|
3883
|
-
start: { x: Number(i), y: Number(
|
|
4189
|
+
start: { x: Number(i), y: Number(r) },
|
|
3884
4190
|
end: { x: Number(a), y: Number(o) }
|
|
3885
4191
|
});
|
|
3886
4192
|
return n._customParams = {
|
|
3887
4193
|
blur: e,
|
|
3888
4194
|
gradientBlur: t,
|
|
3889
4195
|
startX: i,
|
|
3890
|
-
startY:
|
|
4196
|
+
startY: r,
|
|
3891
4197
|
endX: a,
|
|
3892
4198
|
endY: o
|
|
3893
4199
|
}, n.updateUIParam = function(l, c) {
|
|
@@ -3996,7 +4302,7 @@ f({
|
|
|
3996
4302
|
}
|
|
3997
4303
|
]
|
|
3998
4304
|
});
|
|
3999
|
-
const { ZoomBlurFilter:
|
|
4305
|
+
const { ZoomBlurFilter: _t } = g;
|
|
4000
4306
|
f({
|
|
4001
4307
|
id: "zoom-blur",
|
|
4002
4308
|
name: "Zoom Blur",
|
|
@@ -4007,21 +4313,21 @@ f({
|
|
|
4007
4313
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
4008
4314
|
* proper parameter handling with an updateUIParam method
|
|
4009
4315
|
*/
|
|
4010
|
-
createFilter: (
|
|
4316
|
+
createFilter: (s) => {
|
|
4011
4317
|
try {
|
|
4012
|
-
const e = new
|
|
4013
|
-
strength:
|
|
4318
|
+
const e = new _t({
|
|
4319
|
+
strength: s.strength || 0.1,
|
|
4014
4320
|
center: {
|
|
4015
|
-
x:
|
|
4016
|
-
y:
|
|
4321
|
+
x: s.centerX !== void 0 ? s.centerX : 0.5,
|
|
4322
|
+
y: s.centerY !== void 0 ? s.centerY : 0.5
|
|
4017
4323
|
},
|
|
4018
|
-
innerRadius:
|
|
4019
|
-
radius:
|
|
4020
|
-
maxKernelSize:
|
|
4324
|
+
innerRadius: s.innerRadius || 80,
|
|
4325
|
+
radius: s.radius !== void 0 ? s.radius : -1,
|
|
4326
|
+
maxKernelSize: s.maxKernelSize || 32
|
|
4021
4327
|
});
|
|
4022
|
-
return e._customParams = { ...
|
|
4023
|
-
const
|
|
4024
|
-
switch (this._customParams =
|
|
4328
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
4329
|
+
const r = this._customParams || {};
|
|
4330
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
4025
4331
|
case "strength":
|
|
4026
4332
|
this.strength = i;
|
|
4027
4333
|
break;
|
|
@@ -4123,7 +4429,7 @@ f({
|
|
|
4123
4429
|
}
|
|
4124
4430
|
]
|
|
4125
4431
|
});
|
|
4126
|
-
const { ColorGradientFilter:
|
|
4432
|
+
const { ColorGradientFilter: ie } = g;
|
|
4127
4433
|
f({
|
|
4128
4434
|
id: "color-gradient",
|
|
4129
4435
|
name: "Color Gradient",
|
|
@@ -4133,10 +4439,10 @@ f({
|
|
|
4133
4439
|
* Create an instance of the ColorGradientFilter with the provided parameters
|
|
4134
4440
|
* This implementation supports unlimited color stops like the PixiJS example app
|
|
4135
4441
|
*/
|
|
4136
|
-
createFilter: (
|
|
4442
|
+
createFilter: (s) => {
|
|
4137
4443
|
try {
|
|
4138
4444
|
let e = [];
|
|
4139
|
-
e = (
|
|
4445
|
+
e = (s.colorStops || [
|
|
4140
4446
|
{ offset: 0, color: "#ff0000", alpha: 1 },
|
|
4141
4447
|
{ offset: 1, color: "#0000ff", alpha: 1 }
|
|
4142
4448
|
]).map((i) => ({
|
|
@@ -4146,32 +4452,32 @@ f({
|
|
|
4146
4452
|
})), e.length < 2 && (e = [
|
|
4147
4453
|
{ offset: 0, color: 16711680, alpha: 1 },
|
|
4148
4454
|
{ offset: 1, color: 255, alpha: 1 }
|
|
4149
|
-
]), e.sort((i,
|
|
4150
|
-
const t = new
|
|
4151
|
-
type:
|
|
4455
|
+
]), e.sort((i, r) => i.offset - r.offset);
|
|
4456
|
+
const t = new ie({
|
|
4457
|
+
type: s.gradientType,
|
|
4152
4458
|
// 0: linear, 1: radial, 2: conic
|
|
4153
4459
|
stops: e,
|
|
4154
|
-
angle:
|
|
4155
|
-
alpha:
|
|
4156
|
-
maxColors:
|
|
4157
|
-
replace:
|
|
4460
|
+
angle: s.angle,
|
|
4461
|
+
alpha: s.alpha,
|
|
4462
|
+
maxColors: s.maxColors || 0,
|
|
4463
|
+
replace: s.replace
|
|
4158
4464
|
});
|
|
4159
|
-
return t._customParams = { ...
|
|
4160
|
-
return !this.stops || !Array.isArray(this.stops) ? [] : this.stops.map((
|
|
4161
|
-
offset:
|
|
4162
|
-
color: typeof
|
|
4163
|
-
alpha:
|
|
4465
|
+
return t._customParams = { ...s }, t.getColorStopsForUI = function() {
|
|
4466
|
+
return !this.stops || !Array.isArray(this.stops) ? [] : this.stops.map((r) => ({
|
|
4467
|
+
offset: r.offset,
|
|
4468
|
+
color: typeof r.color == "number" ? "#" + r.color.toString(16).padStart(6, "0") : r.color,
|
|
4469
|
+
alpha: r.alpha
|
|
4164
4470
|
}));
|
|
4165
4471
|
}, t.getDynamicControls = function() {
|
|
4166
|
-
const i = this.getColorStopsForUI(),
|
|
4472
|
+
const i = this.getColorStopsForUI(), r = [];
|
|
4167
4473
|
return i.forEach((a, o) => {
|
|
4168
|
-
|
|
4474
|
+
r.push({
|
|
4169
4475
|
id: `colorStop-${o}-color`,
|
|
4170
4476
|
type: "color",
|
|
4171
4477
|
label: `Stop ${o + 1} Color`,
|
|
4172
4478
|
property: `colorStops[${o}].color`,
|
|
4173
4479
|
default: a.color
|
|
4174
|
-
}),
|
|
4480
|
+
}), r.push({
|
|
4175
4481
|
id: `colorStop-${o}-offset`,
|
|
4176
4482
|
type: "slider",
|
|
4177
4483
|
label: `Stop ${o + 1} Position`,
|
|
@@ -4180,7 +4486,7 @@ f({
|
|
|
4180
4486
|
max: 1,
|
|
4181
4487
|
step: 0.01,
|
|
4182
4488
|
default: a.offset
|
|
4183
|
-
}),
|
|
4489
|
+
}), r.push({
|
|
4184
4490
|
id: `colorStop-${o}-alpha`,
|
|
4185
4491
|
type: "slider",
|
|
4186
4492
|
label: `Stop ${o + 1} Alpha`,
|
|
@@ -4190,20 +4496,20 @@ f({
|
|
|
4190
4496
|
step: 0.01,
|
|
4191
4497
|
default: a.alpha
|
|
4192
4498
|
});
|
|
4193
|
-
}),
|
|
4499
|
+
}), r;
|
|
4194
4500
|
}, t.handleButtonAction = function(i) {
|
|
4195
4501
|
(i === "addColorStop" || i === "removeColorStop") && this.updateUIParam(i, !0);
|
|
4196
|
-
}, t.updateUIParam = function(i,
|
|
4502
|
+
}, t.updateUIParam = function(i, r) {
|
|
4197
4503
|
const a = this._customParams || {};
|
|
4198
|
-
switch (this._customParams = a, a[i] =
|
|
4504
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
4199
4505
|
case "gradientType":
|
|
4200
|
-
this.type =
|
|
4506
|
+
this.type = r;
|
|
4201
4507
|
break;
|
|
4202
4508
|
case "angle":
|
|
4203
4509
|
case "alpha":
|
|
4204
4510
|
case "maxColors":
|
|
4205
4511
|
case "replace":
|
|
4206
|
-
i in this && (this[i] =
|
|
4512
|
+
i in this && (this[i] = r);
|
|
4207
4513
|
break;
|
|
4208
4514
|
case "addColorStop":
|
|
4209
4515
|
const o = [...this.stops], c = {
|
|
@@ -4235,9 +4541,9 @@ f({
|
|
|
4235
4541
|
})));
|
|
4236
4542
|
break;
|
|
4237
4543
|
case "cssGradient":
|
|
4238
|
-
if (
|
|
4544
|
+
if (r && typeof r == "string" && r.trim() !== "")
|
|
4239
4545
|
try {
|
|
4240
|
-
const h = new
|
|
4546
|
+
const h = new ie({ css: r });
|
|
4241
4547
|
this.type = h.type, this.angle = h.angle, this.stops = [...h.stops], a.colorStops = this.stops.map((p) => ({
|
|
4242
4548
|
offset: p.offset,
|
|
4243
4549
|
color: typeof p.color == "number" ? "#" + p.color.toString(16).padStart(6, "0") : p.color,
|
|
@@ -4247,8 +4553,8 @@ f({
|
|
|
4247
4553
|
}
|
|
4248
4554
|
break;
|
|
4249
4555
|
case "colorStops":
|
|
4250
|
-
if (Array.isArray(
|
|
4251
|
-
const h =
|
|
4556
|
+
if (Array.isArray(r)) {
|
|
4557
|
+
const h = r.map((p) => ({
|
|
4252
4558
|
offset: p.offset,
|
|
4253
4559
|
color: typeof p.color == "string" ? parseInt(p.color.replace("#", "0x")) : p.color,
|
|
4254
4560
|
alpha: p.alpha
|
|
@@ -4262,9 +4568,9 @@ f({
|
|
|
4262
4568
|
if (h) {
|
|
4263
4569
|
const [p, m, S] = h, b = parseInt(m), _ = [...this.stops];
|
|
4264
4570
|
if (b >= 0 && b < _.length)
|
|
4265
|
-
return S === "color" && typeof
|
|
4571
|
+
return S === "color" && typeof r == "string" ? _[b].color = parseInt(r.replace("#", "0x")) : (S === "offset" || S === "alpha") && (_[b][S] = r), this.stops = _, this.stops.sort((x, y) => x.offset - y.offset), a.colorStops = this.getColorStopsForUI(), !0;
|
|
4266
4572
|
}
|
|
4267
|
-
} else i in this && (this[i] =
|
|
4573
|
+
} else i in this && (this[i] = r);
|
|
4268
4574
|
break;
|
|
4269
4575
|
}
|
|
4270
4576
|
}, t;
|
|
@@ -4373,23 +4679,23 @@ f({
|
|
|
4373
4679
|
category: "color",
|
|
4374
4680
|
description: "Maps colors using a reference texture as a lookup table",
|
|
4375
4681
|
// Create an instance of the ColorMapFilter with the provided parameters
|
|
4376
|
-
createFilter: (
|
|
4682
|
+
createFilter: (s) => {
|
|
4377
4683
|
try {
|
|
4378
4684
|
const e = g.ColorMapFilter;
|
|
4379
4685
|
if (!e)
|
|
4380
4686
|
return null;
|
|
4381
4687
|
let t = null;
|
|
4382
|
-
|
|
4688
|
+
s.texturePath ? t = w.Texture.from(s.texturePath) : t = w.Texture.from("/examples/filters-main/examples/images/colormap.png");
|
|
4383
4689
|
const i = new e({
|
|
4384
4690
|
colorMap: t,
|
|
4385
|
-
nearest:
|
|
4386
|
-
mix:
|
|
4691
|
+
nearest: s.nearest,
|
|
4692
|
+
mix: s.mix
|
|
4387
4693
|
});
|
|
4388
|
-
return i._customParams = { ...
|
|
4694
|
+
return i._customParams = { ...s }, i.updateUIParam = function(r, a) {
|
|
4389
4695
|
const o = this._customParams || {};
|
|
4390
|
-
switch (this._customParams = o, o[
|
|
4696
|
+
switch (this._customParams = o, o[r] = a, r) {
|
|
4391
4697
|
case "texturePath":
|
|
4392
|
-
a && (this.colorMap =
|
|
4698
|
+
a && (this.colorMap = w.Texture.from(a));
|
|
4393
4699
|
break;
|
|
4394
4700
|
case "mix":
|
|
4395
4701
|
this.mix = a;
|
|
@@ -4398,7 +4704,7 @@ f({
|
|
|
4398
4704
|
this.nearest = a;
|
|
4399
4705
|
break;
|
|
4400
4706
|
default:
|
|
4401
|
-
|
|
4707
|
+
r in this && (this[r] = a);
|
|
4402
4708
|
break;
|
|
4403
4709
|
}
|
|
4404
4710
|
return !0;
|
|
@@ -4450,7 +4756,7 @@ f({
|
|
|
4450
4756
|
}
|
|
4451
4757
|
]
|
|
4452
4758
|
});
|
|
4453
|
-
const
|
|
4759
|
+
const xt = g.ColorReplaceFilter;
|
|
4454
4760
|
f({
|
|
4455
4761
|
id: "color-replace",
|
|
4456
4762
|
name: "Color Replace",
|
|
@@ -4461,20 +4767,20 @@ f({
|
|
|
4461
4767
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
4462
4768
|
* proper parameter handling with an updateUIParam method
|
|
4463
4769
|
*/
|
|
4464
|
-
createFilter: (
|
|
4770
|
+
createFilter: (s) => {
|
|
4465
4771
|
try {
|
|
4466
4772
|
let e = 16711680;
|
|
4467
|
-
|
|
4773
|
+
s.originalColor && (typeof s.originalColor == "string" ? e = parseInt(s.originalColor.replace("#", "0x"), 16) : typeof s.originalColor == "number" && (e = s.originalColor));
|
|
4468
4774
|
let t = 255;
|
|
4469
|
-
|
|
4470
|
-
const i = new
|
|
4775
|
+
s.targetColor && (typeof s.targetColor == "string" ? t = parseInt(s.targetColor.replace("#", "0x"), 16) : typeof s.targetColor == "number" && (t = s.targetColor));
|
|
4776
|
+
const i = new xt({
|
|
4471
4777
|
originalColor: e,
|
|
4472
4778
|
targetColor: t,
|
|
4473
|
-
tolerance:
|
|
4779
|
+
tolerance: s.tolerance || 0.4
|
|
4474
4780
|
});
|
|
4475
|
-
return i._customParams = { ...
|
|
4781
|
+
return i._customParams = { ...s }, i.updateUIParam = function(r, a) {
|
|
4476
4782
|
const o = this._customParams || {};
|
|
4477
|
-
switch (this._customParams = o, o[
|
|
4783
|
+
switch (this._customParams = o, o[r] = a, r) {
|
|
4478
4784
|
case "originalColor":
|
|
4479
4785
|
typeof a == "string" ? this.originalColor = parseInt(a.replace("#", "0x"), 16) : typeof a == "number" && (this.originalColor = a);
|
|
4480
4786
|
break;
|
|
@@ -4485,7 +4791,7 @@ f({
|
|
|
4485
4791
|
this.tolerance = a;
|
|
4486
4792
|
break;
|
|
4487
4793
|
default:
|
|
4488
|
-
|
|
4794
|
+
r in this && (this[r] = a);
|
|
4489
4795
|
break;
|
|
4490
4796
|
}
|
|
4491
4797
|
return !0;
|
|
@@ -4531,7 +4837,7 @@ f({
|
|
|
4531
4837
|
}
|
|
4532
4838
|
]
|
|
4533
4839
|
});
|
|
4534
|
-
const
|
|
4840
|
+
const Ct = g.MultiColorReplaceFilter;
|
|
4535
4841
|
f({
|
|
4536
4842
|
id: "multi-color-replace",
|
|
4537
4843
|
name: "Multi-Color Replace",
|
|
@@ -4542,30 +4848,30 @@ f({
|
|
|
4542
4848
|
* This implementation follows the pattern from ColorGradientFilter, adding
|
|
4543
4849
|
* proper parameter handling with an updateUIParam method
|
|
4544
4850
|
*/
|
|
4545
|
-
createFilter: (
|
|
4851
|
+
createFilter: (s) => {
|
|
4546
4852
|
try {
|
|
4547
4853
|
const e = [];
|
|
4548
|
-
if (
|
|
4549
|
-
const i = typeof
|
|
4550
|
-
e.push([i,
|
|
4854
|
+
if (s.originalColor1 && s.targetColor1) {
|
|
4855
|
+
const i = typeof s.originalColor1 == "string" ? parseInt(s.originalColor1.replace("#", "0x"), 16) : s.originalColor1, r = typeof s.targetColor1 == "string" ? parseInt(s.targetColor1.replace("#", "0x"), 16) : s.targetColor1;
|
|
4856
|
+
e.push([i, r]);
|
|
4551
4857
|
}
|
|
4552
|
-
if (
|
|
4553
|
-
const i = typeof
|
|
4554
|
-
e.push([i,
|
|
4858
|
+
if (s.originalColor2 && s.targetColor2) {
|
|
4859
|
+
const i = typeof s.originalColor2 == "string" ? parseInt(s.originalColor2.replace("#", "0x"), 16) : s.originalColor2, r = typeof s.targetColor2 == "string" ? parseInt(s.targetColor2.replace("#", "0x"), 16) : s.targetColor2;
|
|
4860
|
+
e.push([i, r]);
|
|
4555
4861
|
}
|
|
4556
|
-
if (
|
|
4557
|
-
const i = typeof
|
|
4558
|
-
e.push([i,
|
|
4862
|
+
if (s.enableThirdPair && s.originalColor3 && s.targetColor3) {
|
|
4863
|
+
const i = typeof s.originalColor3 == "string" ? parseInt(s.originalColor3.replace("#", "0x"), 16) : s.originalColor3, r = typeof s.targetColor3 == "string" ? parseInt(s.targetColor3.replace("#", "0x"), 16) : s.targetColor3;
|
|
4864
|
+
e.push([i, r]);
|
|
4559
4865
|
}
|
|
4560
|
-
const t = new
|
|
4866
|
+
const t = new Ct(
|
|
4561
4867
|
e,
|
|
4562
|
-
|
|
4868
|
+
s.tolerance || 0.05,
|
|
4563
4869
|
3
|
|
4564
4870
|
// Allow up to 3 color pairs
|
|
4565
4871
|
);
|
|
4566
|
-
return t._customParams = { ...
|
|
4872
|
+
return t._customParams = { ...s }, t.updateUIParam = function(i, r) {
|
|
4567
4873
|
const a = this._customParams || {};
|
|
4568
|
-
if (this._customParams = a, a[i] =
|
|
4874
|
+
if (this._customParams = a, a[i] = r, i === "originalColor1" || i === "targetColor1" || i === "originalColor2" || i === "targetColor2" || i === "originalColor3" || i === "targetColor3" || i === "enableThirdPair") {
|
|
4569
4875
|
const o = [];
|
|
4570
4876
|
if (a.originalColor1 && a.targetColor1) {
|
|
4571
4877
|
const n = typeof a.originalColor1 == "string" ? parseInt(a.originalColor1.replace("#", "0x"), 16) : a.originalColor1, l = typeof a.targetColor1 == "string" ? parseInt(a.targetColor1.replace("#", "0x"), 16) : a.targetColor1;
|
|
@@ -4580,7 +4886,7 @@ f({
|
|
|
4580
4886
|
o.push([n, l]);
|
|
4581
4887
|
}
|
|
4582
4888
|
this.replacements = o, this.refresh();
|
|
4583
|
-
} else i === "tolerance" ? this.tolerance =
|
|
4889
|
+
} else i === "tolerance" ? this.tolerance = r : i in this && (this[i] = r);
|
|
4584
4890
|
return !0;
|
|
4585
4891
|
}, t;
|
|
4586
4892
|
} catch {
|
|
@@ -4668,7 +4974,7 @@ f({
|
|
|
4668
4974
|
}
|
|
4669
4975
|
]
|
|
4670
4976
|
});
|
|
4671
|
-
const { RGBSplitFilter:
|
|
4977
|
+
const { RGBSplitFilter: wt } = g;
|
|
4672
4978
|
f({
|
|
4673
4979
|
id: "rgb-split",
|
|
4674
4980
|
name: "RGB Split",
|
|
@@ -4678,23 +4984,23 @@ f({
|
|
|
4678
4984
|
* Create an instance of the RGBSplitFilter with the provided parameters
|
|
4679
4985
|
* Using the official pixi-filters implementation
|
|
4680
4986
|
*/
|
|
4681
|
-
createFilter: (
|
|
4987
|
+
createFilter: (s) => {
|
|
4682
4988
|
try {
|
|
4683
4989
|
const e = {
|
|
4684
|
-
x:
|
|
4685
|
-
y:
|
|
4990
|
+
x: s.redX !== void 0 ? s.redX : -10,
|
|
4991
|
+
y: s.redY !== void 0 ? s.redY : 0
|
|
4686
4992
|
}, t = {
|
|
4687
|
-
x:
|
|
4688
|
-
y:
|
|
4993
|
+
x: s.greenX !== void 0 ? s.greenX : 0,
|
|
4994
|
+
y: s.greenY !== void 0 ? s.greenY : 10
|
|
4689
4995
|
}, i = {
|
|
4690
|
-
x:
|
|
4691
|
-
y:
|
|
4692
|
-
},
|
|
4996
|
+
x: s.blueX !== void 0 ? s.blueX : 0,
|
|
4997
|
+
y: s.blueY !== void 0 ? s.blueY : 0
|
|
4998
|
+
}, r = new wt({
|
|
4693
4999
|
red: e,
|
|
4694
5000
|
green: t,
|
|
4695
5001
|
blue: i
|
|
4696
5002
|
});
|
|
4697
|
-
return
|
|
5003
|
+
return r._customParams = { ...s }, r.updateUIParam = function(a, o) {
|
|
4698
5004
|
try {
|
|
4699
5005
|
const n = this._customParams || {};
|
|
4700
5006
|
switch (this._customParams = n, n[a] = o, a) {
|
|
@@ -4724,7 +5030,7 @@ f({
|
|
|
4724
5030
|
} catch {
|
|
4725
5031
|
return this._customParams && (this._customParams[a] = o), !1;
|
|
4726
5032
|
}
|
|
4727
|
-
},
|
|
5033
|
+
}, r;
|
|
4728
5034
|
} catch {
|
|
4729
5035
|
return null;
|
|
4730
5036
|
}
|
|
@@ -4802,33 +5108,33 @@ f({
|
|
|
4802
5108
|
}
|
|
4803
5109
|
]
|
|
4804
5110
|
});
|
|
4805
|
-
const { AdvancedBloomFilter:
|
|
5111
|
+
const { AdvancedBloomFilter: St } = g;
|
|
4806
5112
|
f({
|
|
4807
5113
|
id: "advanced-bloom",
|
|
4808
5114
|
name: "Advanced Bloom",
|
|
4809
5115
|
category: "light",
|
|
4810
5116
|
description: "Adds a sophisticated bloom/glow effect with fine-grained control",
|
|
4811
5117
|
// Create an instance of the AdvancedBloomFilter with the provided parameters
|
|
4812
|
-
createFilter: (
|
|
5118
|
+
createFilter: (s) => {
|
|
4813
5119
|
try {
|
|
4814
|
-
const e = new
|
|
4815
|
-
threshold:
|
|
4816
|
-
bloomScale:
|
|
4817
|
-
brightness:
|
|
4818
|
-
blur:
|
|
4819
|
-
quality:
|
|
5120
|
+
const e = new St({
|
|
5121
|
+
threshold: s.threshold || 0.5,
|
|
5122
|
+
bloomScale: s.bloomScale || 1,
|
|
5123
|
+
brightness: s.brightness || 1,
|
|
5124
|
+
blur: s.blur || 8,
|
|
5125
|
+
quality: s.quality || 4,
|
|
4820
5126
|
pixelSize: {
|
|
4821
|
-
x:
|
|
4822
|
-
y:
|
|
5127
|
+
x: s.pixelSizeX || 1,
|
|
5128
|
+
y: s.pixelSizeY || 1
|
|
4823
5129
|
}
|
|
4824
5130
|
});
|
|
4825
5131
|
return e._customParams = {
|
|
4826
|
-
pixelSizeX:
|
|
4827
|
-
pixelSizeY:
|
|
5132
|
+
pixelSizeX: s.pixelSizeX || 1,
|
|
5133
|
+
pixelSizeY: s.pixelSizeY || 1
|
|
4828
5134
|
}, e.updateUIParam = function(t, i) {
|
|
4829
5135
|
try {
|
|
4830
|
-
const
|
|
4831
|
-
switch (this._customParams =
|
|
5136
|
+
const r = this._customParams || {};
|
|
5137
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
4832
5138
|
case "threshold":
|
|
4833
5139
|
this.threshold = Number(i);
|
|
4834
5140
|
break;
|
|
@@ -4845,14 +5151,14 @@ f({
|
|
|
4845
5151
|
this.quality = Number(i);
|
|
4846
5152
|
break;
|
|
4847
5153
|
case "pixelSizeX":
|
|
4848
|
-
|
|
5154
|
+
r.pixelSizeX = Number(i), this.pixelSize = {
|
|
4849
5155
|
x: Number(i),
|
|
4850
|
-
y:
|
|
5156
|
+
y: r.pixelSizeY
|
|
4851
5157
|
};
|
|
4852
5158
|
break;
|
|
4853
5159
|
case "pixelSizeY":
|
|
4854
|
-
|
|
4855
|
-
x:
|
|
5160
|
+
r.pixelSizeY = Number(i), this.pixelSize = {
|
|
5161
|
+
x: r.pixelSizeX,
|
|
4856
5162
|
y: Number(i)
|
|
4857
5163
|
};
|
|
4858
5164
|
break;
|
|
@@ -4958,28 +5264,28 @@ f({
|
|
|
4958
5264
|
}
|
|
4959
5265
|
]
|
|
4960
5266
|
});
|
|
4961
|
-
const
|
|
5267
|
+
const vt = g.AsciiFilter;
|
|
4962
5268
|
f({
|
|
4963
5269
|
id: "ascii",
|
|
4964
5270
|
name: "ASCII",
|
|
4965
5271
|
category: "stylize",
|
|
4966
5272
|
description: "Convert image to ASCII text characters",
|
|
4967
5273
|
// Create an instance of the AsciiFilter with the provided parameters
|
|
4968
|
-
createFilter: (
|
|
5274
|
+
createFilter: (s) => {
|
|
4969
5275
|
try {
|
|
4970
|
-
const e = typeof
|
|
4971
|
-
let t =
|
|
5276
|
+
const e = typeof s.size == "number" ? s.size : 8;
|
|
5277
|
+
let t = s.color;
|
|
4972
5278
|
typeof t == "string" && t.startsWith("#") && (t = parseInt(t.replace("#", "0x"), 16));
|
|
4973
|
-
const i =
|
|
5279
|
+
const i = s.replaceColor === !0, r = new vt({
|
|
4974
5280
|
size: e,
|
|
4975
5281
|
color: t,
|
|
4976
5282
|
replaceColor: i
|
|
4977
5283
|
});
|
|
4978
|
-
return
|
|
5284
|
+
return r._customParams = {
|
|
4979
5285
|
size: e,
|
|
4980
5286
|
color: t,
|
|
4981
5287
|
replaceColor: i
|
|
4982
|
-
},
|
|
5288
|
+
}, r.updateUIParam = function(a, o) {
|
|
4983
5289
|
try {
|
|
4984
5290
|
const n = this._customParams || {};
|
|
4985
5291
|
switch (this._customParams = n, n[a] = o, a) {
|
|
@@ -4998,7 +5304,7 @@ f({
|
|
|
4998
5304
|
}
|
|
4999
5305
|
} catch {
|
|
5000
5306
|
}
|
|
5001
|
-
},
|
|
5307
|
+
}, r;
|
|
5002
5308
|
} catch {
|
|
5003
5309
|
return null;
|
|
5004
5310
|
}
|
|
@@ -5037,27 +5343,27 @@ f({
|
|
|
5037
5343
|
}
|
|
5038
5344
|
]
|
|
5039
5345
|
});
|
|
5040
|
-
const
|
|
5346
|
+
const kt = g.BackdropBlurFilter;
|
|
5041
5347
|
f({
|
|
5042
5348
|
id: "backdrop-blur",
|
|
5043
5349
|
name: "Backdrop Blur",
|
|
5044
5350
|
category: "blur",
|
|
5045
5351
|
description: "Blurs what is behind the object, creating a glass-like effect",
|
|
5046
5352
|
// Create an instance of the BackdropBlurFilter with the provided parameters
|
|
5047
|
-
createFilter: (
|
|
5353
|
+
createFilter: (s) => {
|
|
5048
5354
|
try {
|
|
5049
|
-
const e = new
|
|
5355
|
+
const e = new kt({
|
|
5050
5356
|
// Higher strength values (20-50) make the effect more noticeable
|
|
5051
|
-
strength:
|
|
5052
|
-
quality:
|
|
5357
|
+
strength: s.strength || 20,
|
|
5358
|
+
quality: s.quality || 4,
|
|
5053
5359
|
// Lower resolution values (0.2-0.5) can make the effect more visible but less sharp
|
|
5054
|
-
resolution:
|
|
5055
|
-
kernelSize:
|
|
5360
|
+
resolution: s.resolution || 0.5,
|
|
5361
|
+
kernelSize: s.kernelSize || 9
|
|
5056
5362
|
});
|
|
5057
|
-
return e._customParams = { ...
|
|
5363
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
5058
5364
|
try {
|
|
5059
|
-
const
|
|
5060
|
-
switch (this._customParams =
|
|
5365
|
+
const r = this._customParams || {};
|
|
5366
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
5061
5367
|
case "strength":
|
|
5062
5368
|
this.strength = Number(i), this.blur = Number(i) / 4;
|
|
5063
5369
|
break;
|
|
@@ -5144,7 +5450,7 @@ f({
|
|
|
5144
5450
|
}
|
|
5145
5451
|
]
|
|
5146
5452
|
});
|
|
5147
|
-
const { BevelFilter:
|
|
5453
|
+
const { BevelFilter: Pt } = g;
|
|
5148
5454
|
f({
|
|
5149
5455
|
id: "bevel",
|
|
5150
5456
|
name: "Bevel",
|
|
@@ -5154,20 +5460,20 @@ f({
|
|
|
5154
5460
|
* Create an instance of the BevelFilter with the provided parameters
|
|
5155
5461
|
* Using the official pixi-filters implementation
|
|
5156
5462
|
*/
|
|
5157
|
-
createFilter: (
|
|
5463
|
+
createFilter: (s) => {
|
|
5158
5464
|
try {
|
|
5159
|
-
const e =
|
|
5160
|
-
rotation:
|
|
5161
|
-
thickness:
|
|
5465
|
+
const e = s.lightColor ? s.lightColor.replace("#", "0x") : "0xffffff", t = s.shadowColor ? s.shadowColor.replace("#", "0x") : "0x000000", i = new Pt({
|
|
5466
|
+
rotation: s.rotation !== void 0 ? s.rotation : 45,
|
|
5467
|
+
thickness: s.thickness !== void 0 ? s.thickness : 2,
|
|
5162
5468
|
lightColor: parseInt(e, 16),
|
|
5163
|
-
lightAlpha:
|
|
5469
|
+
lightAlpha: s.lightAlpha !== void 0 ? s.lightAlpha : 0.7,
|
|
5164
5470
|
shadowColor: parseInt(t, 16),
|
|
5165
|
-
shadowAlpha:
|
|
5471
|
+
shadowAlpha: s.shadowAlpha !== void 0 ? s.shadowAlpha : 0.7
|
|
5166
5472
|
});
|
|
5167
|
-
return i._customParams = { ...
|
|
5473
|
+
return i._customParams = { ...s }, i.updateUIParam = function(r, a) {
|
|
5168
5474
|
try {
|
|
5169
5475
|
const o = this._customParams || {};
|
|
5170
|
-
switch (this._customParams = o, o[
|
|
5476
|
+
switch (this._customParams = o, o[r] = a, r) {
|
|
5171
5477
|
case "rotation":
|
|
5172
5478
|
this.rotation = Number(a);
|
|
5173
5479
|
break;
|
|
@@ -5193,12 +5499,12 @@ f({
|
|
|
5193
5499
|
this.shadowAlpha = Number(a);
|
|
5194
5500
|
break;
|
|
5195
5501
|
default:
|
|
5196
|
-
|
|
5502
|
+
r in this && (this[r] = a);
|
|
5197
5503
|
break;
|
|
5198
5504
|
}
|
|
5199
5505
|
return !0;
|
|
5200
5506
|
} catch {
|
|
5201
|
-
return this._customParams && (this._customParams[
|
|
5507
|
+
return this._customParams && (this._customParams[r] = a), !1;
|
|
5202
5508
|
}
|
|
5203
5509
|
}, i;
|
|
5204
5510
|
} catch {
|
|
@@ -5272,29 +5578,29 @@ f({
|
|
|
5272
5578
|
}
|
|
5273
5579
|
]
|
|
5274
5580
|
});
|
|
5275
|
-
const { BloomFilter:
|
|
5581
|
+
const { BloomFilter: Mt } = g;
|
|
5276
5582
|
f({
|
|
5277
5583
|
id: "bloom",
|
|
5278
5584
|
name: "Bloom/Glow",
|
|
5279
5585
|
category: "light",
|
|
5280
5586
|
description: "Add a subtle glow effect to bright areas of the image",
|
|
5281
5587
|
// Create an instance of the BloomFilter with the provided parameters
|
|
5282
|
-
createFilter: (
|
|
5588
|
+
createFilter: (s) => {
|
|
5283
5589
|
try {
|
|
5284
|
-
const e = typeof
|
|
5590
|
+
const e = typeof s.strengthX == "number" ? s.strengthX : 2, t = typeof s.strengthY == "number" ? s.strengthY : 2, i = typeof s.quality == "number" ? s.quality : 4, r = typeof s.resolution == "number" ? s.resolution : 1, a = typeof s.kernelSize == "number" ? s.kernelSize : 5, o = new Mt({
|
|
5285
5591
|
strength: {
|
|
5286
5592
|
x: Number(e),
|
|
5287
5593
|
y: Number(t)
|
|
5288
5594
|
},
|
|
5289
5595
|
quality: Number(i),
|
|
5290
|
-
resolution: Number(
|
|
5596
|
+
resolution: Number(r),
|
|
5291
5597
|
kernelSize: Number(a)
|
|
5292
5598
|
});
|
|
5293
5599
|
return o._customParams = {
|
|
5294
5600
|
strengthX: e,
|
|
5295
5601
|
strengthY: t,
|
|
5296
5602
|
quality: i,
|
|
5297
|
-
resolution:
|
|
5603
|
+
resolution: r,
|
|
5298
5604
|
kernelSize: a
|
|
5299
5605
|
}, o.updateUIParam = function(n, l) {
|
|
5300
5606
|
var c, d;
|
|
@@ -5384,7 +5690,7 @@ f({
|
|
|
5384
5690
|
}
|
|
5385
5691
|
]
|
|
5386
5692
|
});
|
|
5387
|
-
const { BulgePinchFilter:
|
|
5693
|
+
const { BulgePinchFilter: Ft } = g;
|
|
5388
5694
|
f({
|
|
5389
5695
|
id: "bulge-pinch",
|
|
5390
5696
|
// ID must match what the application expects
|
|
@@ -5392,17 +5698,17 @@ f({
|
|
|
5392
5698
|
category: "distortion",
|
|
5393
5699
|
description: "Creates a bulge or pinch effect in a circular area",
|
|
5394
5700
|
// Create an instance of the BulgePinchFilter with the provided parameters
|
|
5395
|
-
createFilter: (
|
|
5701
|
+
createFilter: (s) => {
|
|
5396
5702
|
try {
|
|
5397
|
-
const e =
|
|
5703
|
+
const e = s.centerX ?? 0.5, t = s.centerY ?? 0.5, i = s.radius ?? 100, r = s.strength ?? 1, a = new Ft({
|
|
5398
5704
|
center: {
|
|
5399
5705
|
x: e,
|
|
5400
5706
|
y: t
|
|
5401
5707
|
},
|
|
5402
5708
|
radius: i,
|
|
5403
|
-
strength:
|
|
5709
|
+
strength: r
|
|
5404
5710
|
});
|
|
5405
|
-
return a._customParams = { ...
|
|
5711
|
+
return a._customParams = { ...s }, a.updateUIParam = function(o, n) {
|
|
5406
5712
|
const l = this._customParams || {};
|
|
5407
5713
|
switch (this._customParams = l, l[o] = n, o) {
|
|
5408
5714
|
case "centerX":
|
|
@@ -5476,7 +5782,7 @@ f({
|
|
|
5476
5782
|
}
|
|
5477
5783
|
]
|
|
5478
5784
|
});
|
|
5479
|
-
const { ConvolutionFilter:
|
|
5785
|
+
const { ConvolutionFilter: At } = g, E = {
|
|
5480
5786
|
normal: [0, 0, 0, 0, 1, 0, 0, 0, 0],
|
|
5481
5787
|
gaussianBlur: [0.045, 0.122, 0.045, 0.122, 0.332, 0.122, 0.045, 0.122, 0.045],
|
|
5482
5788
|
boxBlur: [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9],
|
|
@@ -5492,42 +5798,42 @@ f({
|
|
|
5492
5798
|
name: "Convolution Matrix",
|
|
5493
5799
|
category: "effects",
|
|
5494
5800
|
description: "Apply custom image effects using matrix convolution",
|
|
5495
|
-
createFilter: (
|
|
5801
|
+
createFilter: (s) => {
|
|
5496
5802
|
try {
|
|
5497
5803
|
let e;
|
|
5498
|
-
if (
|
|
5804
|
+
if (s.customMatrix)
|
|
5499
5805
|
e = [
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5806
|
+
s.m00,
|
|
5807
|
+
s.m01,
|
|
5808
|
+
s.m02,
|
|
5809
|
+
s.m10,
|
|
5810
|
+
s.m11,
|
|
5811
|
+
s.m12,
|
|
5812
|
+
s.m20,
|
|
5813
|
+
s.m21,
|
|
5814
|
+
s.m22
|
|
5509
5815
|
];
|
|
5510
5816
|
else {
|
|
5511
|
-
const i =
|
|
5512
|
-
e =
|
|
5817
|
+
const i = s.preset;
|
|
5818
|
+
e = E[i] || E.normal;
|
|
5513
5819
|
}
|
|
5514
|
-
const t = new
|
|
5515
|
-
return t._customParams = { ...
|
|
5820
|
+
const t = new At(e, s.width || 200, s.height || 200);
|
|
5821
|
+
return t._customParams = { ...s }, t.updateUIParam = function(i, r) {
|
|
5516
5822
|
const a = this._customParams || {};
|
|
5517
|
-
switch (this._customParams = a, a[i] =
|
|
5823
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
5518
5824
|
case "preset":
|
|
5519
5825
|
if (!a.customMatrix) {
|
|
5520
|
-
const o =
|
|
5521
|
-
|
|
5826
|
+
const o = r;
|
|
5827
|
+
E[o] && (this.matrix = E[o]);
|
|
5522
5828
|
}
|
|
5523
5829
|
break;
|
|
5524
5830
|
case "customMatrix":
|
|
5525
|
-
if (
|
|
5831
|
+
if (r) {
|
|
5526
5832
|
const o = this.matrix;
|
|
5527
5833
|
a.m00 = o[0], a.m01 = o[1], a.m02 = o[2], a.m10 = o[3], a.m11 = o[4], a.m12 = o[5], a.m20 = o[6], a.m21 = o[7], a.m22 = o[8];
|
|
5528
5834
|
} else {
|
|
5529
5835
|
const o = a.preset;
|
|
5530
|
-
this.matrix =
|
|
5836
|
+
this.matrix = E[o] || E.normal;
|
|
5531
5837
|
}
|
|
5532
5838
|
break;
|
|
5533
5839
|
case "m00":
|
|
@@ -5551,17 +5857,17 @@ f({
|
|
|
5551
5857
|
m21: 7,
|
|
5552
5858
|
m22: 8
|
|
5553
5859
|
}[i];
|
|
5554
|
-
l !== void 0 && (o[l] =
|
|
5860
|
+
l !== void 0 && (o[l] = r, this.matrix = o);
|
|
5555
5861
|
}
|
|
5556
5862
|
break;
|
|
5557
5863
|
case "width":
|
|
5558
|
-
this.width =
|
|
5864
|
+
this.width = r;
|
|
5559
5865
|
break;
|
|
5560
5866
|
case "height":
|
|
5561
|
-
this.height =
|
|
5867
|
+
this.height = r;
|
|
5562
5868
|
break;
|
|
5563
5869
|
default:
|
|
5564
|
-
i in this && (this[i] =
|
|
5870
|
+
i in this && (this[i] = r);
|
|
5565
5871
|
break;
|
|
5566
5872
|
}
|
|
5567
5873
|
}, t;
|
|
@@ -5722,7 +6028,7 @@ f({
|
|
|
5722
6028
|
}
|
|
5723
6029
|
]
|
|
5724
6030
|
});
|
|
5725
|
-
const { CrossHatchFilter:
|
|
6031
|
+
const { CrossHatchFilter: zt } = g;
|
|
5726
6032
|
f({
|
|
5727
6033
|
id: "cross-hatch",
|
|
5728
6034
|
name: "Cross Hatch",
|
|
@@ -5730,9 +6036,9 @@ f({
|
|
|
5730
6036
|
description: "Creates a crosshatching effect like in a pencil drawing",
|
|
5731
6037
|
// Create an instance of the CrossHatchFilter
|
|
5732
6038
|
// Note: CrossHatchFilter has NO parameters according to PixiJS examples
|
|
5733
|
-
createFilter: (
|
|
6039
|
+
createFilter: (s) => {
|
|
5734
6040
|
try {
|
|
5735
|
-
const e = new
|
|
6041
|
+
const e = new zt();
|
|
5736
6042
|
return e.updateUIParam = function(t, i) {
|
|
5737
6043
|
return !0;
|
|
5738
6044
|
}, e;
|
|
@@ -5751,60 +6057,60 @@ f({
|
|
|
5751
6057
|
category: "stylize",
|
|
5752
6058
|
description: "Simulates an old CRT screen with scan lines and noise",
|
|
5753
6059
|
// Create an instance of the CRTFilter with the provided parameters
|
|
5754
|
-
createFilter: (
|
|
6060
|
+
createFilter: (s) => {
|
|
5755
6061
|
try {
|
|
5756
6062
|
const e = {
|
|
5757
|
-
lineWidth: typeof
|
|
5758
|
-
noise: typeof
|
|
5759
|
-
curvature: typeof
|
|
5760
|
-
lineContrast: typeof
|
|
5761
|
-
verticalLine:
|
|
5762
|
-
noiseSize: typeof
|
|
5763
|
-
vignetting: typeof
|
|
5764
|
-
vignettingAlpha: typeof
|
|
5765
|
-
vignettingBlur: typeof
|
|
5766
|
-
time: typeof
|
|
5767
|
-
seed: typeof
|
|
6063
|
+
lineWidth: typeof s.lineWidth == "number" ? s.lineWidth : 1,
|
|
6064
|
+
noise: typeof s.noise == "number" ? s.noise : 0.3,
|
|
6065
|
+
curvature: typeof s.curvature == "number" ? s.curvature : 1,
|
|
6066
|
+
lineContrast: typeof s.lineContrast == "number" ? s.lineContrast : 0.25,
|
|
6067
|
+
verticalLine: s.verticalLine === !0,
|
|
6068
|
+
noiseSize: typeof s.noiseSize == "number" ? s.noiseSize : 1,
|
|
6069
|
+
vignetting: typeof s.vignetting == "number" ? s.vignetting : 0.3,
|
|
6070
|
+
vignettingAlpha: typeof s.vignettingAlpha == "number" ? s.vignettingAlpha : 1,
|
|
6071
|
+
vignettingBlur: typeof s.vignettingBlur == "number" ? s.vignettingBlur : 0.3,
|
|
6072
|
+
time: typeof s.time == "number" ? s.time : 0,
|
|
6073
|
+
seed: typeof s.seed == "number" ? s.seed : Math.random()
|
|
5768
6074
|
}, t = new g.CRTFilter(e);
|
|
5769
|
-
return t._customParams = { ...e }, t.updateUIParam = function(i,
|
|
6075
|
+
return t._customParams = { ...e }, t.updateUIParam = function(i, r) {
|
|
5770
6076
|
try {
|
|
5771
6077
|
const a = this._customParams || {};
|
|
5772
|
-
switch (this._customParams = a, a[i] =
|
|
6078
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
5773
6079
|
case "lineWidth":
|
|
5774
|
-
this.lineWidth = Number(
|
|
6080
|
+
this.lineWidth = Number(r);
|
|
5775
6081
|
break;
|
|
5776
6082
|
case "noise":
|
|
5777
|
-
this.noise = Number(
|
|
6083
|
+
this.noise = Number(r);
|
|
5778
6084
|
break;
|
|
5779
6085
|
case "curvature":
|
|
5780
|
-
this.curvature = Number(
|
|
6086
|
+
this.curvature = Number(r);
|
|
5781
6087
|
break;
|
|
5782
6088
|
case "lineContrast":
|
|
5783
|
-
this.lineContrast = Number(
|
|
6089
|
+
this.lineContrast = Number(r);
|
|
5784
6090
|
break;
|
|
5785
6091
|
case "verticalLine":
|
|
5786
|
-
this.verticalLine = !!
|
|
6092
|
+
this.verticalLine = !!r;
|
|
5787
6093
|
break;
|
|
5788
6094
|
case "noiseSize":
|
|
5789
|
-
this.noiseSize = Number(
|
|
6095
|
+
this.noiseSize = Number(r);
|
|
5790
6096
|
break;
|
|
5791
6097
|
case "vignetting":
|
|
5792
|
-
this.vignetting = Number(
|
|
6098
|
+
this.vignetting = Number(r);
|
|
5793
6099
|
break;
|
|
5794
6100
|
case "vignettingAlpha":
|
|
5795
|
-
this.vignettingAlpha = Number(
|
|
6101
|
+
this.vignettingAlpha = Number(r);
|
|
5796
6102
|
break;
|
|
5797
6103
|
case "vignettingBlur":
|
|
5798
|
-
this.vignettingBlur = Number(
|
|
6104
|
+
this.vignettingBlur = Number(r);
|
|
5799
6105
|
break;
|
|
5800
6106
|
case "time":
|
|
5801
|
-
this.time = Number(
|
|
6107
|
+
this.time = Number(r);
|
|
5802
6108
|
break;
|
|
5803
6109
|
case "seed":
|
|
5804
|
-
this.seed = Number(
|
|
6110
|
+
this.seed = Number(r);
|
|
5805
6111
|
break;
|
|
5806
6112
|
default:
|
|
5807
|
-
i in this && (this[i] =
|
|
6113
|
+
i in this && (this[i] = r);
|
|
5808
6114
|
break;
|
|
5809
6115
|
}
|
|
5810
6116
|
} catch {
|
|
@@ -5929,7 +6235,7 @@ f({
|
|
|
5929
6235
|
}
|
|
5930
6236
|
]
|
|
5931
6237
|
});
|
|
5932
|
-
const
|
|
6238
|
+
const Nt = w.DisplacementFilter, Rt = w.Sprite, q = w.Texture;
|
|
5933
6239
|
f({
|
|
5934
6240
|
id: "displacement",
|
|
5935
6241
|
// ID must match what the application expects
|
|
@@ -5937,9 +6243,9 @@ f({
|
|
|
5937
6243
|
category: "distortion",
|
|
5938
6244
|
description: "Distorts the image using a displacement map texture",
|
|
5939
6245
|
// Create an instance of the DisplacementFilter with the provided parameters
|
|
5940
|
-
createFilter: (
|
|
6246
|
+
createFilter: (s) => {
|
|
5941
6247
|
try {
|
|
5942
|
-
const e =
|
|
6248
|
+
const e = s.mapTexture || "/assets/images/displacement_map.png";
|
|
5943
6249
|
let t;
|
|
5944
6250
|
try {
|
|
5945
6251
|
t = q.from(e), t.source.addressMode = "repeat";
|
|
@@ -5955,8 +6261,8 @@ f({
|
|
|
5955
6261
|
}
|
|
5956
6262
|
t = q.from(o);
|
|
5957
6263
|
}
|
|
5958
|
-
const i = new
|
|
5959
|
-
return
|
|
6264
|
+
const i = new Rt(t), r = new Nt(i, s.scale || 50);
|
|
6265
|
+
return r.scale.x = s.scaleX || 50, r.scale.y = s.scaleY || 50, r._customParams = { ...s }, r._displacementSprite = i, r.updateUIParam = function(a, o) {
|
|
5960
6266
|
const n = this._customParams || {};
|
|
5961
6267
|
switch (this._customParams = n, n[a] = o, a) {
|
|
5962
6268
|
case "scaleX":
|
|
@@ -5980,7 +6286,7 @@ f({
|
|
|
5980
6286
|
break;
|
|
5981
6287
|
}
|
|
5982
6288
|
return !0;
|
|
5983
|
-
},
|
|
6289
|
+
}, r;
|
|
5984
6290
|
} catch {
|
|
5985
6291
|
return null;
|
|
5986
6292
|
}
|
|
@@ -6034,28 +6340,28 @@ f({
|
|
|
6034
6340
|
category: "stylize",
|
|
6035
6341
|
description: "Simulates a halftone printing pattern with dots",
|
|
6036
6342
|
// Create an instance of the DotFilter with the provided parameters
|
|
6037
|
-
createFilter: (
|
|
6343
|
+
createFilter: (s) => {
|
|
6038
6344
|
try {
|
|
6039
6345
|
const e = {
|
|
6040
|
-
scale: typeof
|
|
6041
|
-
angle: typeof
|
|
6042
|
-
grayscale:
|
|
6346
|
+
scale: typeof s.scale == "number" ? s.scale : 1,
|
|
6347
|
+
angle: typeof s.angle == "number" ? s.angle : 5,
|
|
6348
|
+
grayscale: s.grayscale === !0
|
|
6043
6349
|
}, t = new g.DotFilter(e);
|
|
6044
|
-
return t._customParams = { ...e }, t.updateUIParam = function(i,
|
|
6350
|
+
return t._customParams = { ...e }, t.updateUIParam = function(i, r) {
|
|
6045
6351
|
try {
|
|
6046
6352
|
const a = this._customParams || {};
|
|
6047
|
-
switch (this._customParams = a, a[i] =
|
|
6353
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
6048
6354
|
case "scale":
|
|
6049
|
-
this.scale = Number(
|
|
6355
|
+
this.scale = Number(r);
|
|
6050
6356
|
break;
|
|
6051
6357
|
case "angle":
|
|
6052
|
-
this.angle = Number(
|
|
6358
|
+
this.angle = Number(r);
|
|
6053
6359
|
break;
|
|
6054
6360
|
case "grayscale":
|
|
6055
|
-
this.grayscale = !!
|
|
6361
|
+
this.grayscale = !!r;
|
|
6056
6362
|
break;
|
|
6057
6363
|
default:
|
|
6058
|
-
i in this && (this[i] =
|
|
6364
|
+
i in this && (this[i] = r);
|
|
6059
6365
|
break;
|
|
6060
6366
|
}
|
|
6061
6367
|
} catch {
|
|
@@ -6102,28 +6408,28 @@ f({
|
|
|
6102
6408
|
}
|
|
6103
6409
|
]
|
|
6104
6410
|
});
|
|
6105
|
-
const { EmbossFilter:
|
|
6411
|
+
const { EmbossFilter: Tt } = g;
|
|
6106
6412
|
f({
|
|
6107
6413
|
id: "emboss",
|
|
6108
6414
|
name: "Emboss",
|
|
6109
6415
|
category: "stylize",
|
|
6110
6416
|
description: "Creates an embossed relief effect",
|
|
6111
6417
|
// Create an instance of the Emboss filter with the provided parameters
|
|
6112
|
-
createFilter: (
|
|
6418
|
+
createFilter: (s) => {
|
|
6113
6419
|
try {
|
|
6114
|
-
const e = typeof
|
|
6420
|
+
const e = typeof s.strength == "number" ? s.strength : 5, t = new Tt(e);
|
|
6115
6421
|
return t._customParams = {
|
|
6116
6422
|
strength: e
|
|
6117
|
-
}, t.updateUIParam = function(i,
|
|
6423
|
+
}, t.updateUIParam = function(i, r) {
|
|
6118
6424
|
try {
|
|
6119
6425
|
const a = this._customParams || {};
|
|
6120
|
-
switch (this._customParams = a, a[i] =
|
|
6426
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
6121
6427
|
case "strength":
|
|
6122
|
-
const o = Number(
|
|
6428
|
+
const o = Number(r);
|
|
6123
6429
|
a.strength = o, this.strength = o;
|
|
6124
6430
|
break;
|
|
6125
6431
|
default:
|
|
6126
|
-
i in this && (this[i] =
|
|
6432
|
+
i in this && (this[i] = r);
|
|
6127
6433
|
break;
|
|
6128
6434
|
}
|
|
6129
6435
|
} catch {
|
|
@@ -6151,7 +6457,7 @@ f({
|
|
|
6151
6457
|
}
|
|
6152
6458
|
]
|
|
6153
6459
|
});
|
|
6154
|
-
const { GlitchFilter:
|
|
6460
|
+
const { GlitchFilter: It } = g, z = {
|
|
6155
6461
|
TRANSPARENT: 0,
|
|
6156
6462
|
ORIGINAL: 1,
|
|
6157
6463
|
LOOP: 2,
|
|
@@ -6163,29 +6469,29 @@ f({
|
|
|
6163
6469
|
name: "Glitch",
|
|
6164
6470
|
category: "effects",
|
|
6165
6471
|
description: "Apply digital distortion and glitch effects",
|
|
6166
|
-
createFilter: (
|
|
6472
|
+
createFilter: (s) => {
|
|
6167
6473
|
try {
|
|
6168
|
-
const e = { x:
|
|
6169
|
-
slices:
|
|
6170
|
-
offset:
|
|
6171
|
-
direction:
|
|
6172
|
-
fillMode:
|
|
6173
|
-
seed:
|
|
6174
|
-
average:
|
|
6175
|
-
minSize:
|
|
6176
|
-
sampleSize:
|
|
6474
|
+
const e = { x: s.redX, y: s.redY }, t = { x: s.greenX, y: s.greenY }, i = { x: s.blueX, y: s.blueY }, r = new It({
|
|
6475
|
+
slices: s.slices,
|
|
6476
|
+
offset: s.offset,
|
|
6477
|
+
direction: s.direction,
|
|
6478
|
+
fillMode: s.fillMode,
|
|
6479
|
+
seed: s.seed,
|
|
6480
|
+
average: s.average,
|
|
6481
|
+
minSize: s.minSize,
|
|
6482
|
+
sampleSize: s.sampleSize,
|
|
6177
6483
|
red: e,
|
|
6178
6484
|
green: t,
|
|
6179
6485
|
blue: i
|
|
6180
6486
|
});
|
|
6181
|
-
|
|
6487
|
+
r.animating = s.animating || !1, r._customParams = { ...s }, typeof r.refresh == "function" && r.refresh();
|
|
6182
6488
|
let a = null;
|
|
6183
6489
|
const o = () => {
|
|
6184
|
-
|
|
6490
|
+
r.animating && (r.seed = Math.random()), a = requestAnimationFrame(o);
|
|
6185
6491
|
};
|
|
6186
|
-
return
|
|
6492
|
+
return r.animating && (a = requestAnimationFrame(o)), r._stopAnimation = () => {
|
|
6187
6493
|
a !== null && (cancelAnimationFrame(a), a = null);
|
|
6188
|
-
},
|
|
6494
|
+
}, r.updateUIParam = function(n, l) {
|
|
6189
6495
|
const c = this._customParams || {};
|
|
6190
6496
|
switch (this._customParams = c, c[n] = l, n) {
|
|
6191
6497
|
case "animating":
|
|
@@ -6234,7 +6540,7 @@ f({
|
|
|
6234
6540
|
n in this && (this[n] = l);
|
|
6235
6541
|
break;
|
|
6236
6542
|
}
|
|
6237
|
-
},
|
|
6543
|
+
}, r;
|
|
6238
6544
|
} catch {
|
|
6239
6545
|
return null;
|
|
6240
6546
|
}
|
|
@@ -6243,7 +6549,7 @@ f({
|
|
|
6243
6549
|
slices: 10,
|
|
6244
6550
|
offset: 100,
|
|
6245
6551
|
direction: 0,
|
|
6246
|
-
fillMode:
|
|
6552
|
+
fillMode: z.LOOP,
|
|
6247
6553
|
// LOOP mode looks better for the demo
|
|
6248
6554
|
seed: 0.5,
|
|
6249
6555
|
average: !1,
|
|
@@ -6306,13 +6612,13 @@ f({
|
|
|
6306
6612
|
label: "Fill Mode",
|
|
6307
6613
|
property: "fillMode",
|
|
6308
6614
|
options: [
|
|
6309
|
-
{ value:
|
|
6310
|
-
{ value:
|
|
6311
|
-
{ value:
|
|
6312
|
-
{ value:
|
|
6313
|
-
{ value:
|
|
6615
|
+
{ value: z.TRANSPARENT, label: "Transparent" },
|
|
6616
|
+
{ value: z.ORIGINAL, label: "Original" },
|
|
6617
|
+
{ value: z.LOOP, label: "Loop" },
|
|
6618
|
+
{ value: z.CLAMP, label: "Clamp" },
|
|
6619
|
+
{ value: z.MIRROR, label: "Mirror" }
|
|
6314
6620
|
],
|
|
6315
|
-
default:
|
|
6621
|
+
default: z.LOOP
|
|
6316
6622
|
},
|
|
6317
6623
|
{
|
|
6318
6624
|
id: "seed",
|
|
@@ -6406,54 +6712,54 @@ f({
|
|
|
6406
6712
|
}
|
|
6407
6713
|
]
|
|
6408
6714
|
});
|
|
6409
|
-
const { GlowFilter:
|
|
6715
|
+
const { GlowFilter: Et } = g;
|
|
6410
6716
|
f({
|
|
6411
6717
|
id: "glow",
|
|
6412
6718
|
name: "Glow",
|
|
6413
6719
|
category: "light",
|
|
6414
6720
|
description: "Adds a customizable glow effect around the image",
|
|
6415
6721
|
// Create an instance of the GlowFilter with the provided parameters
|
|
6416
|
-
createFilter: (
|
|
6722
|
+
createFilter: (s) => {
|
|
6417
6723
|
try {
|
|
6418
|
-
const e = parseInt(
|
|
6419
|
-
distance:
|
|
6420
|
-
outerStrength:
|
|
6421
|
-
innerStrength:
|
|
6724
|
+
const e = parseInt(s.color.replace("#", "0x"), 16), t = new Et({
|
|
6725
|
+
distance: s.distance || 10,
|
|
6726
|
+
outerStrength: s.outerStrength || 4,
|
|
6727
|
+
innerStrength: s.innerStrength || 0,
|
|
6422
6728
|
color: e,
|
|
6423
|
-
alpha:
|
|
6424
|
-
quality:
|
|
6425
|
-
knockout:
|
|
6729
|
+
alpha: s.alpha ?? 1,
|
|
6730
|
+
quality: s.quality || 0.1,
|
|
6731
|
+
knockout: s.knockout || !1
|
|
6426
6732
|
});
|
|
6427
6733
|
return t._customParams = {
|
|
6428
|
-
color:
|
|
6429
|
-
...
|
|
6430
|
-
}, t.updateUIParam = function(i,
|
|
6734
|
+
color: s.color || "#ffffff",
|
|
6735
|
+
...s
|
|
6736
|
+
}, t.updateUIParam = function(i, r) {
|
|
6431
6737
|
try {
|
|
6432
6738
|
const a = this._customParams || {};
|
|
6433
|
-
switch (this._customParams = a, a[i] =
|
|
6739
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
6434
6740
|
case "distance":
|
|
6435
|
-
this.distance = Number(
|
|
6741
|
+
this.distance = Number(r);
|
|
6436
6742
|
break;
|
|
6437
6743
|
case "outerStrength":
|
|
6438
|
-
this.outerStrength = Number(
|
|
6744
|
+
this.outerStrength = Number(r);
|
|
6439
6745
|
break;
|
|
6440
6746
|
case "innerStrength":
|
|
6441
|
-
this.innerStrength = Number(
|
|
6747
|
+
this.innerStrength = Number(r);
|
|
6442
6748
|
break;
|
|
6443
6749
|
case "color":
|
|
6444
|
-
a.color =
|
|
6750
|
+
a.color = r, this.color = parseInt(r.replace("#", "0x"), 16);
|
|
6445
6751
|
break;
|
|
6446
6752
|
case "alpha":
|
|
6447
|
-
this.alpha = Number(
|
|
6753
|
+
this.alpha = Number(r);
|
|
6448
6754
|
break;
|
|
6449
6755
|
case "quality":
|
|
6450
|
-
this.quality = Number(
|
|
6756
|
+
this.quality = Number(r);
|
|
6451
6757
|
break;
|
|
6452
6758
|
case "knockout":
|
|
6453
|
-
this.knockout = !!
|
|
6759
|
+
this.knockout = !!r;
|
|
6454
6760
|
break;
|
|
6455
6761
|
default:
|
|
6456
|
-
i in this && (this[i] =
|
|
6762
|
+
i in this && (this[i] = r);
|
|
6457
6763
|
break;
|
|
6458
6764
|
}
|
|
6459
6765
|
} catch {
|
|
@@ -6541,35 +6847,35 @@ f({
|
|
|
6541
6847
|
}
|
|
6542
6848
|
]
|
|
6543
6849
|
});
|
|
6544
|
-
const { GodrayFilter:
|
|
6850
|
+
const { GodrayFilter: Xt } = g;
|
|
6545
6851
|
f({
|
|
6546
6852
|
id: "godray",
|
|
6547
6853
|
name: "Godray",
|
|
6548
6854
|
category: "light",
|
|
6549
6855
|
description: "Creates volumetric light-ray effects (crepuscular rays)",
|
|
6550
6856
|
// Create an instance of the GodrayFilter with the provided parameters
|
|
6551
|
-
createFilter: (
|
|
6857
|
+
createFilter: (s) => {
|
|
6552
6858
|
try {
|
|
6553
|
-
const e = new
|
|
6554
|
-
angle:
|
|
6555
|
-
parallel:
|
|
6859
|
+
const e = new Xt({
|
|
6860
|
+
angle: s.angle || 30,
|
|
6861
|
+
parallel: s.parallel ?? !0,
|
|
6556
6862
|
center: {
|
|
6557
|
-
x:
|
|
6558
|
-
y:
|
|
6863
|
+
x: s.centerX || 0,
|
|
6864
|
+
y: s.centerY || 0
|
|
6559
6865
|
},
|
|
6560
|
-
gain:
|
|
6561
|
-
lacunarity:
|
|
6562
|
-
time:
|
|
6563
|
-
alpha:
|
|
6866
|
+
gain: s.gain || 0.5,
|
|
6867
|
+
lacunarity: s.lacunarity || 2.5,
|
|
6868
|
+
time: s.time || 0,
|
|
6869
|
+
alpha: s.alpha || 1
|
|
6564
6870
|
});
|
|
6565
6871
|
return e._customParams = {
|
|
6566
|
-
centerX:
|
|
6567
|
-
centerY:
|
|
6568
|
-
...
|
|
6872
|
+
centerX: s.centerX || 0,
|
|
6873
|
+
centerY: s.centerY || 0,
|
|
6874
|
+
...s
|
|
6569
6875
|
}, e.updateUIParam = function(t, i) {
|
|
6570
6876
|
try {
|
|
6571
|
-
const
|
|
6572
|
-
switch (this._customParams =
|
|
6877
|
+
const r = this._customParams || {};
|
|
6878
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
6573
6879
|
case "angle":
|
|
6574
6880
|
this.angle = Number(i);
|
|
6575
6881
|
break;
|
|
@@ -6577,14 +6883,14 @@ f({
|
|
|
6577
6883
|
this.parallel = !!i;
|
|
6578
6884
|
break;
|
|
6579
6885
|
case "centerX":
|
|
6580
|
-
|
|
6886
|
+
r.centerX = Number(i), this.center = {
|
|
6581
6887
|
x: Number(i),
|
|
6582
|
-
y:
|
|
6888
|
+
y: r.centerY
|
|
6583
6889
|
};
|
|
6584
6890
|
break;
|
|
6585
6891
|
case "centerY":
|
|
6586
|
-
|
|
6587
|
-
x:
|
|
6892
|
+
r.centerY = Number(i), this.center = {
|
|
6893
|
+
x: r.centerX,
|
|
6588
6894
|
y: Number(i)
|
|
6589
6895
|
};
|
|
6590
6896
|
break;
|
|
@@ -6703,18 +7009,18 @@ f({
|
|
|
6703
7009
|
}
|
|
6704
7010
|
]
|
|
6705
7011
|
});
|
|
6706
|
-
const
|
|
7012
|
+
const Yt = g.SimpleLightmapFilter, re = w.Texture;
|
|
6707
7013
|
f({
|
|
6708
7014
|
id: "lightmap",
|
|
6709
7015
|
name: "Lightmap",
|
|
6710
7016
|
category: "light",
|
|
6711
7017
|
description: "Applies lighting effects using a reference texture as a light map",
|
|
6712
7018
|
// Create an instance of the SimpleLightmapFilter with the provided parameters
|
|
6713
|
-
createFilter: (
|
|
7019
|
+
createFilter: (s) => {
|
|
6714
7020
|
try {
|
|
6715
|
-
const e =
|
|
6716
|
-
|
|
6717
|
-
const a =
|
|
7021
|
+
const e = s.textureType || "default", t = s.color || "#000000", i = typeof s.alpha == "number" ? s.alpha : 1, r = document.createElement("canvas");
|
|
7022
|
+
r.width = 256, r.height = 256;
|
|
7023
|
+
const a = r.getContext("2d");
|
|
6718
7024
|
if (!a)
|
|
6719
7025
|
throw new Error("Canvas 2D context not available");
|
|
6720
7026
|
if (e === "spotlight") {
|
|
@@ -6728,14 +7034,14 @@ f({
|
|
|
6728
7034
|
const c = a.createRadialGradient(128, 128, 10, 128, 128, 160);
|
|
6729
7035
|
c.addColorStop(0, "white"), c.addColorStop(0.3, "rgba(220, 220, 220, 1)"), c.addColorStop(0.6, "rgba(150, 150, 150, 1)"), c.addColorStop(1, "black"), a.fillStyle = c, a.fillRect(0, 0, 256, 256);
|
|
6730
7036
|
}
|
|
6731
|
-
const o =
|
|
7037
|
+
const o = re.from(r);
|
|
6732
7038
|
let n;
|
|
6733
7039
|
try {
|
|
6734
7040
|
typeof t == "string" && t.startsWith("#") ? n = parseInt(t.replace("#", "0x"), 16) : n = 0;
|
|
6735
7041
|
} catch {
|
|
6736
7042
|
n = 0;
|
|
6737
7043
|
}
|
|
6738
|
-
const l = new
|
|
7044
|
+
const l = new Yt(o, n, i);
|
|
6739
7045
|
return l._customParams = {
|
|
6740
7046
|
textureType: e,
|
|
6741
7047
|
color: t,
|
|
@@ -6761,7 +7067,7 @@ f({
|
|
|
6761
7067
|
const b = m.createRadialGradient(128, 128, 10, 128, 128, 160);
|
|
6762
7068
|
b.addColorStop(0, "white"), b.addColorStop(0.3, "rgba(220, 220, 220, 1)"), b.addColorStop(0.6, "rgba(150, 150, 150, 1)"), b.addColorStop(1, "black"), m.fillStyle = b, m.fillRect(0, 0, 256, 256);
|
|
6763
7069
|
}
|
|
6764
|
-
const S =
|
|
7070
|
+
const S = re.from(p);
|
|
6765
7071
|
if (this.lightMap = S, this.enabled !== void 0) {
|
|
6766
7072
|
const b = this.enabled;
|
|
6767
7073
|
this.enabled = !1, setTimeout(() => {
|
|
@@ -6834,28 +7140,28 @@ f({
|
|
|
6834
7140
|
}
|
|
6835
7141
|
]
|
|
6836
7142
|
});
|
|
6837
|
-
const { NoiseFilter:
|
|
7143
|
+
const { NoiseFilter: Bt } = w;
|
|
6838
7144
|
f({
|
|
6839
7145
|
id: "noise",
|
|
6840
7146
|
name: "Noise",
|
|
6841
7147
|
category: "effects",
|
|
6842
7148
|
description: "Add random noise to the image",
|
|
6843
|
-
createFilter: (
|
|
7149
|
+
createFilter: (s) => {
|
|
6844
7150
|
try {
|
|
6845
|
-
const e = new
|
|
6846
|
-
noise:
|
|
6847
|
-
seed:
|
|
7151
|
+
const e = new Bt({
|
|
7152
|
+
noise: s.noise || 0.5,
|
|
7153
|
+
seed: s.seed || Math.random()
|
|
6848
7154
|
});
|
|
6849
|
-
e.animating =
|
|
7155
|
+
e.animating = s.animating || !1, e._customParams = { ...s };
|
|
6850
7156
|
let t = null;
|
|
6851
7157
|
const i = () => {
|
|
6852
7158
|
e.animating && (e.seed = Math.random()), t = requestAnimationFrame(i);
|
|
6853
7159
|
};
|
|
6854
7160
|
return e.animating && (t = requestAnimationFrame(i)), e._stopAnimation = () => {
|
|
6855
7161
|
t !== null && (cancelAnimationFrame(t), t = null);
|
|
6856
|
-
}, e.updateUIParam = function(
|
|
7162
|
+
}, e.updateUIParam = function(r, a) {
|
|
6857
7163
|
const o = this._customParams || {};
|
|
6858
|
-
switch (this._customParams = o, o[
|
|
7164
|
+
switch (this._customParams = o, o[r] = a, r) {
|
|
6859
7165
|
case "animating":
|
|
6860
7166
|
this.animating = a, a && !t && (t = requestAnimationFrame(i));
|
|
6861
7167
|
break;
|
|
@@ -6869,7 +7175,7 @@ f({
|
|
|
6869
7175
|
a && (this.seed = Math.random());
|
|
6870
7176
|
break;
|
|
6871
7177
|
default:
|
|
6872
|
-
|
|
7178
|
+
r in this && (this[r] = a);
|
|
6873
7179
|
break;
|
|
6874
7180
|
}
|
|
6875
7181
|
}, e;
|
|
@@ -6919,36 +7225,36 @@ f({
|
|
|
6919
7225
|
}
|
|
6920
7226
|
]
|
|
6921
7227
|
});
|
|
6922
|
-
const { OldFilmFilter:
|
|
7228
|
+
const { OldFilmFilter: Ot } = g;
|
|
6923
7229
|
f({
|
|
6924
7230
|
id: "old-film",
|
|
6925
7231
|
name: "Old Film",
|
|
6926
7232
|
category: "effects",
|
|
6927
7233
|
description: "Apply a vintage film effect with scratches and grain",
|
|
6928
|
-
createFilter: (
|
|
7234
|
+
createFilter: (s) => {
|
|
6929
7235
|
try {
|
|
6930
|
-
const e = new
|
|
6931
|
-
sepia:
|
|
6932
|
-
noise:
|
|
6933
|
-
noiseSize:
|
|
6934
|
-
scratch:
|
|
6935
|
-
scratchDensity:
|
|
6936
|
-
scratchWidth:
|
|
6937
|
-
vignetting:
|
|
6938
|
-
vignettingAlpha:
|
|
6939
|
-
vignettingBlur:
|
|
6940
|
-
seed:
|
|
7236
|
+
const e = new Ot({
|
|
7237
|
+
sepia: s.sepia,
|
|
7238
|
+
noise: s.noise,
|
|
7239
|
+
noiseSize: s.noiseSize,
|
|
7240
|
+
scratch: s.scratch,
|
|
7241
|
+
scratchDensity: s.scratchDensity,
|
|
7242
|
+
scratchWidth: s.scratchWidth,
|
|
7243
|
+
vignetting: s.vignetting,
|
|
7244
|
+
vignettingAlpha: s.vignettingAlpha,
|
|
7245
|
+
vignettingBlur: s.vignettingBlur,
|
|
7246
|
+
seed: s.seed || Math.random()
|
|
6941
7247
|
});
|
|
6942
|
-
e.animating =
|
|
7248
|
+
e.animating = s.animating || !1, e._customParams = { ...s };
|
|
6943
7249
|
let t = null;
|
|
6944
7250
|
const i = () => {
|
|
6945
7251
|
e.animating && (e.seed = Math.random()), t = requestAnimationFrame(i);
|
|
6946
7252
|
};
|
|
6947
7253
|
return e.animating && (t = requestAnimationFrame(i)), e._stopAnimation = () => {
|
|
6948
7254
|
t !== null && (cancelAnimationFrame(t), t = null);
|
|
6949
|
-
}, e.updateUIParam = function(
|
|
7255
|
+
}, e.updateUIParam = function(r, a) {
|
|
6950
7256
|
const o = this._customParams || {};
|
|
6951
|
-
switch (this._customParams = o, o[
|
|
7257
|
+
switch (this._customParams = o, o[r] = a, r) {
|
|
6952
7258
|
case "animating":
|
|
6953
7259
|
this.animating = a, a && !t && (t = requestAnimationFrame(i));
|
|
6954
7260
|
break;
|
|
@@ -6967,10 +7273,10 @@ f({
|
|
|
6967
7273
|
case "vignetting":
|
|
6968
7274
|
case "vignettingAlpha":
|
|
6969
7275
|
case "vignettingBlur":
|
|
6970
|
-
|
|
7276
|
+
r in this && (this[r] = a);
|
|
6971
7277
|
break;
|
|
6972
7278
|
default:
|
|
6973
|
-
|
|
7279
|
+
r in this && (this[r] = a);
|
|
6974
7280
|
break;
|
|
6975
7281
|
}
|
|
6976
7282
|
}, e;
|
|
@@ -7108,43 +7414,43 @@ f({
|
|
|
7108
7414
|
}
|
|
7109
7415
|
]
|
|
7110
7416
|
});
|
|
7111
|
-
const { OutlineFilter:
|
|
7417
|
+
const { OutlineFilter: Lt } = g;
|
|
7112
7418
|
f({
|
|
7113
7419
|
id: "outline",
|
|
7114
7420
|
name: "Outline",
|
|
7115
7421
|
category: "effects",
|
|
7116
7422
|
description: "Add an outline or stroke around the image",
|
|
7117
|
-
createFilter: (
|
|
7423
|
+
createFilter: (s) => {
|
|
7118
7424
|
try {
|
|
7119
|
-
let e =
|
|
7425
|
+
let e = s.color;
|
|
7120
7426
|
typeof e == "string" && (e = parseInt(e.replace("#", "0x"), 16));
|
|
7121
|
-
const t = new
|
|
7122
|
-
thickness:
|
|
7427
|
+
const t = new Lt({
|
|
7428
|
+
thickness: s.thickness || 4,
|
|
7123
7429
|
color: e,
|
|
7124
|
-
alpha:
|
|
7125
|
-
quality:
|
|
7126
|
-
knockout:
|
|
7430
|
+
alpha: s.alpha || 1,
|
|
7431
|
+
quality: s.quality || 0.1,
|
|
7432
|
+
knockout: s.knockout || !1
|
|
7127
7433
|
});
|
|
7128
|
-
return t._customParams = { ...
|
|
7434
|
+
return t._customParams = { ...s }, t.updateUIParam = function(i, r) {
|
|
7129
7435
|
const a = this._customParams || {};
|
|
7130
|
-
switch (this._customParams = a, a[i] =
|
|
7436
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
7131
7437
|
case "thickness":
|
|
7132
|
-
this.thickness = Math.max(0,
|
|
7438
|
+
this.thickness = Math.max(0, r);
|
|
7133
7439
|
break;
|
|
7134
7440
|
case "color":
|
|
7135
|
-
typeof
|
|
7441
|
+
typeof r == "string" ? (this.color = parseInt(r.replace("#", "0x"), 16), a.color = r) : this.color = r;
|
|
7136
7442
|
break;
|
|
7137
7443
|
case "alpha":
|
|
7138
|
-
this.alpha = Math.max(0, Math.min(1,
|
|
7444
|
+
this.alpha = Math.max(0, Math.min(1, r));
|
|
7139
7445
|
break;
|
|
7140
7446
|
case "quality":
|
|
7141
|
-
this.quality = Math.max(0.01, Math.min(1,
|
|
7447
|
+
this.quality = Math.max(0.01, Math.min(1, r));
|
|
7142
7448
|
break;
|
|
7143
7449
|
case "knockout":
|
|
7144
|
-
this.knockout = !!
|
|
7450
|
+
this.knockout = !!r;
|
|
7145
7451
|
break;
|
|
7146
7452
|
default:
|
|
7147
|
-
i in this && (this[i] =
|
|
7453
|
+
i in this && (this[i] = r);
|
|
7148
7454
|
break;
|
|
7149
7455
|
}
|
|
7150
7456
|
}, t;
|
|
@@ -7208,37 +7514,37 @@ f({
|
|
|
7208
7514
|
}
|
|
7209
7515
|
]
|
|
7210
7516
|
});
|
|
7211
|
-
const { PixelateFilter:
|
|
7517
|
+
const { PixelateFilter: Dt } = g;
|
|
7212
7518
|
f({
|
|
7213
7519
|
id: "pixelate",
|
|
7214
7520
|
name: "Pixelate",
|
|
7215
7521
|
category: "effects",
|
|
7216
7522
|
description: "Create a pixelated or mosaic effect",
|
|
7217
|
-
createFilter: (
|
|
7523
|
+
createFilter: (s) => {
|
|
7218
7524
|
try {
|
|
7219
|
-
const e = new
|
|
7220
|
-
|
|
7525
|
+
const e = new Dt(
|
|
7526
|
+
s.useUniform ? Math.max(4, s.size || 10) : [Math.max(4, s.sizeX || 10), Math.max(4, s.sizeY || 10)]
|
|
7221
7527
|
);
|
|
7222
|
-
return e._customParams = { ...
|
|
7223
|
-
const
|
|
7224
|
-
switch (this._customParams =
|
|
7528
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
7529
|
+
const r = this._customParams || {};
|
|
7530
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
7225
7531
|
case "useUniform":
|
|
7226
|
-
if (
|
|
7532
|
+
if (r.useUniform = i, i) {
|
|
7227
7533
|
const a = Math.round((this.sizeX + this.sizeY) / 2);
|
|
7228
|
-
this.size = Math.max(4, a),
|
|
7534
|
+
this.size = Math.max(4, a), r.size = a;
|
|
7229
7535
|
} else {
|
|
7230
7536
|
const a = Array.isArray(this.size) ? this.size[0] : this.size;
|
|
7231
|
-
this.sizeX = Math.max(4, a), this.sizeY = Math.max(4, a),
|
|
7537
|
+
this.sizeX = Math.max(4, a), this.sizeY = Math.max(4, a), r.sizeX = this.sizeX, r.sizeY = this.sizeY;
|
|
7232
7538
|
}
|
|
7233
7539
|
break;
|
|
7234
7540
|
case "size":
|
|
7235
|
-
|
|
7541
|
+
r.useUniform && (this.size = Math.max(4, i));
|
|
7236
7542
|
break;
|
|
7237
7543
|
case "sizeX":
|
|
7238
|
-
|
|
7544
|
+
r.useUniform || (this.sizeX = Math.max(4, i));
|
|
7239
7545
|
break;
|
|
7240
7546
|
case "sizeY":
|
|
7241
|
-
|
|
7547
|
+
r.useUniform || (this.sizeY = Math.max(4, i));
|
|
7242
7548
|
break;
|
|
7243
7549
|
default:
|
|
7244
7550
|
t in this && (this[t] = i);
|
|
@@ -7299,7 +7605,7 @@ f({
|
|
|
7299
7605
|
}
|
|
7300
7606
|
]
|
|
7301
7607
|
});
|
|
7302
|
-
const { ReflectionFilter:
|
|
7608
|
+
const { ReflectionFilter: Ut } = g;
|
|
7303
7609
|
f({
|
|
7304
7610
|
id: "reflection",
|
|
7305
7611
|
// ID must match what the application expects
|
|
@@ -7307,47 +7613,47 @@ f({
|
|
|
7307
7613
|
category: "distortion",
|
|
7308
7614
|
description: "Creates a water reflection effect with configurable waves",
|
|
7309
7615
|
// Create an instance of the ReflectionFilter with the provided parameters
|
|
7310
|
-
createFilter: (
|
|
7616
|
+
createFilter: (s) => {
|
|
7311
7617
|
try {
|
|
7312
7618
|
const e = {
|
|
7313
|
-
mirror:
|
|
7314
|
-
boundary:
|
|
7315
|
-
amplitude: new Float32Array([
|
|
7316
|
-
waveLength: new Float32Array([
|
|
7317
|
-
alpha: new Float32Array([
|
|
7318
|
-
time:
|
|
7319
|
-
}, t = new
|
|
7320
|
-
return t._customParams = { ...
|
|
7619
|
+
mirror: s.mirror ?? !0,
|
|
7620
|
+
boundary: s.boundary ?? 0.5,
|
|
7621
|
+
amplitude: new Float32Array([s.amplitudeStart ?? 0, s.amplitudeEnd ?? 20]),
|
|
7622
|
+
waveLength: new Float32Array([s.wavelengthStart ?? 30, s.wavelengthEnd ?? 100]),
|
|
7623
|
+
alpha: new Float32Array([s.alphaStart ?? 1, s.alphaEnd ?? 1]),
|
|
7624
|
+
time: s.time ?? 0
|
|
7625
|
+
}, t = new Ut(e);
|
|
7626
|
+
return t._customParams = { ...s }, t.animating = s.animating ?? !1, t.updateUIParam = function(i, r) {
|
|
7321
7627
|
const a = this._customParams || {};
|
|
7322
|
-
switch (this._customParams = a, a[i] =
|
|
7628
|
+
switch (this._customParams = a, a[i] = r, i) {
|
|
7323
7629
|
case "mirror":
|
|
7324
7630
|
case "boundary":
|
|
7325
7631
|
case "time":
|
|
7326
|
-
this[i] =
|
|
7632
|
+
this[i] = r;
|
|
7327
7633
|
break;
|
|
7328
7634
|
case "amplitudeStart":
|
|
7329
|
-
Array.isArray(this.amplitude) || (this.amplitude = [0, this._customParams.amplitudeEnd || 20]), this.amplitude[0] =
|
|
7635
|
+
Array.isArray(this.amplitude) || (this.amplitude = [0, this._customParams.amplitudeEnd || 20]), this.amplitude[0] = r;
|
|
7330
7636
|
break;
|
|
7331
7637
|
case "amplitudeEnd":
|
|
7332
|
-
Array.isArray(this.amplitude) || (this.amplitude = [this._customParams.amplitudeStart || 0, 20]), this.amplitude[1] =
|
|
7638
|
+
Array.isArray(this.amplitude) || (this.amplitude = [this._customParams.amplitudeStart || 0, 20]), this.amplitude[1] = r;
|
|
7333
7639
|
break;
|
|
7334
7640
|
case "wavelengthStart":
|
|
7335
|
-
Array.isArray(this.waveLength) || (this.waveLength = [30, this._customParams.wavelengthEnd || 100]), this.waveLength[0] =
|
|
7641
|
+
Array.isArray(this.waveLength) || (this.waveLength = [30, this._customParams.wavelengthEnd || 100]), this.waveLength[0] = r;
|
|
7336
7642
|
break;
|
|
7337
7643
|
case "wavelengthEnd":
|
|
7338
|
-
Array.isArray(this.waveLength) || (this.waveLength = [this._customParams.wavelengthStart || 30, 100]), this.waveLength[1] =
|
|
7644
|
+
Array.isArray(this.waveLength) || (this.waveLength = [this._customParams.wavelengthStart || 30, 100]), this.waveLength[1] = r;
|
|
7339
7645
|
break;
|
|
7340
7646
|
case "alphaStart":
|
|
7341
|
-
Array.isArray(this.alpha) || (this.alpha = [1, this._customParams.alphaEnd || 1]), this.alpha[0] =
|
|
7647
|
+
Array.isArray(this.alpha) || (this.alpha = [1, this._customParams.alphaEnd || 1]), this.alpha[0] = r;
|
|
7342
7648
|
break;
|
|
7343
7649
|
case "alphaEnd":
|
|
7344
|
-
Array.isArray(this.alpha) || (this.alpha = [this._customParams.alphaStart || 1, 1]), this.alpha[1] =
|
|
7650
|
+
Array.isArray(this.alpha) || (this.alpha = [this._customParams.alphaStart || 1, 1]), this.alpha[1] = r;
|
|
7345
7651
|
break;
|
|
7346
7652
|
case "animating":
|
|
7347
|
-
this.animating =
|
|
7653
|
+
this.animating = r;
|
|
7348
7654
|
break;
|
|
7349
7655
|
default:
|
|
7350
|
-
i in this && (this[i] =
|
|
7656
|
+
i in this && (this[i] = r);
|
|
7351
7657
|
break;
|
|
7352
7658
|
}
|
|
7353
7659
|
return !0;
|
|
@@ -7467,7 +7773,7 @@ f({
|
|
|
7467
7773
|
}
|
|
7468
7774
|
]
|
|
7469
7775
|
});
|
|
7470
|
-
const { ShockwaveFilter:
|
|
7776
|
+
const { ShockwaveFilter: Vt } = g;
|
|
7471
7777
|
f({
|
|
7472
7778
|
id: "shockwave",
|
|
7473
7779
|
// ID must match what the application expects
|
|
@@ -7475,18 +7781,18 @@ f({
|
|
|
7475
7781
|
category: "distortion",
|
|
7476
7782
|
description: "Creates a rippling shockwave or blast wave effect",
|
|
7477
7783
|
// Create an instance of the ShockwaveFilter with the provided parameters
|
|
7478
|
-
createFilter: (
|
|
7784
|
+
createFilter: (s) => {
|
|
7479
7785
|
try {
|
|
7480
|
-
const e =
|
|
7786
|
+
const e = s.centerX ?? 0.5, t = s.centerY ?? 0.5, i = { x: e, y: t }, r = s.amplitude ?? 30, a = s.wavelength ?? 160, o = s.speed ?? 500, n = s.brightness ?? 1, l = s.radius ?? -1, c = s.time ?? 0, d = new Vt({
|
|
7481
7787
|
center: i,
|
|
7482
|
-
amplitude:
|
|
7788
|
+
amplitude: r,
|
|
7483
7789
|
wavelength: a,
|
|
7484
7790
|
speed: o,
|
|
7485
7791
|
brightness: n,
|
|
7486
7792
|
radius: l,
|
|
7487
7793
|
time: c
|
|
7488
7794
|
});
|
|
7489
|
-
return d._customParams = { ...
|
|
7795
|
+
return d._customParams = { ...s }, d.animating = s.animating ?? !1, d.updateUIParam = function(h, p) {
|
|
7490
7796
|
const m = this._customParams || {};
|
|
7491
7797
|
switch (this._customParams = m, m[h] = p, h) {
|
|
7492
7798
|
case "centerX":
|
|
@@ -7619,26 +7925,26 @@ f({
|
|
|
7619
7925
|
}
|
|
7620
7926
|
]
|
|
7621
7927
|
});
|
|
7622
|
-
const { SimplexNoiseFilter:
|
|
7928
|
+
const { SimplexNoiseFilter: jt } = g;
|
|
7623
7929
|
f({
|
|
7624
7930
|
id: "simplex-noise",
|
|
7625
7931
|
name: "Simplex Noise",
|
|
7626
7932
|
category: "effects",
|
|
7627
7933
|
description: "Apply procedural noise to create texture effects",
|
|
7628
|
-
createFilter: (
|
|
7934
|
+
createFilter: (s) => {
|
|
7629
7935
|
try {
|
|
7630
|
-
const e =
|
|
7631
|
-
strength:
|
|
7632
|
-
noiseScale:
|
|
7633
|
-
offsetX:
|
|
7634
|
-
offsetY:
|
|
7936
|
+
const e = s.animating ? 0 : s.offsetZ || 0, t = new jt({
|
|
7937
|
+
strength: s.strength,
|
|
7938
|
+
noiseScale: s.noiseScale,
|
|
7939
|
+
offsetX: s.offsetX,
|
|
7940
|
+
offsetY: s.offsetY,
|
|
7635
7941
|
offsetZ: e,
|
|
7636
|
-
step:
|
|
7942
|
+
step: s.step
|
|
7637
7943
|
});
|
|
7638
|
-
t.animating =
|
|
7639
|
-
let i = null,
|
|
7944
|
+
t.animating = s.animating || !1, t.animationSpeed = s.animationSpeed || 0.01, t._customParams = { ...s };
|
|
7945
|
+
let i = null, r = 0;
|
|
7640
7946
|
const a = () => {
|
|
7641
|
-
t.animating && (
|
|
7947
|
+
t.animating && (r += t.animationSpeed, t.offsetZ = r), i = requestAnimationFrame(a);
|
|
7642
7948
|
};
|
|
7643
7949
|
return t.animating && (i = requestAnimationFrame(a)), t._stopAnimation = () => {
|
|
7644
7950
|
i !== null && (cancelAnimationFrame(i), i = null);
|
|
@@ -7774,9 +8080,9 @@ f({
|
|
|
7774
8080
|
}
|
|
7775
8081
|
]
|
|
7776
8082
|
});
|
|
7777
|
-
class
|
|
8083
|
+
class qt extends w.Filter {
|
|
7778
8084
|
constructor(e) {
|
|
7779
|
-
const t =
|
|
8085
|
+
const t = be.from({
|
|
7780
8086
|
vertex: `
|
|
7781
8087
|
attribute vec2 aPosition;
|
|
7782
8088
|
varying vec2 vTextureCoord;
|
|
@@ -7883,15 +8189,15 @@ f({
|
|
|
7883
8189
|
name: "Twist",
|
|
7884
8190
|
category: "distortion",
|
|
7885
8191
|
description: "Creates a twisting distortion effect around a central point",
|
|
7886
|
-
createFilter: (
|
|
8192
|
+
createFilter: (s) => {
|
|
7887
8193
|
try {
|
|
7888
|
-
const e = new
|
|
7889
|
-
centerX:
|
|
7890
|
-
centerY:
|
|
7891
|
-
radius:
|
|
7892
|
-
angle:
|
|
8194
|
+
const e = new qt({
|
|
8195
|
+
centerX: s.centerX ?? 0.5,
|
|
8196
|
+
centerY: s.centerY ?? 0.5,
|
|
8197
|
+
radius: s.radius ?? 0.25,
|
|
8198
|
+
angle: s.angle ?? 4
|
|
7893
8199
|
});
|
|
7894
|
-
return e._customParams = { ...
|
|
8200
|
+
return e._customParams = { ...s }, e;
|
|
7895
8201
|
} catch {
|
|
7896
8202
|
return null;
|
|
7897
8203
|
}
|
|
@@ -7955,16 +8261,16 @@ f({
|
|
|
7955
8261
|
}
|
|
7956
8262
|
]
|
|
7957
8263
|
});
|
|
7958
|
-
const { AdjustmentFilter:
|
|
7959
|
-
function L(
|
|
7960
|
-
const e = typeof
|
|
8264
|
+
const { AdjustmentFilter: Ht } = g;
|
|
8265
|
+
function L(s) {
|
|
8266
|
+
const e = typeof s == "string" ? parseInt(s.replace("#", "0x"), 16) : s;
|
|
7961
8267
|
return [
|
|
7962
8268
|
(e >> 16 & 255) / 255,
|
|
7963
8269
|
(e >> 8 & 255) / 255,
|
|
7964
8270
|
(e & 255) / 255
|
|
7965
8271
|
];
|
|
7966
8272
|
}
|
|
7967
|
-
class
|
|
8273
|
+
class $t extends Ht {
|
|
7968
8274
|
constructor(e = {}) {
|
|
7969
8275
|
super({
|
|
7970
8276
|
brightness: 1,
|
|
@@ -8005,16 +8311,16 @@ f({
|
|
|
8005
8311
|
name: "Vignette",
|
|
8006
8312
|
category: "effects",
|
|
8007
8313
|
description: "Add a classic darkened border effect to the image",
|
|
8008
|
-
createFilter: (
|
|
8314
|
+
createFilter: (s) => {
|
|
8009
8315
|
try {
|
|
8010
|
-
const e = new
|
|
8011
|
-
radius:
|
|
8012
|
-
strength:
|
|
8013
|
-
color:
|
|
8316
|
+
const e = new $t({
|
|
8317
|
+
radius: s.radius || 0.8,
|
|
8318
|
+
strength: s.strength || 1,
|
|
8319
|
+
color: s.color || "#000000"
|
|
8014
8320
|
});
|
|
8015
|
-
return e._customParams = { ...
|
|
8016
|
-
const
|
|
8017
|
-
switch (this._customParams =
|
|
8321
|
+
return e._customParams = { ...s }, e.updateUIParam = function(t, i) {
|
|
8322
|
+
const r = this._customParams || {};
|
|
8323
|
+
switch (this._customParams = r, r[t] = i, t) {
|
|
8018
8324
|
case "radius":
|
|
8019
8325
|
this.radius = Math.max(0.1, Math.min(1.5, i));
|
|
8020
8326
|
break;
|
|
@@ -8022,7 +8328,7 @@ f({
|
|
|
8022
8328
|
this.strength = Math.max(0, i);
|
|
8023
8329
|
break;
|
|
8024
8330
|
case "color":
|
|
8025
|
-
this.color = i, typeof i == "string" && (
|
|
8331
|
+
this.color = i, typeof i == "string" && (r.color = i);
|
|
8026
8332
|
break;
|
|
8027
8333
|
default:
|
|
8028
8334
|
t in this && (this[t] = i);
|
|
@@ -8071,22 +8377,22 @@ f({
|
|
|
8071
8377
|
}
|
|
8072
8378
|
]
|
|
8073
8379
|
});
|
|
8074
|
-
function
|
|
8380
|
+
function Jt(s) {
|
|
8075
8381
|
try {
|
|
8076
8382
|
let e = [], t = [];
|
|
8077
8383
|
try {
|
|
8078
|
-
e =
|
|
8384
|
+
e = D(), e.length === 0 && Je();
|
|
8079
8385
|
} catch {
|
|
8080
8386
|
}
|
|
8081
|
-
const i =
|
|
8387
|
+
const i = s == null ? void 0 : s.disabled;
|
|
8082
8388
|
if (Array.isArray(i) && i.length > 0) {
|
|
8083
|
-
let
|
|
8389
|
+
let r = 0;
|
|
8084
8390
|
for (const a of i)
|
|
8085
|
-
|
|
8086
|
-
|
|
8391
|
+
it(a) && r++;
|
|
8392
|
+
r > 0;
|
|
8087
8393
|
}
|
|
8088
8394
|
try {
|
|
8089
|
-
e =
|
|
8395
|
+
e = D(), t = tt();
|
|
8090
8396
|
} catch {
|
|
8091
8397
|
e || (e = []), t || (t = []);
|
|
8092
8398
|
}
|
|
@@ -8096,16 +8402,16 @@ function Kt(r) {
|
|
|
8096
8402
|
}
|
|
8097
8403
|
}
|
|
8098
8404
|
export {
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8405
|
+
Gt as V,
|
|
8406
|
+
Qe as a,
|
|
8407
|
+
et as b,
|
|
8408
|
+
tt as c,
|
|
8409
|
+
Je as d,
|
|
8410
|
+
Qt as e,
|
|
8411
|
+
rt as f,
|
|
8412
|
+
D as g,
|
|
8413
|
+
Kt as h,
|
|
8414
|
+
Jt as i,
|
|
8109
8415
|
f as r
|
|
8110
8416
|
};
|
|
8111
|
-
//# sourceMappingURL=editor-
|
|
8417
|
+
//# sourceMappingURL=editor-DJXRx8vN.js.map
|