@pixerate/editor-react 0.179.0 → 0.180.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{paint-editor → brushes}/BrushEditor.d.cts +14 -5
- package/dist/{paint-editor → brushes}/BrushEditor.d.ts +14 -5
- package/dist/brushes/BrushLibraryEditor.d.cts +26 -0
- package/dist/brushes/BrushLibraryEditor.d.ts +26 -0
- package/dist/brushes/index.cjs +289 -20
- package/dist/brushes/index.d.cts +2 -0
- package/dist/brushes/index.d.ts +2 -0
- package/dist/brushes/index.js +6 -2
- package/dist/chunk-76JBZXLM.js +263 -0
- package/dist/chunk-QIJJCDYW.js +119 -0
- package/dist/{chunk-UR4KL7WE.js → chunk-XAPJMT3W.js} +26 -6
- package/dist/image-editor/BrushOptionsBar.d.cts +6 -1
- package/dist/image-editor/BrushOptionsBar.d.ts +6 -1
- package/dist/image-editor/index.cjs +1178 -894
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1719 -1435
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +20 -23
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +413 -609
- package/dist/vector/VectorAppearancePanel.d.cts +8 -2
- package/dist/vector/VectorAppearancePanel.d.ts +8 -2
- package/dist/vector/index.cjs +1110 -748
- package/dist/vector/index.js +90 -59
- package/package.json +3 -3
- package/dist/chunk-62FMEDGG.js +0 -54
- package/dist/chunk-PQK2UMAY.js +0 -23
|
@@ -19,8 +19,17 @@ import {
|
|
|
19
19
|
usePlaybackSurface
|
|
20
20
|
} from "../chunk-W5CMGX3I.js";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
BrushEditor,
|
|
23
|
+
BrushLibraryBrowser,
|
|
24
|
+
CommitColorInput,
|
|
25
|
+
ErrorLine,
|
|
26
|
+
PaintSlider,
|
|
27
|
+
PixelCanvas,
|
|
28
|
+
button,
|
|
29
|
+
chip,
|
|
30
|
+
panel,
|
|
31
|
+
useAttempt
|
|
32
|
+
} from "../chunk-76JBZXLM.js";
|
|
24
33
|
|
|
25
34
|
// src/paint-editor/usePaintEditor.ts
|
|
26
35
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
@@ -342,137 +351,45 @@ var PaintAgentStrokeLines = ({ strokes }) => {
|
|
|
342
351
|
};
|
|
343
352
|
|
|
344
353
|
// src/paint-editor/PaintToolbar.tsx
|
|
345
|
-
import { useRef as
|
|
354
|
+
import { useRef as useRef3, useState as useState3 } from "react";
|
|
346
355
|
import { PAINT_TOOLS, SYMMETRY_MODES, decodeImageBlob, downloadBytes, quickStencil, timeLapseZip } from "@pixerate/editor/paint-editor";
|
|
347
|
-
|
|
348
|
-
// src/paint-editor/shared.tsx
|
|
349
|
-
import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
350
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
351
|
-
var chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
|
|
352
|
-
var button = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
|
|
353
|
-
var panel = "flex flex-col gap-2 text-xs text-slate-200";
|
|
354
|
-
var PixelCanvas = ({ pixels, label, className, style }) => {
|
|
355
|
-
const ref = useRef3(null);
|
|
356
|
-
useEffect3(() => {
|
|
357
|
-
const canvas = ref.current;
|
|
358
|
-
const ctx = canvas?.getContext("2d");
|
|
359
|
-
if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
|
|
360
|
-
canvas.width = pixels.width;
|
|
361
|
-
canvas.height = pixels.height;
|
|
362
|
-
const img = ctx.createImageData(pixels.width, pixels.height);
|
|
363
|
-
img.data.set(pixels.data);
|
|
364
|
-
ctx.putImageData(img, 0, 0);
|
|
365
|
-
}, [pixels]);
|
|
366
|
-
return /* @__PURE__ */ jsx2("canvas", { ref, role: "img", "aria-label": label, className, style, width: pixels?.width, height: pixels?.height });
|
|
367
|
-
};
|
|
368
|
-
var fmt = (c, v) => c.step >= 1 ? String(Math.round(v)) : v.toFixed(2);
|
|
369
|
-
var PaintSlider = ({ control, value, onChange, onCommit }) => {
|
|
370
|
-
const [draft, setDraft] = useState3(null);
|
|
371
|
-
const ref = useRef3(null);
|
|
372
|
-
const commit = useRef3(onCommit);
|
|
373
|
-
commit.current = onCommit;
|
|
374
|
-
useEffect3(() => {
|
|
375
|
-
const el = ref.current;
|
|
376
|
-
if (!el) return;
|
|
377
|
-
const done = () => {
|
|
378
|
-
commit.current?.(Number(el.value));
|
|
379
|
-
setDraft(null);
|
|
380
|
-
};
|
|
381
|
-
el.addEventListener("change", done);
|
|
382
|
-
return () => el.removeEventListener("change", done);
|
|
383
|
-
}, []);
|
|
384
|
-
const shown = draft ?? value;
|
|
385
|
-
return /* @__PURE__ */ jsxs2("label", { className: "flex flex-col gap-0.5", "data-path": control.path, children: [
|
|
386
|
-
/* @__PURE__ */ jsxs2("span", { className: "flex justify-between text-slate-400", children: [
|
|
387
|
-
/* @__PURE__ */ jsx2("span", { children: control.label }),
|
|
388
|
-
/* @__PURE__ */ jsx2("span", { className: "font-mono", children: fmt(control, shown) })
|
|
389
|
-
] }),
|
|
390
|
-
/* @__PURE__ */ jsx2(
|
|
391
|
-
"input",
|
|
392
|
-
{
|
|
393
|
-
ref,
|
|
394
|
-
type: "range",
|
|
395
|
-
"aria-label": control.label,
|
|
396
|
-
min: control.min,
|
|
397
|
-
max: control.max,
|
|
398
|
-
step: control.step,
|
|
399
|
-
value: shown,
|
|
400
|
-
onChange: (e) => {
|
|
401
|
-
const v = Number(e.target.value);
|
|
402
|
-
if (onCommit) setDraft(v);
|
|
403
|
-
onChange?.(v);
|
|
404
|
-
},
|
|
405
|
-
className: "w-full accent-indigo-500"
|
|
406
|
-
}
|
|
407
|
-
)
|
|
408
|
-
] });
|
|
409
|
-
};
|
|
410
|
-
function useAttempt() {
|
|
411
|
-
const [error, setError] = useState3(null);
|
|
412
|
-
const attempt = (fn) => {
|
|
413
|
-
try {
|
|
414
|
-
setError(null);
|
|
415
|
-
const r = fn();
|
|
416
|
-
if (r && typeof r.catch === "function") r.catch((e) => setError(e instanceof Error ? e.message : String(e)));
|
|
417
|
-
} catch (e) {
|
|
418
|
-
setError(e instanceof Error ? e.message : String(e));
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
return [error, attempt, setError];
|
|
422
|
-
}
|
|
423
|
-
var ErrorLine = ({ error }) => error ? /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-[11px] text-rose-400", children: error }) : null;
|
|
424
|
-
var CommitColorInput = ({ value, label, onCommit, className }) => {
|
|
425
|
-
const ref = useRef3(null);
|
|
426
|
-
const commit = useRef3(onCommit);
|
|
427
|
-
commit.current = onCommit;
|
|
428
|
-
useEffect3(() => {
|
|
429
|
-
const el = ref.current;
|
|
430
|
-
if (!el) return;
|
|
431
|
-
const done = () => commit.current(el.value);
|
|
432
|
-
el.addEventListener("change", done);
|
|
433
|
-
return () => el.removeEventListener("change", done);
|
|
434
|
-
}, []);
|
|
435
|
-
return /* @__PURE__ */ jsx2("input", { ref, type: "color", "aria-label": label, defaultValue: value, className }, value);
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
// src/paint-editor/PaintToolbar.tsx
|
|
439
|
-
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
356
|
+
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
440
357
|
var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", className }) => {
|
|
441
358
|
const state = usePaintEditorState(controller);
|
|
442
359
|
const [error, attempt] = useAttempt();
|
|
443
|
-
const [busy, setBusy] =
|
|
444
|
-
const [note, setNote] =
|
|
445
|
-
const openRef =
|
|
446
|
-
const tracingRef =
|
|
447
|
-
const refRef =
|
|
360
|
+
const [busy, setBusy] = useState3(null);
|
|
361
|
+
const [note, setNote] = useState3(null);
|
|
362
|
+
const openRef = useRef3(null);
|
|
363
|
+
const tracingRef = useRef3(null);
|
|
364
|
+
const refRef = useRef3(null);
|
|
448
365
|
const { symmetry, perspective, tracing } = state.guides;
|
|
449
366
|
const { canvas } = state.document;
|
|
450
367
|
const exportImage = (format) => attempt(async () => downloadBytes(await controller.exportImage({ format }), `${fileName}.${format === "image/png" ? "png" : "jpg"}`, format));
|
|
451
|
-
return /* @__PURE__ */
|
|
452
|
-
PAINT_TOOLS.map((t) => /* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
455
|
-
/* @__PURE__ */
|
|
456
|
-
/* @__PURE__ */
|
|
457
|
-
/* @__PURE__ */
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
/* @__PURE__ */
|
|
460
|
-
/* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */
|
|
462
|
-
/* @__PURE__ */
|
|
368
|
+
return /* @__PURE__ */ jsxs2("div", { className: `flex flex-wrap items-center gap-1.5 text-xs text-slate-200 ${className ?? ""}`, role: "toolbar", "aria-label": "Paint toolbar", "data-testid": "paint-toolbar", children: [
|
|
369
|
+
PAINT_TOOLS.map((t) => /* @__PURE__ */ jsx2("button", { type: "button", "aria-pressed": tool === t.id, title: `${t.label} (${t.key.toUpperCase()})`, className: chip(tool === t.id), onClick: () => onToolChange(t.id), children: t.label }, t.id)),
|
|
370
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
371
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, disabled: !state.canUndo, title: state.undoLabel ? `Undo ${state.undoLabel}` : "Undo", onClick: () => controller.undo(), children: "Undo" }),
|
|
372
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, disabled: !state.canRedo, title: state.redoLabel ? `Redo ${state.redoLabel}` : "Redo", onClick: () => controller.redo(), children: "Redo" }),
|
|
373
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
374
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, "aria-label": "Rotate view left", onClick: () => controller.setView({ rotation: state.view.rotation - 15 }), children: "\u27F2" }),
|
|
375
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, "aria-label": "Rotate view right", onClick: () => controller.setView({ rotation: state.view.rotation + 15 }), children: "\u27F3" }),
|
|
376
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: chip(state.view.mirror), "aria-pressed": state.view.mirror, onClick: () => controller.setView({ mirror: !state.view.mirror }), children: "Mirror view" }),
|
|
377
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => controller.resetView(), children: "Reset view" }),
|
|
378
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
379
|
+
/* @__PURE__ */ jsxs2("label", { className: "flex items-center gap-1", children: [
|
|
463
380
|
"Symmetry",
|
|
464
|
-
/* @__PURE__ */
|
|
381
|
+
/* @__PURE__ */ jsx2(
|
|
465
382
|
"select",
|
|
466
383
|
{
|
|
467
384
|
"aria-label": "Symmetry",
|
|
468
385
|
value: symmetry.mode,
|
|
469
386
|
onChange: (e) => controller.setSymmetry({ mode: e.target.value, center: symmetry.mode === "off" ? { x: canvas.width / 2, y: canvas.height / 2 } : symmetry.center }),
|
|
470
387
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
471
|
-
children: SYMMETRY_MODES.map((m) => /* @__PURE__ */
|
|
388
|
+
children: SYMMETRY_MODES.map((m) => /* @__PURE__ */ jsx2("option", { value: m, children: m }, m))
|
|
472
389
|
}
|
|
473
390
|
)
|
|
474
391
|
] }),
|
|
475
|
-
symmetry.mode === "kaleidoscope" && /* @__PURE__ */
|
|
392
|
+
symmetry.mode === "kaleidoscope" && /* @__PURE__ */ jsx2(
|
|
476
393
|
"input",
|
|
477
394
|
{
|
|
478
395
|
type: "number",
|
|
@@ -484,7 +401,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
484
401
|
className: "w-12 rounded bg-slate-800 px-1 py-0.5"
|
|
485
402
|
}
|
|
486
403
|
),
|
|
487
|
-
/* @__PURE__ */
|
|
404
|
+
/* @__PURE__ */ jsx2(
|
|
488
405
|
"button",
|
|
489
406
|
{
|
|
490
407
|
type: "button",
|
|
@@ -498,7 +415,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
498
415
|
children: "Perspective"
|
|
499
416
|
}
|
|
500
417
|
),
|
|
501
|
-
perspective.enabled && /* @__PURE__ */
|
|
418
|
+
perspective.enabled && /* @__PURE__ */ jsxs2(
|
|
502
419
|
"select",
|
|
503
420
|
{
|
|
504
421
|
"aria-label": "Vanishing points",
|
|
@@ -511,16 +428,16 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
511
428
|
},
|
|
512
429
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
513
430
|
children: [
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
/* @__PURE__ */
|
|
516
|
-
/* @__PURE__ */
|
|
431
|
+
/* @__PURE__ */ jsx2("option", { value: 1, children: "1-point" }),
|
|
432
|
+
/* @__PURE__ */ jsx2("option", { value: 2, children: "2-point" }),
|
|
433
|
+
/* @__PURE__ */ jsx2("option", { value: 3, children: "3-point" })
|
|
517
434
|
]
|
|
518
435
|
}
|
|
519
436
|
),
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
tracing && /* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
438
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => tracingRef.current?.click(), children: "Tracing image\u2026" }),
|
|
439
|
+
tracing && /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
440
|
+
/* @__PURE__ */ jsx2(
|
|
524
441
|
"input",
|
|
525
442
|
{
|
|
526
443
|
type: "range",
|
|
@@ -533,25 +450,25 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
533
450
|
className: "w-16 accent-indigo-500"
|
|
534
451
|
}
|
|
535
452
|
),
|
|
536
|
-
/* @__PURE__ */
|
|
537
|
-
/* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: chip(tracing.sampleColors), "aria-pressed": tracing.sampleColors, onClick: () => controller.updateTracing({ sampleColors: !tracing.sampleColors }), children: "Trace colours" }),
|
|
454
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: chip(tracing.visible), "aria-pressed": tracing.visible, onClick: () => controller.updateTracing({ visible: !tracing.visible }), children: "Show tracing" }),
|
|
455
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => controller.clearTracingImage(), children: "Remove tracing" })
|
|
539
456
|
] }),
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
/* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
/* @__PURE__ */
|
|
544
|
-
/* @__PURE__ */
|
|
545
|
-
state.guides.stencils.length > 0 && /* @__PURE__ */
|
|
457
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => refRef.current?.click(), children: "Reference\u2026" }),
|
|
458
|
+
/* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-1", role: "group", "aria-label": "Stencils", children: [
|
|
459
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, title: "A ruler: strokes that start near it follow it", onClick: () => attempt(() => controller.addStencil(quickStencil("ruler", canvas))), children: "Ruler" }),
|
|
460
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, title: "A circle guide: strokes that start near it follow it", onClick: () => attempt(() => controller.addStencil(quickStencil("circle", canvas))), children: "Circle" }),
|
|
461
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, title: "An ellipse mask: paint lands only inside it", onClick: () => attempt(() => controller.addStencil(quickStencil("ellipse-mask", canvas))), children: "Mask" }),
|
|
462
|
+
state.guides.stencils.length > 0 && /* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => attempt(() => controller.removeStencils()), children: "Clear stencils" })
|
|
546
463
|
] }),
|
|
547
|
-
/* @__PURE__ */
|
|
548
|
-
/* @__PURE__ */
|
|
549
|
-
/* @__PURE__ */
|
|
550
|
-
/* @__PURE__ */
|
|
551
|
-
/* @__PURE__ */
|
|
552
|
-
/* @__PURE__ */
|
|
553
|
-
/* @__PURE__ */
|
|
554
|
-
/* @__PURE__ */
|
|
464
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, title: "Which hand holds the pen (palm rejection)", onClick: () => controller.setHand(state.hand === "right" ? "left" : "right"), children: state.hand === "right" ? "Right-handed" : "Left-handed" }),
|
|
465
|
+
/* @__PURE__ */ jsx2("span", { className: "mx-1 h-4 w-px bg-slate-700" }),
|
|
466
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => attempt(() => downloadBytes(JSON.stringify(controller.toJSON()), `${fileName}.paint.json`, "application/json")), children: "Save" }),
|
|
467
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => openRef.current?.click(), children: "Open\u2026" }),
|
|
468
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => exportImage("image/png"), children: "PNG" }),
|
|
469
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => exportImage("image/jpeg"), children: "JPEG" }),
|
|
470
|
+
/* @__PURE__ */ jsx2("button", { type: "button", className: button, onClick: () => attempt(() => downloadBytes(controller.exportPsd().bytes, `${fileName}.psd`, "image/vnd.adobe.photoshop")), children: "PSD" }),
|
|
471
|
+
/* @__PURE__ */ jsx2(
|
|
555
472
|
"button",
|
|
556
473
|
{
|
|
557
474
|
type: "button",
|
|
@@ -571,7 +488,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
571
488
|
children: "Time-lapse"
|
|
572
489
|
}
|
|
573
490
|
),
|
|
574
|
-
/* @__PURE__ */
|
|
491
|
+
/* @__PURE__ */ jsx2(
|
|
575
492
|
"button",
|
|
576
493
|
{
|
|
577
494
|
type: "button",
|
|
@@ -589,8 +506,8 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
589
506
|
children: "PNG 2\xD7"
|
|
590
507
|
}
|
|
591
508
|
),
|
|
592
|
-
(busy ?? note) && /* @__PURE__ */
|
|
593
|
-
/* @__PURE__ */
|
|
509
|
+
(busy ?? note) && /* @__PURE__ */ jsx2("span", { className: "text-[11px] text-slate-400", "data-testid": "paint-replay-status", children: busy ?? note }),
|
|
510
|
+
/* @__PURE__ */ jsx2(
|
|
594
511
|
"input",
|
|
595
512
|
{
|
|
596
513
|
ref: openRef,
|
|
@@ -605,7 +522,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
605
522
|
}
|
|
606
523
|
}
|
|
607
524
|
),
|
|
608
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ jsx2(
|
|
609
526
|
"input",
|
|
610
527
|
{
|
|
611
528
|
ref: tracingRef,
|
|
@@ -620,7 +537,7 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
620
537
|
}
|
|
621
538
|
}
|
|
622
539
|
),
|
|
623
|
-
/* @__PURE__ */
|
|
540
|
+
/* @__PURE__ */ jsx2(
|
|
624
541
|
"input",
|
|
625
542
|
{
|
|
626
543
|
ref: refRef,
|
|
@@ -635,148 +552,35 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
635
552
|
}
|
|
636
553
|
}
|
|
637
554
|
),
|
|
638
|
-
/* @__PURE__ */
|
|
555
|
+
/* @__PURE__ */ jsx2(ErrorLine, { error })
|
|
639
556
|
] });
|
|
640
557
|
};
|
|
641
558
|
|
|
642
559
|
// src/paint-editor/BrushPanel.tsx
|
|
643
|
-
import { useMemo as
|
|
560
|
+
import { useMemo as useMemo3, useRef as useRef4 } from "react";
|
|
644
561
|
import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
|
|
645
|
-
import { brushColourHex, PAINT_PROFILE
|
|
646
|
-
|
|
647
|
-
// src/paint-editor/BrushEditor.tsx
|
|
648
|
-
import { useMemo as useMemo3, useState as useState5 } from "react";
|
|
649
|
-
import { brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
|
|
650
|
-
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
651
|
-
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSaveAs, renderExtra, className }) => {
|
|
652
|
-
const sections = useMemo3(() => brushEditorSections(brush, profile), [brush, profile]);
|
|
653
|
-
const [problems, setProblems] = useState5(null);
|
|
654
|
-
const [name, setName] = useState5("");
|
|
655
|
-
const set = (path, value) => {
|
|
656
|
-
const r = setBrushEditorValue(brush, path, value);
|
|
657
|
-
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
658
|
-
if (r.brush !== brush) onChange(r.brush);
|
|
659
|
-
};
|
|
660
|
-
return /* @__PURE__ */ jsxs4("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
661
|
-
preview !== void 0 && /* @__PURE__ */ jsx4(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
662
|
-
sections.map((s) => /* @__PURE__ */ jsxs4("section", { className: "flex flex-col gap-1.5", "data-section": s.id, ...s.id === "behaviour" ? { "data-testid": "brush-engine" } : {}, children: [
|
|
663
|
-
/* @__PURE__ */ jsx4("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
664
|
-
s.controls.map((c) => /* @__PURE__ */ jsx4(EditorControl, { control: c, onSet: set }, c.path)),
|
|
665
|
-
renderExtra?.(s.id)
|
|
666
|
-
] }, s.id)),
|
|
667
|
-
onSaveAs && /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
668
|
-
/* @__PURE__ */ jsx4("input", { value: name, placeholder: "Brush name", "aria-label": "Brush name", onChange: (e) => setName(e.target.value), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
669
|
-
/* @__PURE__ */ jsx4(
|
|
670
|
-
"button",
|
|
671
|
-
{
|
|
672
|
-
type: "button",
|
|
673
|
-
className: button,
|
|
674
|
-
disabled: !name.trim(),
|
|
675
|
-
onClick: async () => {
|
|
676
|
-
try {
|
|
677
|
-
await onSaveAs(name.trim());
|
|
678
|
-
setName("");
|
|
679
|
-
setProblems(null);
|
|
680
|
-
} catch (e) {
|
|
681
|
-
setProblems(e.message);
|
|
682
|
-
}
|
|
683
|
-
},
|
|
684
|
-
children: "Save brush"
|
|
685
|
-
}
|
|
686
|
-
)
|
|
687
|
-
] }),
|
|
688
|
-
/* @__PURE__ */ jsx4(ErrorLine, { error: problems })
|
|
689
|
-
] });
|
|
690
|
-
};
|
|
691
|
-
var EditorControl = ({ control: c, onSet }) => {
|
|
692
|
-
const note = c.note ? /* @__PURE__ */ jsx4("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
693
|
-
switch (c.kind) {
|
|
694
|
-
case "slider":
|
|
695
|
-
return /* @__PURE__ */ jsxs4("div", { title: c.note, children: [
|
|
696
|
-
/* @__PURE__ */ jsx4(PaintSlider, { control: c, value: c.value, onChange: (v) => onSet(c.path, v) }),
|
|
697
|
-
note
|
|
698
|
-
] });
|
|
699
|
-
case "choice":
|
|
700
|
-
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center justify-between gap-2", title: c.note, children: [
|
|
701
|
-
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
702
|
-
/* @__PURE__ */ jsx4("select", { "aria-label": c.ariaLabel, value: c.value, onChange: (e) => onSet(c.path, e.target.value), className: "max-w-[60%] rounded bg-slate-800 px-1 py-0.5", children: c.options.map((o) => /* @__PURE__ */ jsx4("option", { value: o.value, children: o.label }, o.value)) })
|
|
703
|
-
] });
|
|
704
|
-
case "toggle":
|
|
705
|
-
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", title: c.note, children: [
|
|
706
|
-
/* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": c.ariaLabel, checked: c.value, onChange: (e) => onSet(c.path, e.target.checked) }),
|
|
707
|
-
" ",
|
|
708
|
-
c.label
|
|
709
|
-
] });
|
|
710
|
-
case "text":
|
|
711
|
-
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center justify-between gap-2", children: [
|
|
712
|
-
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
713
|
-
/* @__PURE__ */ jsx4("input", { "aria-label": c.ariaLabel, defaultValue: c.value, placeholder: c.placeholder, onBlur: (e) => e.target.value !== c.value && onSet(c.path, e.target.value.trim().toLowerCase()), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }, c.value)
|
|
714
|
-
] });
|
|
715
|
-
case "colour": {
|
|
716
|
-
const set = (light, dark) => onSet(c.path, dark === null ? light : { light, dark });
|
|
717
|
-
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", children: [
|
|
718
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
|
|
719
|
-
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
720
|
-
/* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
|
|
721
|
-
/* @__PURE__ */ jsx4("input", { type: "color", "aria-label": c.ariaLabel, title: c.dark !== null ? "On light backgrounds" : void 0, value: c.value ?? "#000000", onChange: (e) => set(e.target.value, c.dark), className: "h-5 w-8" }),
|
|
722
|
-
c.dark !== null && /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `${c.ariaLabel} (dark)`, title: "On dark backgrounds", value: c.dark, onChange: (e) => set(c.value ?? "#000000", e.target.value), className: "h-5 w-8" }),
|
|
723
|
-
(c.value || c.gradient) && /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
|
|
724
|
-
] })
|
|
725
|
-
] }),
|
|
726
|
-
c.gradient ? /* @__PURE__ */ jsx4("span", { className: "text-[10px] text-slate-500", children: "A gradient (its own paint)." }) : /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", children: [
|
|
727
|
-
/* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": `${c.ariaLabel}: light and dark`, checked: c.dark !== null, onChange: (e) => set(c.value ?? "#000000", e.target.checked ? c.value ?? "#ffffff" : null) }),
|
|
728
|
-
" Light / dark"
|
|
729
|
-
] })
|
|
730
|
-
] });
|
|
731
|
-
}
|
|
732
|
-
case "palette": {
|
|
733
|
-
const at = (i, entry) => onSet(c.path, c.value.map((x, j) => j === i ? entry : x));
|
|
734
|
-
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1", role: "group", "aria-label": c.ariaLabel, children: [
|
|
735
|
-
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
736
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
737
|
-
c.value.map((col, i) => {
|
|
738
|
-
const light = typeof col === "string" ? col : col.light;
|
|
739
|
-
return /* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-0.5 rounded bg-slate-900 p-0.5", children: [
|
|
740
|
-
/* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `Palette colour ${i + 1}`, value: light, onChange: (e) => at(i, typeof col === "string" ? e.target.value : { ...col, light: e.target.value }), className: "h-4 w-5" }),
|
|
741
|
-
typeof col !== "string" && /* @__PURE__ */ jsx4("input", { type: "color", "aria-label": `Palette colour ${i + 1} (dark)`, value: col.dark, onChange: (e) => at(i, { ...col, dark: e.target.value }), className: "h-4 w-5" }),
|
|
742
|
-
/* @__PURE__ */ jsx4("button", { type: "button", "aria-label": `Remove palette colour ${i + 1}`, className: "px-0.5 text-slate-400 hover:text-white", onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)), children: "\xD7" })
|
|
743
|
-
] }, i);
|
|
744
|
-
}),
|
|
745
|
-
c.value.length < c.max && /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
746
|
-
/* @__PURE__ */ jsx4("input", { type: "color", "aria-label": "Add a palette colour", onChange: (e) => onSet(c.path, [...c.value, e.target.value]), className: "h-4 w-6" }),
|
|
747
|
-
/* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, [...c.value, { light: "#334155", dark: "#e2e8f0" }]), children: "Add light / dark pair" })
|
|
748
|
-
] })
|
|
749
|
-
] })
|
|
750
|
-
] });
|
|
751
|
-
}
|
|
752
|
-
case "stamps":
|
|
753
|
-
return /* @__PURE__ */ jsx4("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": c.ariaLabel, title: `Up to ${c.max}`, children: c.options.map((o) => {
|
|
754
|
-
const on = c.value.includes(o.value);
|
|
755
|
-
return /* @__PURE__ */ jsx4("button", { type: "button", "aria-pressed": on, className: chip(on), onClick: () => onSet(c.path, on ? c.value.filter((v) => v !== o.value) : [...c.value, o.value].slice(-c.max)), children: o.label }, o.value);
|
|
756
|
-
}) });
|
|
757
|
-
}
|
|
758
|
-
};
|
|
562
|
+
import { brushColourHex, PAINT_PROFILE } from "@pixerate/editor/brushes";
|
|
759
563
|
|
|
760
564
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
761
565
|
import { PAINT_GRADIENT_KIT } from "@pixerate/editor/paint-editor";
|
|
762
|
-
import { jsx as
|
|
763
|
-
var PaintGradientEditor = (props) => /* @__PURE__ */
|
|
566
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
567
|
+
var PaintGradientEditor = (props) => /* @__PURE__ */ jsx3(PaintGradientEditorView, { ...props, kit: PAINT_GRADIENT_KIT });
|
|
764
568
|
|
|
765
569
|
// src/paint-editor/StickerPicker.tsx
|
|
766
|
-
import { useEffect as
|
|
767
|
-
import { jsx as
|
|
570
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
571
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
768
572
|
var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
769
|
-
const [provider, setProvider] =
|
|
770
|
-
|
|
573
|
+
const [provider, setProvider] = useState4(() => controller.stickersProvider);
|
|
574
|
+
useEffect3(() => controller.stickers.subscribe(setProvider), [controller]);
|
|
771
575
|
const failed = selected.map((ref) => ({ ref, ...controller.stickerArtStatus(ref) })).filter((x) => x.status === "failed");
|
|
772
|
-
return /* @__PURE__ */
|
|
576
|
+
return /* @__PURE__ */ jsx4(
|
|
773
577
|
StickerLibraryPicker,
|
|
774
578
|
{
|
|
775
579
|
provider,
|
|
776
580
|
selected,
|
|
777
581
|
label,
|
|
778
582
|
onPick: (it) => onPick(it.ref),
|
|
779
|
-
footer: failed.map((f) => /* @__PURE__ */
|
|
583
|
+
footer: failed.map((f) => /* @__PURE__ */ jsxs3("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
780
584
|
f.ref,
|
|
781
585
|
": ",
|
|
782
586
|
f.error
|
|
@@ -786,70 +590,70 @@ var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
|
786
590
|
};
|
|
787
591
|
|
|
788
592
|
// src/paint-editor/BrushPanel.tsx
|
|
789
|
-
import { Fragment as
|
|
593
|
+
import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
790
594
|
var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
791
595
|
const state = usePaintEditorState(controller);
|
|
792
596
|
const [error, attempt] = useAttempt();
|
|
793
|
-
const fileRef =
|
|
597
|
+
const fileRef = useRef4(null);
|
|
794
598
|
const { brush, brushes } = state;
|
|
795
599
|
const paper = state.document.paper;
|
|
796
|
-
const thumbs =
|
|
600
|
+
const thumbs = useMemo3(
|
|
797
601
|
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: "#26324a" })])),
|
|
798
602
|
// Thumbnails follow the library and the paper.
|
|
799
603
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
800
604
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
801
605
|
);
|
|
802
|
-
const entries =
|
|
803
|
-
const spec =
|
|
606
|
+
const entries = useMemo3(() => brushes.map((b) => ({ brush: controller.getBrushSpec(b.id), builtin: Boolean(b.builtin) })), [controller, brushes]);
|
|
607
|
+
const spec = useMemo3(() => controller.getBrushSpec(), [controller, brush]);
|
|
804
608
|
const own = typeof spec.colour?.default === "string" && /^#[0-9a-f]{6}/i.test(spec.colour.default) ? spec.colour.default.slice(0, 7) : void 0;
|
|
805
|
-
const preview =
|
|
609
|
+
const preview = useMemo3(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
|
|
806
610
|
const carried = brushLoadColor(state.mixerLoad);
|
|
807
611
|
const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
|
|
808
612
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
809
613
|
const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
|
|
810
|
-
return /* @__PURE__ */
|
|
811
|
-
/* @__PURE__ */
|
|
812
|
-
/* @__PURE__ */
|
|
614
|
+
return /* @__PURE__ */ jsxs4("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
615
|
+
/* @__PURE__ */ jsx5(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
616
|
+
/* @__PURE__ */ jsx5(
|
|
813
617
|
BrushEditor,
|
|
814
618
|
{
|
|
815
619
|
brush: spec,
|
|
816
|
-
profile:
|
|
620
|
+
profile: PAINT_PROFILE,
|
|
817
621
|
preview,
|
|
818
622
|
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
819
623
|
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
820
624
|
renderExtra: (section) => {
|
|
821
625
|
if (section === "shape" && brush.engine === "sticker")
|
|
822
|
-
return /* @__PURE__ */
|
|
626
|
+
return /* @__PURE__ */ jsx5(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
|
|
823
627
|
if (section === "behaviour" && loads)
|
|
824
|
-
return /* @__PURE__ */
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
827
|
-
brush.engine === "mixer" && /* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
628
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
629
|
+
/* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "Carries" }),
|
|
630
|
+
/* @__PURE__ */ jsx5("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
631
|
+
brush.engine === "mixer" && /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
632
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
829
633
|
] });
|
|
830
634
|
if (section === "colour")
|
|
831
|
-
return /* @__PURE__ */
|
|
832
|
-
palette.length > 0 && /* @__PURE__ */
|
|
833
|
-
/* @__PURE__ */
|
|
834
|
-
/* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
636
|
+
palette.length > 0 && /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": "Paint with a palette colour", children: palette.map((hex, i) => /* @__PURE__ */ jsx5("button", { type: "button", "aria-label": `Paint with ${hex}`, title: hex, "aria-pressed": state.color === hex, className: `h-5 w-5 rounded ring-1 ${state.color === hex ? "ring-white" : "ring-slate-700"}`, style: { background: hex }, onClick: () => controller.setColor(hex) }, `${hex}-${i}`)) }),
|
|
637
|
+
/* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", title: "Choosing a brush with a default colour (the highlighter's yellow) makes it your colour unless this is on", children: [
|
|
638
|
+
/* @__PURE__ */ jsx5("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
|
|
835
639
|
" Keep my colour when choosing a brush"
|
|
836
640
|
] }),
|
|
837
|
-
brushTakesPaint(brush) && /* @__PURE__ */
|
|
838
|
-
/* @__PURE__ */
|
|
839
|
-
/* @__PURE__ */
|
|
840
|
-
/* @__PURE__ */
|
|
641
|
+
brushTakesPaint(brush) && /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
642
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
|
|
643
|
+
/* @__PURE__ */ jsx5("span", { className: "text-slate-400", title: "A gradient of the brush's own, used instead of the paint (the multi-colour brush)", children: "Brush gradient" }),
|
|
644
|
+
/* @__PURE__ */ jsx5("button", { type: "button", "aria-pressed": brush.paint !== null, className: chip(brush.paint !== null), onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : DEFAULT_PAINT_GRADIENT })), children: brush.paint ? "On" : "Off" })
|
|
841
645
|
] }),
|
|
842
|
-
brush.paint && /* @__PURE__ */
|
|
646
|
+
brush.paint && /* @__PURE__ */ jsx5(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
843
647
|
] })
|
|
844
648
|
] });
|
|
845
649
|
return null;
|
|
846
650
|
}
|
|
847
651
|
}
|
|
848
652
|
),
|
|
849
|
-
/* @__PURE__ */
|
|
850
|
-
/* @__PURE__ */
|
|
851
|
-
/* @__PURE__ */
|
|
852
|
-
/* @__PURE__ */
|
|
653
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
654
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => attempt(async () => downloadBytes2(JSON.stringify(await controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
655
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
656
|
+
/* @__PURE__ */ jsx5(
|
|
853
657
|
"input",
|
|
854
658
|
{
|
|
855
659
|
ref: fileRef,
|
|
@@ -865,24 +669,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
865
669
|
}
|
|
866
670
|
)
|
|
867
671
|
] }),
|
|
868
|
-
/* @__PURE__ */
|
|
672
|
+
/* @__PURE__ */ jsx5(ErrorLine, { error })
|
|
869
673
|
] });
|
|
870
674
|
};
|
|
871
675
|
|
|
872
676
|
// src/paint-editor/PaperPanel.tsx
|
|
873
|
-
import { useMemo as
|
|
677
|
+
import { useMemo as useMemo4 } from "react";
|
|
874
678
|
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath, readPath, renderPaper } from "@pixerate/editor/paint-editor";
|
|
875
|
-
import { jsx as
|
|
679
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
876
680
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
877
681
|
var PaperPanel = ({ controller, className }) => {
|
|
878
682
|
const state = usePaintEditorState(controller);
|
|
879
683
|
const [error, attempt] = useAttempt();
|
|
880
684
|
const paper = state.document.paper;
|
|
881
|
-
const previews =
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
/* @__PURE__ */
|
|
685
|
+
const previews = useMemo4(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
686
|
+
return /* @__PURE__ */ jsxs5("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
687
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs5("div", { children: [
|
|
688
|
+
/* @__PURE__ */ jsx6("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
689
|
+
/* @__PURE__ */ jsx6("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ jsx6(
|
|
886
690
|
"button",
|
|
887
691
|
{
|
|
888
692
|
type: "button",
|
|
@@ -891,37 +695,37 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
891
695
|
title: p.name,
|
|
892
696
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
893
697
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
894
|
-
children: /* @__PURE__ */
|
|
698
|
+
children: /* @__PURE__ */ jsx6(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
895
699
|
},
|
|
896
700
|
p.preset
|
|
897
701
|
)) })
|
|
898
702
|
] }, family)),
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
/* @__PURE__ */
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ jsx6("div", { className: "text-slate-300", children: paper.name }),
|
|
704
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between", children: [
|
|
705
|
+
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Colour" }),
|
|
706
|
+
/* @__PURE__ */ jsx6(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
903
707
|
] }),
|
|
904
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
905
|
-
/* @__PURE__ */
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
/* @__PURE__ */
|
|
708
|
+
PAPER_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper(patchPath(paper, c.path, v))) }, c.path)),
|
|
709
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between", children: [
|
|
710
|
+
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
711
|
+
/* @__PURE__ */ jsx6(CommitColorInput, { label: "Backlight colour", value: paper.backlightColor ?? DEFAULT_BACKLIGHT_COLOR, onCommit: (v) => attempt(() => controller.setPaper({ backlightColor: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
908
712
|
] }),
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
713
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", children: [
|
|
714
|
+
/* @__PURE__ */ jsx6("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
911
715
|
" Mirror tiling"
|
|
912
716
|
] }),
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
917
|
-
/* @__PURE__ */
|
|
717
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
|
|
718
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
719
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
720
|
+
LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
721
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
|
|
918
722
|
] }),
|
|
919
|
-
/* @__PURE__ */
|
|
723
|
+
/* @__PURE__ */ jsx6(ErrorLine, { error })
|
|
920
724
|
] });
|
|
921
725
|
};
|
|
922
726
|
|
|
923
727
|
// src/paint-editor/ColorPanel.tsx
|
|
924
|
-
import { useMemo as
|
|
728
|
+
import { useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
|
|
925
729
|
import {
|
|
926
730
|
HARMONY_KINDS,
|
|
927
731
|
MIXING_PAD_HEIGHT,
|
|
@@ -938,24 +742,24 @@ import {
|
|
|
938
742
|
wheelPoint
|
|
939
743
|
} from "@pixerate/editor/paint-editor";
|
|
940
744
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
941
|
-
import { jsx as
|
|
745
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
942
746
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
943
747
|
const state = usePaintEditorState(controller);
|
|
944
748
|
const [error, attempt] = useAttempt();
|
|
945
|
-
const [wheel, setWheel] =
|
|
946
|
-
const [kind, setKind] =
|
|
947
|
-
const [padTool, setPadTool] =
|
|
948
|
-
const [sample, setSample] =
|
|
949
|
-
const [parts, setParts] =
|
|
950
|
-
const [padName, setPadName] =
|
|
951
|
-
const padPoints =
|
|
952
|
-
const ring =
|
|
749
|
+
const [wheel, setWheel] = useState5("ryb");
|
|
750
|
+
const [kind, setKind] = useState5("complementary");
|
|
751
|
+
const [padTool, setPadTool] = useState5("paint");
|
|
752
|
+
const [sample, setSample] = useState5(3);
|
|
753
|
+
const [parts, setParts] = useState5([1, 1]);
|
|
754
|
+
const [padName, setPadName] = useState5("");
|
|
755
|
+
const padPoints = useRef5(null);
|
|
756
|
+
const ring = useMemo5(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
953
757
|
const color = state.color;
|
|
954
|
-
const harmony =
|
|
758
|
+
const harmony = useMemo5(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
955
759
|
const [r, g, b] = parseHexColor(color);
|
|
956
760
|
const hsv = rgbToHsv(r, g, b);
|
|
957
|
-
const effectWell =
|
|
958
|
-
const pad =
|
|
761
|
+
const effectWell = useMemo5(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
762
|
+
const pad = useMemo5(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
959
763
|
const R = wheelSize / 2;
|
|
960
764
|
const mid = R * 0.82;
|
|
961
765
|
const setHsv = (s, v) => controller.setColor(rgbToHexColor(...hsvToRgb(hsv.h, s, v)));
|
|
@@ -967,9 +771,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
967
771
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
968
772
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
969
773
|
};
|
|
970
|
-
return /* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
774
|
+
return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
775
|
+
/* @__PURE__ */ jsxs6("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
776
|
+
/* @__PURE__ */ jsx7(
|
|
973
777
|
"div",
|
|
974
778
|
{
|
|
975
779
|
role: "slider",
|
|
@@ -983,20 +787,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
983
787
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
984
788
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
985
789
|
},
|
|
986
|
-
children: /* @__PURE__ */
|
|
790
|
+
children: /* @__PURE__ */ jsx7(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
987
791
|
}
|
|
988
792
|
),
|
|
989
|
-
/* @__PURE__ */
|
|
793
|
+
/* @__PURE__ */ jsx7("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
990
794
|
const p = wheelPoint(h.angle, mid);
|
|
991
|
-
return /* @__PURE__ */
|
|
795
|
+
return /* @__PURE__ */ jsx7("circle", { cx: R + p.x, cy: R + p.y, r: i === 0 ? 7 : 5, fill: h.color, stroke: "#fff", strokeWidth: i === 0 ? 2 : 1 }, i);
|
|
992
796
|
}) }),
|
|
993
|
-
/* @__PURE__ */
|
|
797
|
+
/* @__PURE__ */ jsx7("div", { className: "absolute rounded-full border border-slate-700", style: { left: R - R * 0.45, top: R - R * 0.45, width: R * 0.9, height: R * 0.9, background: color } })
|
|
994
798
|
] }),
|
|
995
|
-
/* @__PURE__ */
|
|
996
|
-
/* @__PURE__ */
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */
|
|
799
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
800
|
+
/* @__PURE__ */ jsx7("input", { type: "color", "aria-label": "Paint colour", value: color, onChange: (e) => controller.setColor(e.target.value), className: "h-7 w-9 rounded bg-transparent" }),
|
|
801
|
+
/* @__PURE__ */ jsx7("input", { type: "color", "aria-label": "Second colour", value: state.secondaryColor, onChange: (e) => controller.setSecondaryColor(e.target.value), className: "h-5 w-7 rounded bg-transparent" }),
|
|
802
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
803
|
+
/* @__PURE__ */ jsx7(
|
|
1000
804
|
"input",
|
|
1001
805
|
{
|
|
1002
806
|
"aria-label": "Hex colour",
|
|
@@ -1007,8 +811,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1007
811
|
color
|
|
1008
812
|
)
|
|
1009
813
|
] }),
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
815
|
+
/* @__PURE__ */ jsx7(
|
|
1012
816
|
"span",
|
|
1013
817
|
{
|
|
1014
818
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -1018,7 +822,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1018
822
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1019
823
|
}
|
|
1020
824
|
),
|
|
1021
|
-
/* @__PURE__ */
|
|
825
|
+
/* @__PURE__ */ jsx7(
|
|
1022
826
|
"button",
|
|
1023
827
|
{
|
|
1024
828
|
type: "button",
|
|
@@ -1030,26 +834,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1030
834
|
}
|
|
1031
835
|
)
|
|
1032
836
|
] }),
|
|
1033
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
837
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
838
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
839
|
+
/* @__PURE__ */ jsx7("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
840
|
+
/* @__PURE__ */ jsx7("input", { type: "range", "aria-label": "Saturation", min: 0, max: 1, step: 0.01, value: hsv.s, onChange: (e) => setHsv(Number(e.target.value), hsv.v), className: "flex-1 accent-indigo-500" })
|
|
1037
841
|
] }),
|
|
1038
|
-
/* @__PURE__ */
|
|
1039
|
-
/* @__PURE__ */
|
|
1040
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
843
|
+
/* @__PURE__ */ jsx7("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
844
|
+
/* @__PURE__ */ jsx7("input", { type: "range", "aria-label": "Value", min: 0, max: 1, step: 0.01, value: hsv.v, onChange: (e) => setHsv(hsv.s, Number(e.target.value)), className: "flex-1 accent-indigo-500" })
|
|
1041
845
|
] }),
|
|
1042
|
-
/* @__PURE__ */
|
|
1043
|
-
/* @__PURE__ */
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
/* @__PURE__ */
|
|
846
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
|
|
847
|
+
/* @__PURE__ */ jsx7("select", { "aria-label": "Harmony", value: kind, onChange: (e) => setKind(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: HARMONY_KINDS.map((k) => /* @__PURE__ */ jsx7("option", { value: k, children: k }, k)) }),
|
|
848
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
849
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1046
850
|
] }),
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
851
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
852
|
+
harmony.map((h, i) => /* @__PURE__ */ jsx7("button", { type: "button", "aria-label": `Use ${h.color}`, title: h.color, className: "h-6 w-6 rounded ring-1 ring-slate-700", style: { background: h.color }, onClick: () => controller.setColor(h.color) }, i)),
|
|
853
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1050
854
|
] }),
|
|
1051
|
-
/* @__PURE__ */
|
|
1052
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
856
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx7(
|
|
1053
857
|
"button",
|
|
1054
858
|
{
|
|
1055
859
|
type: "button",
|
|
@@ -1067,15 +871,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1067
871
|
},
|
|
1068
872
|
i
|
|
1069
873
|
)),
|
|
1070
|
-
/* @__PURE__ */
|
|
874
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1071
875
|
] }),
|
|
1072
|
-
mixingPad && /* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1076
|
-
/* @__PURE__ */
|
|
876
|
+
mixingPad && /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
877
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
|
|
878
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
879
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ jsx7("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
880
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1077
881
|
] }),
|
|
1078
|
-
/* @__PURE__ */
|
|
882
|
+
/* @__PURE__ */ jsx7(
|
|
1079
883
|
"div",
|
|
1080
884
|
{
|
|
1081
885
|
role: "application",
|
|
@@ -1096,20 +900,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1096
900
|
padPoints.current = null;
|
|
1097
901
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1098
902
|
},
|
|
1099
|
-
children: /* @__PURE__ */
|
|
903
|
+
children: /* @__PURE__ */ jsx7(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1100
904
|
}
|
|
1101
905
|
),
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */
|
|
1104
|
-
/* @__PURE__ */
|
|
906
|
+
/* @__PURE__ */ jsx7("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-1", children: [
|
|
907
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Sample" }),
|
|
908
|
+
/* @__PURE__ */ jsx7("select", { "aria-label": "Pick sample size", value: sample, onChange: (e) => setSample(Number(e.target.value)), className: "rounded bg-slate-800 px-1 py-0.5", children: PAD_SAMPLE_SIZES.map((n) => /* @__PURE__ */ jsx7("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1105
909
|
] }) }),
|
|
1106
|
-
/* @__PURE__ */
|
|
1107
|
-
/* @__PURE__ */
|
|
1108
|
-
/* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
911
|
+
/* @__PURE__ */ jsx7("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
912
|
+
/* @__PURE__ */ jsx7("input", { type: "number", "aria-label": "Paint colour parts", min: 0, max: 20, value: parts[0], onChange: (e) => setParts([Number(e.target.value), parts[1]]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
913
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-500", children: ":" }),
|
|
914
|
+
/* @__PURE__ */ jsx7("input", { type: "number", "aria-label": "Second colour parts", min: 0, max: 20, value: parts[1], onChange: (e) => setParts([parts[0], Number(e.target.value)]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
915
|
+
/* @__PURE__ */ jsx7("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
916
|
+
/* @__PURE__ */ jsx7(
|
|
1113
917
|
"button",
|
|
1114
918
|
{
|
|
1115
919
|
type: "button",
|
|
@@ -1128,23 +932,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1128
932
|
}
|
|
1129
933
|
)
|
|
1130
934
|
] }),
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1133
|
-
/* @__PURE__ */
|
|
935
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
936
|
+
/* @__PURE__ */ jsx7("input", { value: padName, placeholder: "Pad name", "aria-label": "Pad name", onChange: (e) => setPadName(e.target.value), className: "w-24 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
937
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1134
938
|
] }),
|
|
1135
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
939
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ jsx7("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ jsxs6("li", { className: "flex items-center gap-1", children: [
|
|
940
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
941
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1138
942
|
] }, p.id)) })
|
|
1139
943
|
] }),
|
|
1140
|
-
/* @__PURE__ */
|
|
944
|
+
/* @__PURE__ */ jsx7(ErrorLine, { error })
|
|
1141
945
|
] });
|
|
1142
946
|
};
|
|
1143
947
|
|
|
1144
948
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1145
|
-
import { useState as
|
|
949
|
+
import { useState as useState6 } from "react";
|
|
1146
950
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1147
|
-
import { jsx as
|
|
951
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1148
952
|
function siblingIndex(layers, l) {
|
|
1149
953
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1150
954
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1152,7 +956,7 @@ function siblingIndex(layers, l) {
|
|
|
1152
956
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1153
957
|
usePaintEditorState(controller);
|
|
1154
958
|
const [error, attempt] = useAttempt();
|
|
1155
|
-
const [renaming, setRenaming] =
|
|
959
|
+
const [renaming, setRenaming] = useState6(null);
|
|
1156
960
|
const layers = controller.listLayers();
|
|
1157
961
|
const active = layers.find((l) => l.active) ?? null;
|
|
1158
962
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1162,18 +966,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1162
966
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1163
967
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1164
968
|
};
|
|
1165
|
-
return /* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
/* @__PURE__ */
|
|
969
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
970
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", children: [
|
|
971
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
972
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
973
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
974
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
975
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
976
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
977
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
978
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1175
979
|
] }),
|
|
1176
|
-
/* @__PURE__ */
|
|
980
|
+
/* @__PURE__ */ jsx8("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs7(
|
|
1177
981
|
"li",
|
|
1178
982
|
{
|
|
1179
983
|
role: "treeitem",
|
|
@@ -1182,7 +986,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1182
986
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1183
987
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1184
988
|
children: [
|
|
1185
|
-
/* @__PURE__ */
|
|
989
|
+
/* @__PURE__ */ jsx8(
|
|
1186
990
|
"button",
|
|
1187
991
|
{
|
|
1188
992
|
type: "button",
|
|
@@ -1195,7 +999,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1195
999
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1196
1000
|
}
|
|
1197
1001
|
),
|
|
1198
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1002
|
+
renaming === l.id ? /* @__PURE__ */ jsx8(
|
|
1199
1003
|
"input",
|
|
1200
1004
|
{
|
|
1201
1005
|
autoFocus: true,
|
|
@@ -1212,23 +1016,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1212
1016
|
if (e.key === "Escape") setRenaming(null);
|
|
1213
1017
|
}
|
|
1214
1018
|
}
|
|
1215
|
-
) : /* @__PURE__ */
|
|
1019
|
+
) : /* @__PURE__ */ jsxs7("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1216
1020
|
l.type === "group" ? "\u25B8 " : "",
|
|
1217
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1021
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs7("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1218
1022
|
"\u270E",
|
|
1219
1023
|
" "
|
|
1220
1024
|
] }),
|
|
1221
1025
|
l.name
|
|
1222
1026
|
] }),
|
|
1223
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1027
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx8("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1224
1028
|
]
|
|
1225
1029
|
},
|
|
1226
1030
|
l.id
|
|
1227
1031
|
)) }),
|
|
1228
|
-
active && /* @__PURE__ */
|
|
1229
|
-
/* @__PURE__ */
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1032
|
+
active && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5", children: [
|
|
1033
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1034
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1035
|
+
/* @__PURE__ */ jsx8(
|
|
1232
1036
|
"input",
|
|
1233
1037
|
{
|
|
1234
1038
|
type: "range",
|
|
@@ -1242,40 +1046,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1242
1046
|
}
|
|
1243
1047
|
)
|
|
1244
1048
|
] }),
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
active.type === "group" && /* @__PURE__ */
|
|
1249
|
-
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */
|
|
1049
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1050
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1051
|
+
/* @__PURE__ */ jsxs7("select", { "aria-label": "Layer blend", value: active.blend, onChange: (e) => attempt(() => controller.updateLayer(active.id, { blend: e.target.value })), className: "flex-1 rounded bg-slate-800 px-1 py-0.5", children: [
|
|
1052
|
+
active.type === "group" && /* @__PURE__ */ jsx8("option", { value: "pass-through", children: "Pass through" }),
|
|
1053
|
+
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ jsx8("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ jsx8("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1250
1054
|
] })
|
|
1251
1055
|
] }),
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1056
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex gap-1", children: [
|
|
1057
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ jsx8("button", { type: "button", "aria-pressed": Boolean(active.locks[k]), className: chip(Boolean(active.locks[k])), onClick: () => attempt(() => controller.updateLayer(active.id, { locks: { [k]: !active.locks[k] } })), children: k === "pixels" ? "Lock pixels" : "Lock transparency" }, k)),
|
|
1058
|
+
/* @__PURE__ */ jsx8("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1255
1059
|
] }),
|
|
1256
|
-
light?.hasLight && /* @__PURE__ */
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1060
|
+
light?.hasLight && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1061
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
|
|
1062
|
+
/* @__PURE__ */ jsx8("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1063
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1260
1064
|
] }),
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
/* @__PURE__ */
|
|
1263
|
-
/* @__PURE__ */
|
|
1065
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", title: "How far the light spills onto the paint and paper around it (0 turns it off)", children: [
|
|
1066
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1067
|
+
/* @__PURE__ */ jsx8("input", { type: "range", "aria-label": "Light spill radius", min: 0, max: 120, step: 1, value: light.spill.radius, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { radius: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1264
1068
|
] }),
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1069
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1070
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1071
|
+
/* @__PURE__ */ jsx8("input", { type: "range", "aria-label": "Light spill strength", min: 0, max: 2, step: 0.05, value: light.spill.strength, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { strength: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1268
1072
|
] })
|
|
1269
1073
|
] }),
|
|
1270
|
-
/* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ jsx8("div", { className: "border-t border-slate-800 pt-1.5", "data-testid": "paint-layer-effects", title: "Live layer styles drawn from this layer's paint: glows, shadows, strokes", children: /* @__PURE__ */ jsx8(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1271
1075
|
] }),
|
|
1272
|
-
/* @__PURE__ */
|
|
1076
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
1273
1077
|
] });
|
|
1274
1078
|
};
|
|
1275
1079
|
|
|
1276
1080
|
// src/paint-editor/WetPanel.tsx
|
|
1277
1081
|
import { WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as readPath2, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1278
|
-
import { jsx as
|
|
1082
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1279
1083
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1280
1084
|
var WetPanel = ({ controller, className }) => {
|
|
1281
1085
|
const state = usePaintEditorState(controller);
|
|
@@ -1284,31 +1088,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1284
1088
|
const layerId = state.document.activeLayerId;
|
|
1285
1089
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1286
1090
|
const backend = controller.wetState();
|
|
1287
|
-
return /* @__PURE__ */
|
|
1288
|
-
/* @__PURE__ */
|
|
1289
|
-
/* @__PURE__ */
|
|
1290
|
-
/* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1092
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
1093
|
+
/* @__PURE__ */ jsx9("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1094
|
+
/* @__PURE__ */ jsxs8("span", { className: "text-[10px] text-slate-500", children: [
|
|
1291
1095
|
"step ",
|
|
1292
1096
|
wet.clock
|
|
1293
1097
|
] })
|
|
1294
1098
|
] }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1300
|
-
/* @__PURE__ */
|
|
1099
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-1", children: [
|
|
1100
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1101
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1102
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1103
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wet.instantDry), "aria-pressed": wet.instantDry, title: "Each wet stroke dries as soon as it ends", onClick: () => controller.setInstantDry(!wet.instantDry), children: "Instant dry" }),
|
|
1104
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1301
1105
|
] }),
|
|
1302
|
-
/* @__PURE__ */
|
|
1303
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1304
|
-
info && /* @__PURE__ */
|
|
1305
|
-
/* @__PURE__ */
|
|
1306
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1307
|
-
/* @__PURE__ */
|
|
1308
|
-
/* @__PURE__ */
|
|
1309
|
-
/* @__PURE__ */
|
|
1106
|
+
/* @__PURE__ */ jsx9(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1107
|
+
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath2(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1108
|
+
info && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1109
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1110
|
+
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath2(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1111
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1112
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1113
|
+
/* @__PURE__ */ jsx9("select", { "aria-label": "Flow map", value: info.flow.kind, onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setFlowMap(layerId, { kind: e.target.value }))), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_FLOW_KINDS.map((k) => /* @__PURE__ */ jsx9("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1310
1114
|
] }),
|
|
1311
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1115
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx9(
|
|
1312
1116
|
PaintSlider,
|
|
1313
1117
|
{
|
|
1314
1118
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1317,20 +1121,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1317
1121
|
}
|
|
1318
1122
|
)
|
|
1319
1123
|
] }),
|
|
1320
|
-
backend.message && /* @__PURE__ */
|
|
1321
|
-
backend.backend && /* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1324
|
-
/* @__PURE__ */
|
|
1124
|
+
backend.message && /* @__PURE__ */ jsx9("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1125
|
+
backend.backend && /* @__PURE__ */ jsx9("p", { className: "text-[10px] text-slate-500", children: backend.backend.kind === "wasm-threads" ? `WebAssembly, ${backend.backend.threads} threads` : backend.backend.kind === "wasm" ? "WebAssembly, one thread" : "JavaScript" }),
|
|
1126
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1127
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Engine" }),
|
|
1128
|
+
/* @__PURE__ */ jsx9("select", { "aria-label": "Wet engine", value: wet.gpu, onChange: (e) => attempt(() => controller.setWetEngine({ gpu: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_GPU_OPTIONS.map((o) => /* @__PURE__ */ jsx9("option", { value: o.value, children: o.label }, o.value)) })
|
|
1325
1129
|
] }),
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
/* @__PURE__ */
|
|
1130
|
+
/* @__PURE__ */ jsx9("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1131
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
1328
1132
|
] });
|
|
1329
1133
|
};
|
|
1330
1134
|
|
|
1331
1135
|
// src/paint-editor/StickerPanel.tsx
|
|
1332
1136
|
import { STICKER_SLIDERS, readPath as readPath3, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1333
|
-
import { jsx as
|
|
1137
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1334
1138
|
var StickerPanel = ({ controller, className }) => {
|
|
1335
1139
|
const state = usePaintEditorState(controller);
|
|
1336
1140
|
const [error, attempt] = useAttempt();
|
|
@@ -1340,16 +1144,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1340
1144
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1341
1145
|
if (!stickers.length) return null;
|
|
1342
1146
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1343
|
-
return /* @__PURE__ */
|
|
1344
|
-
/* @__PURE__ */
|
|
1147
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1148
|
+
/* @__PURE__ */ jsxs9("span", { className: "font-medium text-slate-300", children: [
|
|
1345
1149
|
"Stickers (",
|
|
1346
1150
|
stickers.length,
|
|
1347
1151
|
")"
|
|
1348
1152
|
] }),
|
|
1349
|
-
/* @__PURE__ */
|
|
1350
|
-
sel && /* @__PURE__ */
|
|
1351
|
-
/* @__PURE__ */
|
|
1352
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ jsx10("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Stickers", children: stickers.map((s) => /* @__PURE__ */ jsx10("button", { type: "button", role: "option", "aria-selected": s.id === picked, title: `${stickerRefLabel(s.ref)} ${s.id}`, className: `h-5 w-5 rounded ring-1 ${s.id === picked ? "ring-indigo-400" : "ring-slate-700"}`, style: { background: s.color }, onClick: () => setPicked(s.id) }, s.id)) }),
|
|
1154
|
+
sel && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1155
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1156
|
+
/* @__PURE__ */ jsx10(
|
|
1353
1157
|
StickerPicker,
|
|
1354
1158
|
{
|
|
1355
1159
|
controller,
|
|
@@ -1363,9 +1167,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1363
1167
|
)
|
|
1364
1168
|
}
|
|
1365
1169
|
),
|
|
1366
|
-
/* @__PURE__ */
|
|
1367
|
-
/* @__PURE__ */
|
|
1368
|
-
/* @__PURE__ */
|
|
1170
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1171
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Position" }),
|
|
1172
|
+
/* @__PURE__ */ jsx10("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx10(
|
|
1369
1173
|
"input",
|
|
1370
1174
|
{
|
|
1371
1175
|
type: "number",
|
|
@@ -1379,24 +1183,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1379
1183
|
`${sel.id}-${k}-${sel[k]}`
|
|
1380
1184
|
)) })
|
|
1381
1185
|
] }),
|
|
1382
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1383
|
-
/* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1186
|
+
STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx10(PaintSlider, { control: c, value: readPath3(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1187
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between", children: [
|
|
1188
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Colour" }),
|
|
1189
|
+
/* @__PURE__ */ jsx10(CommitColorInput, { label: "Sticker colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1386
1190
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1388
|
-
/* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
/* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", children: [
|
|
1192
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1193
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1194
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1391
1195
|
] })
|
|
1392
1196
|
] }),
|
|
1393
|
-
/* @__PURE__ */
|
|
1197
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1394
1198
|
] });
|
|
1395
1199
|
};
|
|
1396
1200
|
|
|
1397
1201
|
// src/paint-editor/StrokePanel.tsx
|
|
1398
1202
|
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath4 } from "@pixerate/editor/paint-editor";
|
|
1399
|
-
import { jsx as
|
|
1203
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1400
1204
|
var StrokePanel = ({ controller, className }) => {
|
|
1401
1205
|
const state = usePaintEditorState(controller);
|
|
1402
1206
|
const [error, attempt] = useAttempt();
|
|
@@ -1406,16 +1210,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1406
1210
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1407
1211
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1408
1212
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1409
|
-
return /* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1214
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1215
|
+
/* @__PURE__ */ jsxs10("span", { className: "font-medium text-slate-300", children: [
|
|
1412
1216
|
"Strokes (",
|
|
1413
1217
|
strokes.length,
|
|
1414
1218
|
")"
|
|
1415
1219
|
] }),
|
|
1416
|
-
/* @__PURE__ */
|
|
1220
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1417
1221
|
] }),
|
|
1418
|
-
/* @__PURE__ */
|
|
1222
|
+
/* @__PURE__ */ jsx11("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ jsx11(
|
|
1419
1223
|
"button",
|
|
1420
1224
|
{
|
|
1421
1225
|
type: "button",
|
|
@@ -1428,10 +1232,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1428
1232
|
},
|
|
1429
1233
|
s.id
|
|
1430
1234
|
)) }),
|
|
1431
|
-
sel && /* @__PURE__ */
|
|
1432
|
-
/* @__PURE__ */
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1235
|
+
sel && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1236
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1237
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Brush" }),
|
|
1238
|
+
/* @__PURE__ */ jsxs10(
|
|
1435
1239
|
"select",
|
|
1436
1240
|
{
|
|
1437
1241
|
"aria-label": "Stroke brush",
|
|
@@ -1439,41 +1243,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1439
1243
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1440
1244
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1441
1245
|
children: [
|
|
1442
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1443
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1246
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx11("option", { value: "", children: sel.brush.name }),
|
|
1247
|
+
brushes.map((b) => /* @__PURE__ */ jsx11("option", { value: b.id, children: b.name }, b.id))
|
|
1444
1248
|
]
|
|
1445
1249
|
}
|
|
1446
1250
|
)
|
|
1447
1251
|
] }),
|
|
1448
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1449
|
-
/* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
/* @__PURE__ */
|
|
1252
|
+
STROKE_SLIDERS.map((c) => /* @__PURE__ */ jsx11(PaintSlider, { control: c, value: readPath4(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1253
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between", children: [
|
|
1254
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Colour" }),
|
|
1255
|
+
/* @__PURE__ */ jsx11(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1452
1256
|
] }),
|
|
1453
|
-
/* @__PURE__ */
|
|
1454
|
-
/* @__PURE__ */
|
|
1455
|
-
/* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1258
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1259
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: index === strokes.length - 1, "aria-label": "Move stroke up", onClick: () => attempt(() => controller.reorderStroke(sel.id, index + 1)), children: "\u2191" }),
|
|
1260
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1261
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1458
1262
|
] })
|
|
1459
1263
|
] }),
|
|
1460
|
-
/* @__PURE__ */
|
|
1264
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1461
1265
|
] });
|
|
1462
1266
|
};
|
|
1463
1267
|
|
|
1464
1268
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1465
|
-
import { useState as
|
|
1269
|
+
import { useState as useState7 } from "react";
|
|
1466
1270
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1467
|
-
import { jsx as
|
|
1271
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1468
1272
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1469
1273
|
const state = usePaintEditorState(controller);
|
|
1470
1274
|
const [error, attempt] = useAttempt();
|
|
1471
|
-
const [path, setPath] =
|
|
1472
|
-
const [taper, setTaper] =
|
|
1275
|
+
const [path, setPath] = useState7("");
|
|
1276
|
+
const [taper, setTaper] = useState7(PATH_STROKE_TAPERS[0].id);
|
|
1473
1277
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1474
|
-
return /* @__PURE__ */
|
|
1475
|
-
/* @__PURE__ */
|
|
1476
|
-
/* @__PURE__ */
|
|
1278
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1279
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1280
|
+
/* @__PURE__ */ jsx12(
|
|
1477
1281
|
"textarea",
|
|
1478
1282
|
{
|
|
1479
1283
|
"aria-label": "SVG path data",
|
|
@@ -1484,25 +1288,25 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1484
1288
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1485
1289
|
}
|
|
1486
1290
|
),
|
|
1487
|
-
/* @__PURE__ */
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
|
|
1292
|
+
/* @__PURE__ */ jsx12("select", { "aria-label": "Pressure along the path", value: taper, onChange: (e) => setTaper(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: PATH_STROKE_TAPERS.map((t) => /* @__PURE__ */ jsx12("option", { value: t.id, children: t.label }, t.id)) }),
|
|
1293
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1490
1294
|
] }),
|
|
1491
|
-
/* @__PURE__ */
|
|
1295
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1492
1296
|
] });
|
|
1493
1297
|
};
|
|
1494
1298
|
|
|
1495
1299
|
// src/paint-editor/PaintEditor.tsx
|
|
1496
|
-
import { useRef as
|
|
1300
|
+
import { useRef as useRef7, useState as useState9 } from "react";
|
|
1497
1301
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1498
1302
|
|
|
1499
1303
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1500
|
-
import { useEffect as
|
|
1304
|
+
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
|
|
1501
1305
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1502
|
-
import { jsx as
|
|
1306
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1503
1307
|
function usePaintEffectsProvider(controller) {
|
|
1504
|
-
const [provider, setProvider] =
|
|
1505
|
-
|
|
1308
|
+
const [provider, setProvider] = useState8(controller.effectsProvider);
|
|
1309
|
+
useEffect4(() => {
|
|
1506
1310
|
setProvider(controller.effectsProvider);
|
|
1507
1311
|
return controller.effects.subscribe(setProvider);
|
|
1508
1312
|
}, [controller]);
|
|
@@ -1510,27 +1314,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
1510
1314
|
}
|
|
1511
1315
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
1512
1316
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
1513
|
-
|
|
1317
|
+
useEffect4(() => {
|
|
1514
1318
|
if (!registry) return;
|
|
1515
1319
|
return registry.register(createPaintEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
|
|
1516
1320
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
1517
1321
|
}
|
|
1518
1322
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1519
1323
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1520
|
-
const drags =
|
|
1521
|
-
if (!provider) return /* @__PURE__ */
|
|
1324
|
+
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1325
|
+
if (!provider) return /* @__PURE__ */ jsxs12("p", { className: "text-[11px] text-slate-400", children: [
|
|
1522
1326
|
'No effects provider: "',
|
|
1523
1327
|
name ?? effect,
|
|
1524
1328
|
'" is kept as it was drawn.'
|
|
1525
1329
|
] });
|
|
1526
|
-
if (error) return /* @__PURE__ */
|
|
1527
|
-
if (!description) return /* @__PURE__ */
|
|
1330
|
+
if (error) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1331
|
+
if (!description) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1528
1332
|
const commit = (gesture) => {
|
|
1529
1333
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1530
1334
|
drags.current.add(gesture);
|
|
1531
1335
|
return true;
|
|
1532
1336
|
};
|
|
1533
|
-
return /* @__PURE__ */
|
|
1337
|
+
return /* @__PURE__ */ jsx13(
|
|
1534
1338
|
EffectParameters,
|
|
1535
1339
|
{
|
|
1536
1340
|
description,
|
|
@@ -1552,8 +1356,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1552
1356
|
const state = usePaintEditorState(controller);
|
|
1553
1357
|
const provider = usePaintEffectsProvider(controller);
|
|
1554
1358
|
const [error, attempt] = useAttempt();
|
|
1555
|
-
const [browse, setBrowse] =
|
|
1556
|
-
const [busy, setBusy] =
|
|
1359
|
+
const [browse, setBrowse] = useState8(null);
|
|
1360
|
+
const [busy, setBusy] = useState8(false);
|
|
1557
1361
|
const paper = controller.getPaperEffect();
|
|
1558
1362
|
const activeId = state.document.activeLayerId;
|
|
1559
1363
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1565,7 +1369,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1565
1369
|
if (!effectPaint) return;
|
|
1566
1370
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1567
1371
|
};
|
|
1568
|
-
const thumbnail =
|
|
1372
|
+
const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1569
1373
|
const run = (work) => attempt(() => {
|
|
1570
1374
|
setBusy(true);
|
|
1571
1375
|
return work().finally(() => setBusy(false));
|
|
@@ -1581,28 +1385,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1581
1385
|
};
|
|
1582
1386
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1583
1387
|
const pixel = active?.type === "pixel";
|
|
1584
|
-
return /* @__PURE__ */
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
/* @__PURE__ */
|
|
1591
|
-
/* @__PURE__ */
|
|
1388
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1389
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1390
|
+
/* @__PURE__ */ jsx13("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1391
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1392
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1393
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1394
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "light", onClick: () => toggle("light"), title: "Bake a light, glow or grade into the active layer's dried paint", children: "Light\u2026" }),
|
|
1395
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paint", onClick: () => toggle("paint"), title: "Paint with an effect: brushes take each pixel's colour from it", children: "Paint\u2026" })
|
|
1592
1396
|
] }),
|
|
1593
|
-
!provider && /* @__PURE__ */
|
|
1594
|
-
browse && /* @__PURE__ */
|
|
1595
|
-
paper && /* @__PURE__ */
|
|
1596
|
-
/* @__PURE__ */
|
|
1597
|
-
/* @__PURE__ */
|
|
1397
|
+
!provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1398
|
+
browse && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1399
|
+
paper && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1400
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1401
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1598
1402
|
"Paper: ",
|
|
1599
1403
|
paper.name ?? paper.effect
|
|
1600
1404
|
] }),
|
|
1601
|
-
/* @__PURE__ */
|
|
1405
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1602
1406
|
] }),
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */
|
|
1605
|
-
/* @__PURE__ */
|
|
1407
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1408
|
+
/* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1409
|
+
/* @__PURE__ */ jsx13(
|
|
1606
1410
|
"input",
|
|
1607
1411
|
{
|
|
1608
1412
|
type: "range",
|
|
@@ -1624,39 +1428,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1624
1428
|
`o${paper.opacity}`
|
|
1625
1429
|
)
|
|
1626
1430
|
] }),
|
|
1627
|
-
/* @__PURE__ */
|
|
1628
|
-
/* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1432
|
+
/* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1433
|
+
/* @__PURE__ */ jsx13("select", { className: "flex-1 rounded bg-slate-800 px-1 py-0.5 text-[11px]", "aria-label": "Effect paper blend", value: paper.blend, onChange: (e) => {
|
|
1630
1434
|
const blend = e.currentTarget.value;
|
|
1631
1435
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1632
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1436
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx13("option", { value: b, children: b }, b)) })
|
|
1633
1437
|
] }),
|
|
1634
|
-
/* @__PURE__ */
|
|
1438
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1635
1439
|
] }),
|
|
1636
|
-
effectPaint && /* @__PURE__ */
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
thumbnail ? /* @__PURE__ */
|
|
1639
|
-
/* @__PURE__ */
|
|
1440
|
+
effectPaint && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1441
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1442
|
+
thumbnail ? /* @__PURE__ */ jsx13("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
1443
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1640
1444
|
"Paint: ",
|
|
1641
1445
|
effectPaint.effect,
|
|
1642
1446
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1643
1447
|
] }),
|
|
1644
|
-
/* @__PURE__ */
|
|
1448
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1645
1449
|
] }),
|
|
1646
|
-
/* @__PURE__ */
|
|
1647
|
-
/* @__PURE__ */
|
|
1648
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1451
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1452
|
+
/* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1649
1453
|
"Along the stroke"
|
|
1650
1454
|
] }),
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1456
|
+
/* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1653
1457
|
"Live"
|
|
1654
1458
|
] })
|
|
1655
1459
|
] }),
|
|
1656
|
-
effectPaint.map && /* @__PURE__ */
|
|
1657
|
-
/* @__PURE__ */
|
|
1658
|
-
/* @__PURE__ */
|
|
1659
|
-
/* @__PURE__ */
|
|
1460
|
+
effectPaint.map && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1461
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1462
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Length" }),
|
|
1463
|
+
/* @__PURE__ */ jsx13(
|
|
1660
1464
|
"input",
|
|
1661
1465
|
{
|
|
1662
1466
|
type: "number",
|
|
@@ -1670,55 +1474,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1670
1474
|
effectPaint.map.length
|
|
1671
1475
|
)
|
|
1672
1476
|
] }),
|
|
1673
|
-
/* @__PURE__ */
|
|
1674
|
-
/* @__PURE__ */
|
|
1675
|
-
/* @__PURE__ */
|
|
1676
|
-
/* @__PURE__ */
|
|
1477
|
+
/* @__PURE__ */ jsxs12("select", { "aria-label": "Effect repeat", value: effectPaint.map.repeat, onChange: (e) => repaint({ map: { ...effectPaint.map, repeat: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: [
|
|
1478
|
+
/* @__PURE__ */ jsx13("option", { value: "repeat", children: "Repeat" }),
|
|
1479
|
+
/* @__PURE__ */ jsx13("option", { value: "mirror", children: "Mirror" }),
|
|
1480
|
+
/* @__PURE__ */ jsx13("option", { value: "clamp", children: "Clamp" })
|
|
1677
1481
|
] })
|
|
1678
1482
|
] }),
|
|
1679
|
-
/* @__PURE__ */
|
|
1483
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1680
1484
|
] }),
|
|
1681
|
-
animation && /* @__PURE__ */
|
|
1682
|
-
/* @__PURE__ */
|
|
1485
|
+
animation && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1486
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1683
1487
|
"Live paint: ",
|
|
1684
1488
|
animation.strokes,
|
|
1685
1489
|
" ",
|
|
1686
1490
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1687
1491
|
] }),
|
|
1688
|
-
/* @__PURE__ */
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
1691
|
-
/* @__PURE__ */
|
|
1492
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1493
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1494
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "fps" }),
|
|
1495
|
+
/* @__PURE__ */ jsx13("input", { type: "number", "aria-label": "Live paint frame rate", min: 1, max: 60, value: playback.fps, onChange: (e) => attempt(() => controller.setEffectPlayback({ fps: Math.round(Number(e.target.value)) })), className: "w-12 rounded bg-slate-800 px-1 py-0.5" })
|
|
1692
1496
|
] })
|
|
1693
1497
|
] }),
|
|
1694
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1695
|
-
/* @__PURE__ */
|
|
1696
|
-
/* @__PURE__ */
|
|
1498
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1499
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1500
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1697
1501
|
"Layer: ",
|
|
1698
1502
|
layerEffect.name ?? layerEffect.effect
|
|
1699
1503
|
] }),
|
|
1700
|
-
/* @__PURE__ */
|
|
1504
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1701
1505
|
] }),
|
|
1702
|
-
/* @__PURE__ */
|
|
1506
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1703
1507
|
] }),
|
|
1704
|
-
/* @__PURE__ */
|
|
1508
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1705
1509
|
] });
|
|
1706
1510
|
};
|
|
1707
1511
|
|
|
1708
1512
|
// src/paint-editor/PaintEditor.tsx
|
|
1709
|
-
import { jsx as
|
|
1513
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1710
1514
|
var PAINT_CONTROLS = {
|
|
1711
1515
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1712
1516
|
lighting: '[data-testid="light-panel"]',
|
|
1713
1517
|
symmetry: '[aria-label="Symmetry"]'
|
|
1714
1518
|
};
|
|
1715
1519
|
var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, agentStrokes, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1716
|
-
const [tool, setTool] =
|
|
1717
|
-
const [tab, setTab] =
|
|
1718
|
-
const tabRef =
|
|
1520
|
+
const [tool, setTool] = useState9("brush");
|
|
1521
|
+
const [tab, setTab] = useState9("color");
|
|
1522
|
+
const tabRef = useRef7(tab);
|
|
1719
1523
|
tabRef.current = tab;
|
|
1720
|
-
const rootRef =
|
|
1721
|
-
const [ownPresence] =
|
|
1524
|
+
const rootRef = useRef7(null);
|
|
1525
|
+
const [ownPresence] = useState9(() => new PaintPresence2());
|
|
1722
1526
|
const ambientPlayback = useAgentPlayback();
|
|
1723
1527
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1724
1528
|
const viewBox = () => {
|
|
@@ -1774,29 +1578,29 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1774
1578
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1775
1579
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1776
1580
|
};
|
|
1777
|
-
const [error, setError] =
|
|
1581
|
+
const [error, setError] = useState9(null);
|
|
1778
1582
|
const effects = usePaintEffectsProvider(controller);
|
|
1779
1583
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1780
|
-
return /* @__PURE__ */
|
|
1781
|
-
playing && /* @__PURE__ */
|
|
1782
|
-
/* @__PURE__ */
|
|
1783
|
-
/* @__PURE__ */
|
|
1784
|
-
/* @__PURE__ */
|
|
1785
|
-
/* @__PURE__ */
|
|
1786
|
-
/* @__PURE__ */
|
|
1787
|
-
error && /* @__PURE__ */
|
|
1584
|
+
return /* @__PURE__ */ jsxs13("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|
|
1585
|
+
playing && /* @__PURE__ */ jsx14(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1586
|
+
/* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1587
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1588
|
+
/* @__PURE__ */ jsx14(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1589
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1590
|
+
/* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1591
|
+
error && /* @__PURE__ */ jsx14("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1788
1592
|
] }),
|
|
1789
|
-
/* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */
|
|
1791
|
-
/* @__PURE__ */
|
|
1792
|
-
tab === "color" && /* @__PURE__ */
|
|
1793
|
-
tab === "wet" && /* @__PURE__ */
|
|
1794
|
-
tab === "paper" && /* @__PURE__ */
|
|
1795
|
-
tab === "layers" && /* @__PURE__ */
|
|
1796
|
-
tab === "layers" && /* @__PURE__ */
|
|
1797
|
-
tab === "layers" && /* @__PURE__ */
|
|
1798
|
-
tab === "layers" && /* @__PURE__ */
|
|
1799
|
-
tab === "effects" && effects && /* @__PURE__ */
|
|
1593
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1594
|
+
/* @__PURE__ */ jsx14("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx14("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
1595
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1596
|
+
tab === "color" && /* @__PURE__ */ jsx14(ColorPanel, { controller }),
|
|
1597
|
+
tab === "wet" && /* @__PURE__ */ jsx14(WetPanel, { controller }),
|
|
1598
|
+
tab === "paper" && /* @__PURE__ */ jsx14(PaperPanel, { controller }),
|
|
1599
|
+
tab === "layers" && /* @__PURE__ */ jsx14(PaintLayersPanel, { controller }),
|
|
1600
|
+
tab === "layers" && /* @__PURE__ */ jsx14(StrokePanel, { controller }),
|
|
1601
|
+
tab === "layers" && /* @__PURE__ */ jsx14(PathStrokePanel, { controller }),
|
|
1602
|
+
tab === "layers" && /* @__PURE__ */ jsx14(StickerPanel, { controller }),
|
|
1603
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx14(PaintEffectsPanel, { controller })
|
|
1800
1604
|
] })
|
|
1801
1605
|
] })
|
|
1802
1606
|
] })
|