@pixerate/editor-react 0.179.0 → 0.181.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/brushes/BrushEditor.d.cts +40 -0
- package/dist/brushes/BrushEditor.d.ts +40 -0
- package/dist/brushes/BrushLibraryEditor.d.cts +31 -0
- package/dist/brushes/BrushLibraryEditor.d.ts +31 -0
- package/dist/brushes/index.cjs +292 -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-THMOZMEE.js +122 -0
- package/dist/{chunk-UR4KL7WE.js → chunk-WCSMREA4.js} +26 -6
- package/dist/chunk-XORL5PGL.js +263 -0
- package/dist/image-editor/BrushOptionsBar.d.cts +6 -1
- package/dist/image-editor/BrushOptionsBar.d.ts +6 -1
- package/dist/image-editor/index.cjs +1181 -894
- package/dist/image-editor/index.js +3 -3
- package/dist/index.cjs +1722 -1435
- package/dist/index.js +3 -3
- package/dist/paint-editor/index.cjs +22 -24
- package/dist/paint-editor/index.d.cts +1 -1
- package/dist/paint-editor/index.d.ts +1 -1
- package/dist/paint-editor/index.js +415 -610
- package/dist/vector/VectorAppearancePanel.d.cts +8 -2
- package/dist/vector/VectorAppearancePanel.d.ts +8 -2
- package/dist/vector/index.cjs +1113 -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
- package/dist/paint-editor/BrushEditor.d.cts +0 -29
- package/dist/paint-editor/BrushEditor.d.ts +0 -29
|
@@ -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-XORL5PGL.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, brushPreviewColours, 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,71 @@ 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 =
|
|
797
|
-
|
|
600
|
+
const thumbs = useMemo3(
|
|
601
|
+
// Each in a colour that reads on the paper (the brush's own default when it has one).
|
|
602
|
+
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: brushPreviewColours(controller.getBrushSpec(b.id), { paper: paper.color }).color })])),
|
|
798
603
|
// Thumbnails follow the library and the paper.
|
|
799
604
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
800
605
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
801
606
|
);
|
|
802
|
-
const entries =
|
|
803
|
-
const spec =
|
|
607
|
+
const entries = useMemo3(() => brushes.map((b) => ({ brush: controller.getBrushSpec(b.id), builtin: Boolean(b.builtin) })), [controller, brushes]);
|
|
608
|
+
const spec = useMemo3(() => controller.getBrushSpec(), [controller, brush]);
|
|
804
609
|
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 =
|
|
610
|
+
const preview = useMemo3(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
|
|
806
611
|
const carried = brushLoadColor(state.mixerLoad);
|
|
807
612
|
const palette = (spec.colour?.palette ?? []).flatMap((c) => brushColourHex(c, state.colorScheme) ?? []);
|
|
808
613
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
809
614
|
const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
|
|
810
|
-
return /* @__PURE__ */
|
|
811
|
-
/* @__PURE__ */
|
|
812
|
-
/* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ jsxs4("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
616
|
+
/* @__PURE__ */ jsx5(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
617
|
+
/* @__PURE__ */ jsx5(
|
|
813
618
|
BrushEditor,
|
|
814
619
|
{
|
|
815
620
|
brush: spec,
|
|
816
|
-
profile:
|
|
621
|
+
profile: PAINT_PROFILE,
|
|
817
622
|
preview,
|
|
818
623
|
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
819
624
|
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
820
625
|
renderExtra: (section) => {
|
|
821
626
|
if (section === "shape" && brush.engine === "sticker")
|
|
822
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ jsx5(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
|
|
823
628
|
if (section === "behaviour" && loads)
|
|
824
|
-
return /* @__PURE__ */
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
827
|
-
brush.engine === "mixer" && /* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
630
|
+
/* @__PURE__ */ jsx5("span", { className: "text-slate-400", children: "Carries" }),
|
|
631
|
+
/* @__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" } }),
|
|
632
|
+
brush.engine === "mixer" && /* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
633
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
829
634
|
] });
|
|
830
635
|
if (section === "colour")
|
|
831
|
-
return /* @__PURE__ */
|
|
832
|
-
palette.length > 0 && /* @__PURE__ */
|
|
833
|
-
/* @__PURE__ */
|
|
834
|
-
/* @__PURE__ */
|
|
636
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
637
|
+
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}`)) }),
|
|
638
|
+
/* @__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: [
|
|
639
|
+
/* @__PURE__ */ jsx5("input", { type: "checkbox", "aria-label": "Keep my colour", checked: state.colorLocked, onChange: (e) => controller.setColorLocked(e.target.checked) }),
|
|
835
640
|
" Keep my colour when choosing a brush"
|
|
836
641
|
] }),
|
|
837
|
-
brushTakesPaint(brush) && /* @__PURE__ */
|
|
838
|
-
/* @__PURE__ */
|
|
839
|
-
/* @__PURE__ */
|
|
840
|
-
/* @__PURE__ */
|
|
642
|
+
brushTakesPaint(brush) && /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
643
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
|
|
644
|
+
/* @__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" }),
|
|
645
|
+
/* @__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
646
|
] }),
|
|
842
|
-
brush.paint && /* @__PURE__ */
|
|
647
|
+
brush.paint && /* @__PURE__ */ jsx5(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
843
648
|
] })
|
|
844
649
|
] });
|
|
845
650
|
return null;
|
|
846
651
|
}
|
|
847
652
|
}
|
|
848
653
|
),
|
|
849
|
-
/* @__PURE__ */
|
|
850
|
-
/* @__PURE__ */
|
|
851
|
-
/* @__PURE__ */
|
|
852
|
-
/* @__PURE__ */
|
|
654
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
655
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => attempt(async () => downloadBytes2(JSON.stringify(await controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
656
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
657
|
+
/* @__PURE__ */ jsx5(
|
|
853
658
|
"input",
|
|
854
659
|
{
|
|
855
660
|
ref: fileRef,
|
|
@@ -865,24 +670,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
865
670
|
}
|
|
866
671
|
)
|
|
867
672
|
] }),
|
|
868
|
-
/* @__PURE__ */
|
|
673
|
+
/* @__PURE__ */ jsx5(ErrorLine, { error })
|
|
869
674
|
] });
|
|
870
675
|
};
|
|
871
676
|
|
|
872
677
|
// src/paint-editor/PaperPanel.tsx
|
|
873
|
-
import { useMemo as
|
|
678
|
+
import { useMemo as useMemo4 } from "react";
|
|
874
679
|
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath, readPath, renderPaper } from "@pixerate/editor/paint-editor";
|
|
875
|
-
import { jsx as
|
|
680
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
876
681
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
877
682
|
var PaperPanel = ({ controller, className }) => {
|
|
878
683
|
const state = usePaintEditorState(controller);
|
|
879
684
|
const [error, attempt] = useAttempt();
|
|
880
685
|
const paper = state.document.paper;
|
|
881
|
-
const previews =
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
884
|
-
/* @__PURE__ */
|
|
885
|
-
/* @__PURE__ */
|
|
686
|
+
const previews = useMemo4(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
687
|
+
return /* @__PURE__ */ jsxs5("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
688
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs5("div", { children: [
|
|
689
|
+
/* @__PURE__ */ jsx6("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
690
|
+
/* @__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
691
|
"button",
|
|
887
692
|
{
|
|
888
693
|
type: "button",
|
|
@@ -891,37 +696,37 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
891
696
|
title: p.name,
|
|
892
697
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
893
698
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
894
|
-
children: /* @__PURE__ */
|
|
699
|
+
children: /* @__PURE__ */ jsx6(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
895
700
|
},
|
|
896
701
|
p.preset
|
|
897
702
|
)) })
|
|
898
703
|
] }, family)),
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
/* @__PURE__ */
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
/* @__PURE__ */
|
|
704
|
+
/* @__PURE__ */ jsx6("div", { className: "text-slate-300", children: paper.name }),
|
|
705
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between", children: [
|
|
706
|
+
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Colour" }),
|
|
707
|
+
/* @__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
708
|
] }),
|
|
904
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
905
|
-
/* @__PURE__ */
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
/* @__PURE__ */
|
|
709
|
+
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)),
|
|
710
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between", children: [
|
|
711
|
+
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
712
|
+
/* @__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
713
|
] }),
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
714
|
+
/* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", children: [
|
|
715
|
+
/* @__PURE__ */ jsx6("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
911
716
|
" Mirror tiling"
|
|
912
717
|
] }),
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
917
|
-
/* @__PURE__ */
|
|
718
|
+
/* @__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" }),
|
|
719
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
720
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
721
|
+
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)),
|
|
722
|
+
/* @__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
723
|
] }),
|
|
919
|
-
/* @__PURE__ */
|
|
724
|
+
/* @__PURE__ */ jsx6(ErrorLine, { error })
|
|
920
725
|
] });
|
|
921
726
|
};
|
|
922
727
|
|
|
923
728
|
// src/paint-editor/ColorPanel.tsx
|
|
924
|
-
import { useMemo as
|
|
729
|
+
import { useMemo as useMemo5, useRef as useRef5, useState as useState5 } from "react";
|
|
925
730
|
import {
|
|
926
731
|
HARMONY_KINDS,
|
|
927
732
|
MIXING_PAD_HEIGHT,
|
|
@@ -938,24 +743,24 @@ import {
|
|
|
938
743
|
wheelPoint
|
|
939
744
|
} from "@pixerate/editor/paint-editor";
|
|
940
745
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
941
|
-
import { jsx as
|
|
746
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
942
747
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
943
748
|
const state = usePaintEditorState(controller);
|
|
944
749
|
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 =
|
|
750
|
+
const [wheel, setWheel] = useState5("ryb");
|
|
751
|
+
const [kind, setKind] = useState5("complementary");
|
|
752
|
+
const [padTool, setPadTool] = useState5("paint");
|
|
753
|
+
const [sample, setSample] = useState5(3);
|
|
754
|
+
const [parts, setParts] = useState5([1, 1]);
|
|
755
|
+
const [padName, setPadName] = useState5("");
|
|
756
|
+
const padPoints = useRef5(null);
|
|
757
|
+
const ring = useMemo5(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
953
758
|
const color = state.color;
|
|
954
|
-
const harmony =
|
|
759
|
+
const harmony = useMemo5(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
955
760
|
const [r, g, b] = parseHexColor(color);
|
|
956
761
|
const hsv = rgbToHsv(r, g, b);
|
|
957
|
-
const effectWell =
|
|
958
|
-
const pad =
|
|
762
|
+
const effectWell = useMemo5(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
763
|
+
const pad = useMemo5(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
959
764
|
const R = wheelSize / 2;
|
|
960
765
|
const mid = R * 0.82;
|
|
961
766
|
const setHsv = (s, v) => controller.setColor(rgbToHexColor(...hsvToRgb(hsv.h, s, v)));
|
|
@@ -967,9 +772,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
967
772
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
968
773
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
969
774
|
};
|
|
970
|
-
return /* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
/* @__PURE__ */
|
|
775
|
+
return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
776
|
+
/* @__PURE__ */ jsxs6("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
777
|
+
/* @__PURE__ */ jsx7(
|
|
973
778
|
"div",
|
|
974
779
|
{
|
|
975
780
|
role: "slider",
|
|
@@ -983,20 +788,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
983
788
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
984
789
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
985
790
|
},
|
|
986
|
-
children: /* @__PURE__ */
|
|
791
|
+
children: /* @__PURE__ */ jsx7(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
987
792
|
}
|
|
988
793
|
),
|
|
989
|
-
/* @__PURE__ */
|
|
794
|
+
/* @__PURE__ */ jsx7("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
990
795
|
const p = wheelPoint(h.angle, mid);
|
|
991
|
-
return /* @__PURE__ */
|
|
796
|
+
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
797
|
}) }),
|
|
993
|
-
/* @__PURE__ */
|
|
798
|
+
/* @__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
799
|
] }),
|
|
995
|
-
/* @__PURE__ */
|
|
996
|
-
/* @__PURE__ */
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */
|
|
800
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
801
|
+
/* @__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" }),
|
|
802
|
+
/* @__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" }),
|
|
803
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
804
|
+
/* @__PURE__ */ jsx7(
|
|
1000
805
|
"input",
|
|
1001
806
|
{
|
|
1002
807
|
"aria-label": "Hex colour",
|
|
@@ -1007,8 +812,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1007
812
|
color
|
|
1008
813
|
)
|
|
1009
814
|
] }),
|
|
1010
|
-
/* @__PURE__ */
|
|
1011
|
-
/* @__PURE__ */
|
|
815
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
816
|
+
/* @__PURE__ */ jsx7(
|
|
1012
817
|
"span",
|
|
1013
818
|
{
|
|
1014
819
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -1018,7 +823,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1018
823
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1019
824
|
}
|
|
1020
825
|
),
|
|
1021
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ jsx7(
|
|
1022
827
|
"button",
|
|
1023
828
|
{
|
|
1024
829
|
type: "button",
|
|
@@ -1030,26 +835,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1030
835
|
}
|
|
1031
836
|
)
|
|
1032
837
|
] }),
|
|
1033
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
1036
|
-
/* @__PURE__ */
|
|
838
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx7(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
839
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
840
|
+
/* @__PURE__ */ jsx7("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
841
|
+
/* @__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
842
|
] }),
|
|
1038
|
-
/* @__PURE__ */
|
|
1039
|
-
/* @__PURE__ */
|
|
1040
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
844
|
+
/* @__PURE__ */ jsx7("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
845
|
+
/* @__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
846
|
] }),
|
|
1042
|
-
/* @__PURE__ */
|
|
1043
|
-
/* @__PURE__ */
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
/* @__PURE__ */
|
|
847
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
|
|
848
|
+
/* @__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)) }),
|
|
849
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
850
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1046
851
|
] }),
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
853
|
+
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)),
|
|
854
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1050
855
|
] }),
|
|
1051
|
-
/* @__PURE__ */
|
|
1052
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
856
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
857
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx7(
|
|
1053
858
|
"button",
|
|
1054
859
|
{
|
|
1055
860
|
type: "button",
|
|
@@ -1067,15 +872,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1067
872
|
},
|
|
1068
873
|
i
|
|
1069
874
|
)),
|
|
1070
|
-
/* @__PURE__ */
|
|
875
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1071
876
|
] }),
|
|
1072
|
-
mixingPad && /* @__PURE__ */
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1076
|
-
/* @__PURE__ */
|
|
877
|
+
mixingPad && /* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
878
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1", children: [
|
|
879
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
880
|
+
["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)),
|
|
881
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1077
882
|
] }),
|
|
1078
|
-
/* @__PURE__ */
|
|
883
|
+
/* @__PURE__ */ jsx7(
|
|
1079
884
|
"div",
|
|
1080
885
|
{
|
|
1081
886
|
role: "application",
|
|
@@ -1096,20 +901,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1096
901
|
padPoints.current = null;
|
|
1097
902
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1098
903
|
},
|
|
1099
|
-
children: /* @__PURE__ */
|
|
904
|
+
children: /* @__PURE__ */ jsx7(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1100
905
|
}
|
|
1101
906
|
),
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */
|
|
1104
|
-
/* @__PURE__ */
|
|
907
|
+
/* @__PURE__ */ jsx7("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-1", children: [
|
|
908
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Sample" }),
|
|
909
|
+
/* @__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
910
|
] }) }),
|
|
1106
|
-
/* @__PURE__ */
|
|
1107
|
-
/* @__PURE__ */
|
|
1108
|
-
/* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
911
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
912
|
+
/* @__PURE__ */ jsx7("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
913
|
+
/* @__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" }),
|
|
914
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-500", children: ":" }),
|
|
915
|
+
/* @__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" }),
|
|
916
|
+
/* @__PURE__ */ jsx7("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
917
|
+
/* @__PURE__ */ jsx7(
|
|
1113
918
|
"button",
|
|
1114
919
|
{
|
|
1115
920
|
type: "button",
|
|
@@ -1128,23 +933,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1128
933
|
}
|
|
1129
934
|
)
|
|
1130
935
|
] }),
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1133
|
-
/* @__PURE__ */
|
|
936
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
937
|
+
/* @__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" }),
|
|
938
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1134
939
|
] }),
|
|
1135
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1136
|
-
/* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
940
|
+
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: [
|
|
941
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
942
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1138
943
|
] }, p.id)) })
|
|
1139
944
|
] }),
|
|
1140
|
-
/* @__PURE__ */
|
|
945
|
+
/* @__PURE__ */ jsx7(ErrorLine, { error })
|
|
1141
946
|
] });
|
|
1142
947
|
};
|
|
1143
948
|
|
|
1144
949
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1145
|
-
import { useState as
|
|
950
|
+
import { useState as useState6 } from "react";
|
|
1146
951
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1147
|
-
import { jsx as
|
|
952
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1148
953
|
function siblingIndex(layers, l) {
|
|
1149
954
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1150
955
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1152,7 +957,7 @@ function siblingIndex(layers, l) {
|
|
|
1152
957
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1153
958
|
usePaintEditorState(controller);
|
|
1154
959
|
const [error, attempt] = useAttempt();
|
|
1155
|
-
const [renaming, setRenaming] =
|
|
960
|
+
const [renaming, setRenaming] = useState6(null);
|
|
1156
961
|
const layers = controller.listLayers();
|
|
1157
962
|
const active = layers.find((l) => l.active) ?? null;
|
|
1158
963
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1162,18 +967,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1162
967
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1163
968
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1164
969
|
};
|
|
1165
|
-
return /* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
/* @__PURE__ */
|
|
970
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
971
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", children: [
|
|
972
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
973
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
974
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
975
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
976
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
977
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
978
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
979
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1175
980
|
] }),
|
|
1176
|
-
/* @__PURE__ */
|
|
981
|
+
/* @__PURE__ */ jsx8("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs7(
|
|
1177
982
|
"li",
|
|
1178
983
|
{
|
|
1179
984
|
role: "treeitem",
|
|
@@ -1182,7 +987,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1182
987
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1183
988
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1184
989
|
children: [
|
|
1185
|
-
/* @__PURE__ */
|
|
990
|
+
/* @__PURE__ */ jsx8(
|
|
1186
991
|
"button",
|
|
1187
992
|
{
|
|
1188
993
|
type: "button",
|
|
@@ -1195,7 +1000,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1195
1000
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1196
1001
|
}
|
|
1197
1002
|
),
|
|
1198
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1003
|
+
renaming === l.id ? /* @__PURE__ */ jsx8(
|
|
1199
1004
|
"input",
|
|
1200
1005
|
{
|
|
1201
1006
|
autoFocus: true,
|
|
@@ -1212,23 +1017,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1212
1017
|
if (e.key === "Escape") setRenaming(null);
|
|
1213
1018
|
}
|
|
1214
1019
|
}
|
|
1215
|
-
) : /* @__PURE__ */
|
|
1020
|
+
) : /* @__PURE__ */ jsxs7("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1216
1021
|
l.type === "group" ? "\u25B8 " : "",
|
|
1217
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1022
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs7("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1218
1023
|
"\u270E",
|
|
1219
1024
|
" "
|
|
1220
1025
|
] }),
|
|
1221
1026
|
l.name
|
|
1222
1027
|
] }),
|
|
1223
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1028
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx8("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1224
1029
|
]
|
|
1225
1030
|
},
|
|
1226
1031
|
l.id
|
|
1227
1032
|
)) }),
|
|
1228
|
-
active && /* @__PURE__ */
|
|
1229
|
-
/* @__PURE__ */
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1033
|
+
active && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5", children: [
|
|
1034
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1035
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1036
|
+
/* @__PURE__ */ jsx8(
|
|
1232
1037
|
"input",
|
|
1233
1038
|
{
|
|
1234
1039
|
type: "range",
|
|
@@ -1242,40 +1047,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1242
1047
|
}
|
|
1243
1048
|
)
|
|
1244
1049
|
] }),
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
active.type === "group" && /* @__PURE__ */
|
|
1249
|
-
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */
|
|
1050
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1051
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1052
|
+
/* @__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: [
|
|
1053
|
+
active.type === "group" && /* @__PURE__ */ jsx8("option", { value: "pass-through", children: "Pass through" }),
|
|
1054
|
+
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
1055
|
] })
|
|
1251
1056
|
] }),
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1057
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex gap-1", children: [
|
|
1058
|
+
["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)),
|
|
1059
|
+
/* @__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
1060
|
] }),
|
|
1256
|
-
light?.hasLight && /* @__PURE__ */
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1061
|
+
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: [
|
|
1062
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
|
|
1063
|
+
/* @__PURE__ */ jsx8("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1064
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1260
1065
|
] }),
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
/* @__PURE__ */
|
|
1263
|
-
/* @__PURE__ */
|
|
1066
|
+
/* @__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: [
|
|
1067
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1068
|
+
/* @__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
1069
|
] }),
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
/* @__PURE__ */
|
|
1070
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1071
|
+
/* @__PURE__ */ jsx8("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1072
|
+
/* @__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
1073
|
] })
|
|
1269
1074
|
] }),
|
|
1270
|
-
/* @__PURE__ */
|
|
1075
|
+
/* @__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
1076
|
] }),
|
|
1272
|
-
/* @__PURE__ */
|
|
1077
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
1273
1078
|
] });
|
|
1274
1079
|
};
|
|
1275
1080
|
|
|
1276
1081
|
// src/paint-editor/WetPanel.tsx
|
|
1277
1082
|
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
|
|
1083
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1279
1084
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1280
1085
|
var WetPanel = ({ controller, className }) => {
|
|
1281
1086
|
const state = usePaintEditorState(controller);
|
|
@@ -1284,31 +1089,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1284
1089
|
const layerId = state.document.activeLayerId;
|
|
1285
1090
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1286
1091
|
const backend = controller.wetState();
|
|
1287
|
-
return /* @__PURE__ */
|
|
1288
|
-
/* @__PURE__ */
|
|
1289
|
-
/* @__PURE__ */
|
|
1290
|
-
/* @__PURE__ */
|
|
1092
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1093
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
1094
|
+
/* @__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" }),
|
|
1095
|
+
/* @__PURE__ */ jsxs8("span", { className: "text-[10px] text-slate-500", children: [
|
|
1291
1096
|
"step ",
|
|
1292
1097
|
wet.clock
|
|
1293
1098
|
] })
|
|
1294
1099
|
] }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1297
|
-
/* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1300
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-1", children: [
|
|
1101
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1102
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1103
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1104
|
+
/* @__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" }),
|
|
1105
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1301
1106
|
] }),
|
|
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__ */
|
|
1107
|
+
/* @__PURE__ */ jsx9(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1108
|
+
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)),
|
|
1109
|
+
info && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1110
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1111
|
+
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)),
|
|
1112
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1113
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1114
|
+
/* @__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
1115
|
] }),
|
|
1311
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1116
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx9(
|
|
1312
1117
|
PaintSlider,
|
|
1313
1118
|
{
|
|
1314
1119
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1317,20 +1122,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1317
1122
|
}
|
|
1318
1123
|
)
|
|
1319
1124
|
] }),
|
|
1320
|
-
backend.message && /* @__PURE__ */
|
|
1321
|
-
backend.backend && /* @__PURE__ */
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */
|
|
1324
|
-
/* @__PURE__ */
|
|
1125
|
+
backend.message && /* @__PURE__ */ jsx9("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1126
|
+
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" }),
|
|
1127
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1128
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Engine" }),
|
|
1129
|
+
/* @__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
1130
|
] }),
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
/* @__PURE__ */
|
|
1131
|
+
/* @__PURE__ */ jsx9("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1132
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
1328
1133
|
] });
|
|
1329
1134
|
};
|
|
1330
1135
|
|
|
1331
1136
|
// src/paint-editor/StickerPanel.tsx
|
|
1332
1137
|
import { STICKER_SLIDERS, readPath as readPath3, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1333
|
-
import { jsx as
|
|
1138
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1334
1139
|
var StickerPanel = ({ controller, className }) => {
|
|
1335
1140
|
const state = usePaintEditorState(controller);
|
|
1336
1141
|
const [error, attempt] = useAttempt();
|
|
@@ -1340,16 +1145,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1340
1145
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1341
1146
|
if (!stickers.length) return null;
|
|
1342
1147
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1343
|
-
return /* @__PURE__ */
|
|
1344
|
-
/* @__PURE__ */
|
|
1148
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1149
|
+
/* @__PURE__ */ jsxs9("span", { className: "font-medium text-slate-300", children: [
|
|
1345
1150
|
"Stickers (",
|
|
1346
1151
|
stickers.length,
|
|
1347
1152
|
")"
|
|
1348
1153
|
] }),
|
|
1349
|
-
/* @__PURE__ */
|
|
1350
|
-
sel && /* @__PURE__ */
|
|
1351
|
-
/* @__PURE__ */
|
|
1352
|
-
/* @__PURE__ */
|
|
1154
|
+
/* @__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)) }),
|
|
1155
|
+
sel && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1156
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1157
|
+
/* @__PURE__ */ jsx10(
|
|
1353
1158
|
StickerPicker,
|
|
1354
1159
|
{
|
|
1355
1160
|
controller,
|
|
@@ -1363,9 +1168,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1363
1168
|
)
|
|
1364
1169
|
}
|
|
1365
1170
|
),
|
|
1366
|
-
/* @__PURE__ */
|
|
1367
|
-
/* @__PURE__ */
|
|
1368
|
-
/* @__PURE__ */
|
|
1171
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1172
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Position" }),
|
|
1173
|
+
/* @__PURE__ */ jsx10("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx10(
|
|
1369
1174
|
"input",
|
|
1370
1175
|
{
|
|
1371
1176
|
type: "number",
|
|
@@ -1379,24 +1184,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1379
1184
|
`${sel.id}-${k}-${sel[k]}`
|
|
1380
1185
|
)) })
|
|
1381
1186
|
] }),
|
|
1382
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1383
|
-
/* @__PURE__ */
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1187
|
+
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)),
|
|
1188
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between", children: [
|
|
1189
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Colour" }),
|
|
1190
|
+
/* @__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
1191
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1388
|
-
/* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
/* @__PURE__ */
|
|
1192
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", children: [
|
|
1193
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1194
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1195
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1391
1196
|
] })
|
|
1392
1197
|
] }),
|
|
1393
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1394
1199
|
] });
|
|
1395
1200
|
};
|
|
1396
1201
|
|
|
1397
1202
|
// src/paint-editor/StrokePanel.tsx
|
|
1398
1203
|
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath4 } from "@pixerate/editor/paint-editor";
|
|
1399
|
-
import { jsx as
|
|
1204
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1400
1205
|
var StrokePanel = ({ controller, className }) => {
|
|
1401
1206
|
const state = usePaintEditorState(controller);
|
|
1402
1207
|
const [error, attempt] = useAttempt();
|
|
@@ -1406,16 +1211,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1406
1211
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1407
1212
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1408
1213
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1409
|
-
return /* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1214
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1215
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1216
|
+
/* @__PURE__ */ jsxs10("span", { className: "font-medium text-slate-300", children: [
|
|
1412
1217
|
"Strokes (",
|
|
1413
1218
|
strokes.length,
|
|
1414
1219
|
")"
|
|
1415
1220
|
] }),
|
|
1416
|
-
/* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1417
1222
|
] }),
|
|
1418
|
-
/* @__PURE__ */
|
|
1223
|
+
/* @__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
1224
|
"button",
|
|
1420
1225
|
{
|
|
1421
1226
|
type: "button",
|
|
@@ -1428,10 +1233,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1428
1233
|
},
|
|
1429
1234
|
s.id
|
|
1430
1235
|
)) }),
|
|
1431
|
-
sel && /* @__PURE__ */
|
|
1432
|
-
/* @__PURE__ */
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1236
|
+
sel && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1237
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1238
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Brush" }),
|
|
1239
|
+
/* @__PURE__ */ jsxs10(
|
|
1435
1240
|
"select",
|
|
1436
1241
|
{
|
|
1437
1242
|
"aria-label": "Stroke brush",
|
|
@@ -1439,41 +1244,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1439
1244
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1440
1245
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1441
1246
|
children: [
|
|
1442
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1443
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1247
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx11("option", { value: "", children: sel.brush.name }),
|
|
1248
|
+
brushes.map((b) => /* @__PURE__ */ jsx11("option", { value: b.id, children: b.name }, b.id))
|
|
1444
1249
|
]
|
|
1445
1250
|
}
|
|
1446
1251
|
)
|
|
1447
1252
|
] }),
|
|
1448
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1449
|
-
/* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1451
|
-
/* @__PURE__ */
|
|
1253
|
+
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)),
|
|
1254
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between", children: [
|
|
1255
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Colour" }),
|
|
1256
|
+
/* @__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
1257
|
] }),
|
|
1453
|
-
/* @__PURE__ */
|
|
1454
|
-
/* @__PURE__ */
|
|
1455
|
-
/* @__PURE__ */
|
|
1456
|
-
/* @__PURE__ */
|
|
1457
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1259
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1260
|
+
/* @__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" }),
|
|
1261
|
+
/* @__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" }),
|
|
1262
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1458
1263
|
] })
|
|
1459
1264
|
] }),
|
|
1460
|
-
/* @__PURE__ */
|
|
1265
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1461
1266
|
] });
|
|
1462
1267
|
};
|
|
1463
1268
|
|
|
1464
1269
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1465
|
-
import { useState as
|
|
1270
|
+
import { useState as useState7 } from "react";
|
|
1466
1271
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1467
|
-
import { jsx as
|
|
1272
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1468
1273
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1469
1274
|
const state = usePaintEditorState(controller);
|
|
1470
1275
|
const [error, attempt] = useAttempt();
|
|
1471
|
-
const [path, setPath] =
|
|
1472
|
-
const [taper, setTaper] =
|
|
1276
|
+
const [path, setPath] = useState7("");
|
|
1277
|
+
const [taper, setTaper] = useState7(PATH_STROKE_TAPERS[0].id);
|
|
1473
1278
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1474
|
-
return /* @__PURE__ */
|
|
1475
|
-
/* @__PURE__ */
|
|
1476
|
-
/* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1280
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1281
|
+
/* @__PURE__ */ jsx12(
|
|
1477
1282
|
"textarea",
|
|
1478
1283
|
{
|
|
1479
1284
|
"aria-label": "SVG path data",
|
|
@@ -1484,25 +1289,25 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1484
1289
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1485
1290
|
}
|
|
1486
1291
|
),
|
|
1487
|
-
/* @__PURE__ */
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
/* @__PURE__ */
|
|
1292
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2", children: [
|
|
1293
|
+
/* @__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)) }),
|
|
1294
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1490
1295
|
] }),
|
|
1491
|
-
/* @__PURE__ */
|
|
1296
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1492
1297
|
] });
|
|
1493
1298
|
};
|
|
1494
1299
|
|
|
1495
1300
|
// src/paint-editor/PaintEditor.tsx
|
|
1496
|
-
import { useRef as
|
|
1301
|
+
import { useRef as useRef7, useState as useState9 } from "react";
|
|
1497
1302
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1498
1303
|
|
|
1499
1304
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1500
|
-
import { useEffect as
|
|
1305
|
+
import { useEffect as useEffect4, useMemo as useMemo6, useRef as useRef6, useState as useState8 } from "react";
|
|
1501
1306
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1502
|
-
import { jsx as
|
|
1307
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1503
1308
|
function usePaintEffectsProvider(controller) {
|
|
1504
|
-
const [provider, setProvider] =
|
|
1505
|
-
|
|
1309
|
+
const [provider, setProvider] = useState8(controller.effectsProvider);
|
|
1310
|
+
useEffect4(() => {
|
|
1506
1311
|
setProvider(controller.effectsProvider);
|
|
1507
1312
|
return controller.effects.subscribe(setProvider);
|
|
1508
1313
|
}, [controller]);
|
|
@@ -1510,27 +1315,27 @@ function usePaintEffectsProvider(controller) {
|
|
|
1510
1315
|
}
|
|
1511
1316
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
1512
1317
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
1513
|
-
|
|
1318
|
+
useEffect4(() => {
|
|
1514
1319
|
if (!registry) return;
|
|
1515
1320
|
return registry.register(createPaintEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
|
|
1516
1321
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
1517
1322
|
}
|
|
1518
1323
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1519
1324
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1520
|
-
const drags =
|
|
1521
|
-
if (!provider) return /* @__PURE__ */
|
|
1325
|
+
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1326
|
+
if (!provider) return /* @__PURE__ */ jsxs12("p", { className: "text-[11px] text-slate-400", children: [
|
|
1522
1327
|
'No effects provider: "',
|
|
1523
1328
|
name ?? effect,
|
|
1524
1329
|
'" is kept as it was drawn.'
|
|
1525
1330
|
] });
|
|
1526
|
-
if (error) return /* @__PURE__ */
|
|
1527
|
-
if (!description) return /* @__PURE__ */
|
|
1331
|
+
if (error) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1332
|
+
if (!description) return /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1528
1333
|
const commit = (gesture) => {
|
|
1529
1334
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1530
1335
|
drags.current.add(gesture);
|
|
1531
1336
|
return true;
|
|
1532
1337
|
};
|
|
1533
|
-
return /* @__PURE__ */
|
|
1338
|
+
return /* @__PURE__ */ jsx13(
|
|
1534
1339
|
EffectParameters,
|
|
1535
1340
|
{
|
|
1536
1341
|
description,
|
|
@@ -1552,8 +1357,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1552
1357
|
const state = usePaintEditorState(controller);
|
|
1553
1358
|
const provider = usePaintEffectsProvider(controller);
|
|
1554
1359
|
const [error, attempt] = useAttempt();
|
|
1555
|
-
const [browse, setBrowse] =
|
|
1556
|
-
const [busy, setBusy] =
|
|
1360
|
+
const [browse, setBrowse] = useState8(null);
|
|
1361
|
+
const [busy, setBusy] = useState8(false);
|
|
1557
1362
|
const paper = controller.getPaperEffect();
|
|
1558
1363
|
const activeId = state.document.activeLayerId;
|
|
1559
1364
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1565,7 +1370,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1565
1370
|
if (!effectPaint) return;
|
|
1566
1371
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1567
1372
|
};
|
|
1568
|
-
const thumbnail =
|
|
1373
|
+
const thumbnail = useMemo6(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1569
1374
|
const run = (work) => attempt(() => {
|
|
1570
1375
|
setBusy(true);
|
|
1571
1376
|
return work().finally(() => setBusy(false));
|
|
@@ -1581,28 +1386,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1581
1386
|
};
|
|
1582
1387
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1583
1388
|
const pixel = active?.type === "pixel";
|
|
1584
|
-
return /* @__PURE__ */
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
/* @__PURE__ */
|
|
1591
|
-
/* @__PURE__ */
|
|
1389
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1390
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1391
|
+
/* @__PURE__ */ jsx13("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1392
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1393
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1394
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1395
|
+
/* @__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" }),
|
|
1396
|
+
/* @__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
1397
|
] }),
|
|
1593
|
-
!provider && /* @__PURE__ */
|
|
1594
|
-
browse && /* @__PURE__ */
|
|
1595
|
-
paper && /* @__PURE__ */
|
|
1596
|
-
/* @__PURE__ */
|
|
1597
|
-
/* @__PURE__ */
|
|
1398
|
+
!provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1399
|
+
browse && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1400
|
+
paper && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1401
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1402
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1598
1403
|
"Paper: ",
|
|
1599
1404
|
paper.name ?? paper.effect
|
|
1600
1405
|
] }),
|
|
1601
|
-
/* @__PURE__ */
|
|
1406
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1602
1407
|
] }),
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */
|
|
1605
|
-
/* @__PURE__ */
|
|
1408
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1409
|
+
/* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1410
|
+
/* @__PURE__ */ jsx13(
|
|
1606
1411
|
"input",
|
|
1607
1412
|
{
|
|
1608
1413
|
type: "range",
|
|
@@ -1624,39 +1429,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1624
1429
|
`o${paper.opacity}`
|
|
1625
1430
|
)
|
|
1626
1431
|
] }),
|
|
1627
|
-
/* @__PURE__ */
|
|
1628
|
-
/* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1432
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1433
|
+
/* @__PURE__ */ jsx13("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1434
|
+
/* @__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
1435
|
const blend = e.currentTarget.value;
|
|
1631
1436
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1632
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1437
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx13("option", { value: b, children: b }, b)) })
|
|
1633
1438
|
] }),
|
|
1634
|
-
/* @__PURE__ */
|
|
1439
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1635
1440
|
] }),
|
|
1636
|
-
effectPaint && /* @__PURE__ */
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
thumbnail ? /* @__PURE__ */
|
|
1639
|
-
/* @__PURE__ */
|
|
1441
|
+
effectPaint && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1442
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1443
|
+
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,
|
|
1444
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1640
1445
|
"Paint: ",
|
|
1641
1446
|
effectPaint.effect,
|
|
1642
1447
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1643
1448
|
] }),
|
|
1644
|
-
/* @__PURE__ */
|
|
1449
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1645
1450
|
] }),
|
|
1646
|
-
/* @__PURE__ */
|
|
1647
|
-
/* @__PURE__ */
|
|
1648
|
-
/* @__PURE__ */
|
|
1451
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1452
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1453
|
+
/* @__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
1454
|
"Along the stroke"
|
|
1650
1455
|
] }),
|
|
1651
|
-
/* @__PURE__ */
|
|
1652
|
-
/* @__PURE__ */
|
|
1456
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1457
|
+
/* @__PURE__ */ jsx13("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1653
1458
|
"Live"
|
|
1654
1459
|
] })
|
|
1655
1460
|
] }),
|
|
1656
|
-
effectPaint.map && /* @__PURE__ */
|
|
1657
|
-
/* @__PURE__ */
|
|
1658
|
-
/* @__PURE__ */
|
|
1659
|
-
/* @__PURE__ */
|
|
1461
|
+
effectPaint.map && /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1462
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1463
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Length" }),
|
|
1464
|
+
/* @__PURE__ */ jsx13(
|
|
1660
1465
|
"input",
|
|
1661
1466
|
{
|
|
1662
1467
|
type: "number",
|
|
@@ -1670,55 +1475,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1670
1475
|
effectPaint.map.length
|
|
1671
1476
|
)
|
|
1672
1477
|
] }),
|
|
1673
|
-
/* @__PURE__ */
|
|
1674
|
-
/* @__PURE__ */
|
|
1675
|
-
/* @__PURE__ */
|
|
1676
|
-
/* @__PURE__ */
|
|
1478
|
+
/* @__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: [
|
|
1479
|
+
/* @__PURE__ */ jsx13("option", { value: "repeat", children: "Repeat" }),
|
|
1480
|
+
/* @__PURE__ */ jsx13("option", { value: "mirror", children: "Mirror" }),
|
|
1481
|
+
/* @__PURE__ */ jsx13("option", { value: "clamp", children: "Clamp" })
|
|
1677
1482
|
] })
|
|
1678
1483
|
] }),
|
|
1679
|
-
/* @__PURE__ */
|
|
1484
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1680
1485
|
] }),
|
|
1681
|
-
animation && /* @__PURE__ */
|
|
1682
|
-
/* @__PURE__ */
|
|
1486
|
+
animation && /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1487
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1683
1488
|
"Live paint: ",
|
|
1684
1489
|
animation.strokes,
|
|
1685
1490
|
" ",
|
|
1686
1491
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1687
1492
|
] }),
|
|
1688
|
-
/* @__PURE__ */
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
1691
|
-
/* @__PURE__ */
|
|
1493
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1494
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center gap-1", children: [
|
|
1495
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "fps" }),
|
|
1496
|
+
/* @__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
1497
|
] })
|
|
1693
1498
|
] }),
|
|
1694
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1695
|
-
/* @__PURE__ */
|
|
1696
|
-
/* @__PURE__ */
|
|
1499
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1500
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1", children: [
|
|
1501
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex-1 truncate", children: [
|
|
1697
1502
|
"Layer: ",
|
|
1698
1503
|
layerEffect.name ?? layerEffect.effect
|
|
1699
1504
|
] }),
|
|
1700
|
-
/* @__PURE__ */
|
|
1505
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1701
1506
|
] }),
|
|
1702
|
-
/* @__PURE__ */
|
|
1507
|
+
/* @__PURE__ */ jsx13(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1703
1508
|
] }),
|
|
1704
|
-
/* @__PURE__ */
|
|
1509
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1705
1510
|
] });
|
|
1706
1511
|
};
|
|
1707
1512
|
|
|
1708
1513
|
// src/paint-editor/PaintEditor.tsx
|
|
1709
|
-
import { jsx as
|
|
1514
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1710
1515
|
var PAINT_CONTROLS = {
|
|
1711
1516
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1712
1517
|
lighting: '[data-testid="light-panel"]',
|
|
1713
1518
|
symmetry: '[aria-label="Symmetry"]'
|
|
1714
1519
|
};
|
|
1715
1520
|
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 =
|
|
1521
|
+
const [tool, setTool] = useState9("brush");
|
|
1522
|
+
const [tab, setTab] = useState9("color");
|
|
1523
|
+
const tabRef = useRef7(tab);
|
|
1719
1524
|
tabRef.current = tab;
|
|
1720
|
-
const rootRef =
|
|
1721
|
-
const [ownPresence] =
|
|
1525
|
+
const rootRef = useRef7(null);
|
|
1526
|
+
const [ownPresence] = useState9(() => new PaintPresence2());
|
|
1722
1527
|
const ambientPlayback = useAgentPlayback();
|
|
1723
1528
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1724
1529
|
const viewBox = () => {
|
|
@@ -1774,29 +1579,29 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1774
1579
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1775
1580
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1776
1581
|
};
|
|
1777
|
-
const [error, setError] =
|
|
1582
|
+
const [error, setError] = useState9(null);
|
|
1778
1583
|
const effects = usePaintEffectsProvider(controller);
|
|
1779
1584
|
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__ */
|
|
1585
|
+
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: [
|
|
1586
|
+
playing && /* @__PURE__ */ jsx14(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1587
|
+
/* @__PURE__ */ jsx14(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1588
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1589
|
+
/* @__PURE__ */ jsx14(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1590
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1591
|
+
/* @__PURE__ */ jsx14(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, className: "flex-1 rounded-lg" }),
|
|
1592
|
+
error && /* @__PURE__ */ jsx14("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1788
1593
|
] }),
|
|
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__ */
|
|
1594
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1595
|
+
/* @__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)) }),
|
|
1596
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1597
|
+
tab === "color" && /* @__PURE__ */ jsx14(ColorPanel, { controller }),
|
|
1598
|
+
tab === "wet" && /* @__PURE__ */ jsx14(WetPanel, { controller }),
|
|
1599
|
+
tab === "paper" && /* @__PURE__ */ jsx14(PaperPanel, { controller }),
|
|
1600
|
+
tab === "layers" && /* @__PURE__ */ jsx14(PaintLayersPanel, { controller }),
|
|
1601
|
+
tab === "layers" && /* @__PURE__ */ jsx14(StrokePanel, { controller }),
|
|
1602
|
+
tab === "layers" && /* @__PURE__ */ jsx14(PathStrokePanel, { controller }),
|
|
1603
|
+
tab === "layers" && /* @__PURE__ */ jsx14(StickerPanel, { controller }),
|
|
1604
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx14(PaintEffectsPanel, { controller })
|
|
1800
1605
|
] })
|
|
1801
1606
|
] })
|
|
1802
1607
|
] })
|