@pixerate/editor-react 0.171.0 → 0.172.1
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/animation-editor/index.cjs +1 -1
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-2UD3JH4W.js → chunk-NQ22NA7S.js} +1 -1
- package/dist/{chunk-TOYSB4DK.js → chunk-W6UZ7PVT.js} +1 -1
- package/dist/effects/index.cjs +1 -1
- package/dist/effects/index.js +1 -1
- package/dist/image-editor/index.cjs +1 -1
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/paint-editor/BrushEditor.d.cts +29 -0
- package/dist/paint-editor/BrushEditor.d.ts +29 -0
- package/dist/paint-editor/BrushLibraryBrowser.d.cts +24 -0
- package/dist/paint-editor/BrushLibraryBrowser.d.ts +24 -0
- package/dist/paint-editor/BrushPanel.d.cts +5 -6
- package/dist/paint-editor/BrushPanel.d.ts +5 -6
- package/dist/paint-editor/index.cjs +832 -805
- package/dist/paint-editor/index.d.cts +2 -0
- package/dist/paint-editor/index.d.ts +2 -0
- package/dist/paint-editor/index.js +477 -483
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +1 -1
- package/dist/video-editor/index.js +1 -1
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
EffectParameters,
|
|
10
10
|
EffectsBrowser,
|
|
11
11
|
useEffectDescription
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-W6UZ7PVT.js";
|
|
13
13
|
import "../chunk-5RPB4WGT.js";
|
|
14
14
|
import "../chunk-KIRIU53A.js";
|
|
15
15
|
import "../chunk-3I7FOSLF.js";
|
|
@@ -574,61 +574,156 @@ var PaintToolbar = ({ controller, tool, onToolChange, fileName = "painting", cla
|
|
|
574
574
|
};
|
|
575
575
|
|
|
576
576
|
// src/paint-editor/BrushPanel.tsx
|
|
577
|
-
import { useMemo as
|
|
578
|
-
import {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
577
|
+
import { useMemo as useMemo5, useRef as useRef4 } from "react";
|
|
578
|
+
import { brushLoadColor, brushTakesPaint, downloadBytes as downloadBytes2, toggleStickerRef, DEFAULT_PAINT_GRADIENT } from "@pixerate/editor/paint-editor";
|
|
579
|
+
import { PAINT_PROFILE as PAINT_PROFILE2 } from "@pixerate/editor/brushes";
|
|
580
|
+
|
|
581
|
+
// src/paint-editor/BrushEditor.tsx
|
|
582
|
+
import { useMemo as useMemo3, useState as useState5 } from "react";
|
|
583
|
+
import { brushEditorSections, PAINT_PROFILE, setBrushEditorValue } from "@pixerate/editor/brushes";
|
|
584
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
585
|
+
var BrushEditor = ({ brush, profile = PAINT_PROFILE, onChange, preview, onSaveAs, renderExtra, className }) => {
|
|
586
|
+
const sections = useMemo3(() => brushEditorSections(brush, profile), [brush, profile]);
|
|
587
|
+
const [problems, setProblems] = useState5(null);
|
|
588
|
+
const [name, setName] = useState5("");
|
|
589
|
+
const set = (path, value) => {
|
|
590
|
+
const r = setBrushEditorValue(brush, path, value);
|
|
591
|
+
setProblems(r.problems.length ? r.problems.join(" ") : null);
|
|
592
|
+
if (r.brush !== brush) onChange(r.brush);
|
|
593
|
+
};
|
|
594
|
+
return /* @__PURE__ */ jsxs4("div", { className: `flex flex-col gap-2 ${className ?? ""}`, "data-testid": "brush-editor", children: [
|
|
595
|
+
preview !== void 0 && /* @__PURE__ */ jsx4(PixelCanvas, { pixels: preview, label: "Brush preview", className: "rounded", style: { width: "100%", aspectRatio: preview ? `${preview.width} / ${preview.height}` : "4 / 1" } }),
|
|
596
|
+
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: [
|
|
597
|
+
/* @__PURE__ */ jsx4("span", { className: "font-medium text-slate-300", children: s.title }),
|
|
598
|
+
s.controls.map((c) => /* @__PURE__ */ jsx4(EditorControl, { control: c, onSet: set }, c.path)),
|
|
599
|
+
renderExtra?.(s.id)
|
|
600
|
+
] }, s.id)),
|
|
601
|
+
onSaveAs && /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
602
|
+
/* @__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" }),
|
|
603
|
+
/* @__PURE__ */ jsx4(
|
|
604
|
+
"button",
|
|
605
|
+
{
|
|
606
|
+
type: "button",
|
|
607
|
+
className: button,
|
|
608
|
+
disabled: !name.trim(),
|
|
609
|
+
onClick: async () => {
|
|
610
|
+
try {
|
|
611
|
+
await onSaveAs(name.trim());
|
|
612
|
+
setName("");
|
|
613
|
+
setProblems(null);
|
|
614
|
+
} catch (e) {
|
|
615
|
+
setProblems(e.message);
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
children: "Save brush"
|
|
619
|
+
}
|
|
620
|
+
)
|
|
621
|
+
] }),
|
|
622
|
+
/* @__PURE__ */ jsx4(ErrorLine, { error: problems })
|
|
623
|
+
] });
|
|
624
|
+
};
|
|
625
|
+
var EditorControl = ({ control: c, onSet }) => {
|
|
626
|
+
const note = c.note ? /* @__PURE__ */ jsx4("span", { className: "text-[10px] text-amber-400", children: c.note }) : null;
|
|
627
|
+
switch (c.kind) {
|
|
628
|
+
case "slider":
|
|
629
|
+
return /* @__PURE__ */ jsxs4("div", { title: c.note, children: [
|
|
630
|
+
/* @__PURE__ */ jsx4(PaintSlider, { control: c, value: c.value, onChange: (v) => onSet(c.path, v) }),
|
|
631
|
+
note
|
|
632
|
+
] });
|
|
633
|
+
case "choice":
|
|
634
|
+
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center justify-between gap-2", title: c.note, children: [
|
|
635
|
+
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
636
|
+
/* @__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)) })
|
|
637
|
+
] });
|
|
638
|
+
case "toggle":
|
|
639
|
+
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center gap-2", title: c.note, children: [
|
|
640
|
+
/* @__PURE__ */ jsx4("input", { type: "checkbox", "aria-label": c.ariaLabel, checked: c.value, onChange: (e) => onSet(c.path, e.target.checked) }),
|
|
641
|
+
" ",
|
|
642
|
+
c.label
|
|
643
|
+
] });
|
|
644
|
+
case "text":
|
|
645
|
+
return /* @__PURE__ */ jsxs4("label", { className: "flex items-center justify-between gap-2", children: [
|
|
646
|
+
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
647
|
+
/* @__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)
|
|
648
|
+
] });
|
|
649
|
+
case "colour":
|
|
650
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between gap-2", children: [
|
|
651
|
+
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
652
|
+
/* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-1", children: [
|
|
653
|
+
/* @__PURE__ */ jsx4("input", { type: "color", "aria-label": c.ariaLabel, value: c.value ?? "#000000", onChange: (e) => onSet(c.path, e.target.value), className: "h-5 w-8" }),
|
|
654
|
+
c.value && /* @__PURE__ */ jsx4("button", { type: "button", className: button, onClick: () => onSet(c.path, void 0), children: "None" })
|
|
655
|
+
] })
|
|
656
|
+
] });
|
|
657
|
+
case "palette":
|
|
658
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center gap-1", role: "group", "aria-label": c.ariaLabel, children: [
|
|
659
|
+
/* @__PURE__ */ jsx4("span", { className: "text-slate-400", children: c.label }),
|
|
660
|
+
c.value.map((col, i) => /* @__PURE__ */ jsx4("button", { type: "button", title: `Remove ${col}`, "aria-label": `Remove ${col}`, className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: col }, onClick: () => onSet(c.path, c.value.filter((_, j) => j !== i)) }, `${col}-${i}`)),
|
|
661
|
+
c.value.length < c.max && /* @__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" })
|
|
662
|
+
] });
|
|
663
|
+
case "stamps":
|
|
664
|
+
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) => {
|
|
665
|
+
const on = c.value.includes(o.value);
|
|
666
|
+
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);
|
|
667
|
+
}) });
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
// src/paint-editor/BrushLibraryBrowser.tsx
|
|
672
|
+
import { useMemo as useMemo4, useState as useState6 } from "react";
|
|
673
|
+
import { brushLibraryGroups } from "@pixerate/editor/brushes";
|
|
674
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
675
|
+
var BrushLibraryBrowser = ({ entries, activeId, onSelect, profile, thumbnail, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
676
|
+
const [text, setText] = useState6("");
|
|
677
|
+
const groups = useMemo4(() => brushLibraryGroups(entries, { text, profile }), [entries, text, profile]);
|
|
678
|
+
return /* @__PURE__ */ jsxs5("div", { className: `flex flex-col gap-1 ${className ?? ""}`, "data-testid": "brush-library", children: [
|
|
679
|
+
/* @__PURE__ */ jsx5("input", { type: "search", value: text, placeholder: "Find a brush", "aria-label": "Find a brush", onChange: (e) => setText(e.target.value), className: "rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
680
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", role: "listbox", "aria-label": "Brushes", children: [
|
|
681
|
+
groups.map((g) => /* @__PURE__ */ jsxs5("div", { role: "group", "aria-label": g.title, className: "flex flex-col gap-0.5", children: [
|
|
682
|
+
/* @__PURE__ */ jsx5("span", { className: "text-[10px] uppercase tracking-wide text-slate-500", children: g.title }),
|
|
683
|
+
/* @__PURE__ */ jsx5("div", { className: "grid grid-cols-2 gap-1", children: g.varieties.flatMap(
|
|
684
|
+
(v) => v.entries.map((e) => /* @__PURE__ */ jsxs5(
|
|
685
|
+
"button",
|
|
686
|
+
{
|
|
687
|
+
type: "button",
|
|
688
|
+
role: "option",
|
|
689
|
+
"aria-selected": activeId === e.brush.id,
|
|
690
|
+
title: [e.brush.name, v.title.toLowerCase() === e.brush.name.toLowerCase() ? "" : v.title, e.builtin ? "" : "saved"].filter(Boolean).join(" \xB7 "),
|
|
691
|
+
className: `flex flex-col items-start gap-0.5 rounded p-1 text-left ${activeId === e.brush.id ? "bg-indigo-600/30 ring-1 ring-indigo-500" : "bg-slate-900 hover:bg-slate-800"}`,
|
|
692
|
+
onClick: () => onSelect(e.brush.id),
|
|
693
|
+
children: [
|
|
694
|
+
thumbnail && /* @__PURE__ */ jsx5(PixelCanvas, { pixels: thumbnail(e.brush.id), label: `${e.brush.name} thumbnail`, className: "rounded", style: { width: "100%", aspectRatio: `${thumbnailWidth} / ${thumbnailHeight}` } }),
|
|
695
|
+
/* @__PURE__ */ jsx5("span", { className: "truncate text-[10px] text-slate-300", children: e.brush.name })
|
|
696
|
+
]
|
|
697
|
+
},
|
|
698
|
+
e.brush.id
|
|
699
|
+
))
|
|
700
|
+
) })
|
|
701
|
+
] }, g.id)),
|
|
702
|
+
!groups.length && /* @__PURE__ */ jsx5("span", { className: "text-slate-500", children: "No brush matches." })
|
|
703
|
+
] })
|
|
704
|
+
] });
|
|
705
|
+
};
|
|
611
706
|
|
|
612
707
|
// src/paint-editor/PaintGradientEditor.tsx
|
|
613
708
|
import { PAINT_GRADIENT_KIT } from "@pixerate/editor/paint-editor";
|
|
614
|
-
import { jsx as
|
|
615
|
-
var PaintGradientEditor = (props) => /* @__PURE__ */
|
|
709
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
710
|
+
var PaintGradientEditor = (props) => /* @__PURE__ */ jsx6(PaintGradientEditorView, { ...props, kit: PAINT_GRADIENT_KIT });
|
|
616
711
|
|
|
617
712
|
// src/paint-editor/StickerPicker.tsx
|
|
618
|
-
import { useEffect as useEffect4, useState as
|
|
619
|
-
import { jsx as
|
|
713
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
714
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
620
715
|
var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
621
|
-
const [provider, setProvider] =
|
|
716
|
+
const [provider, setProvider] = useState7(() => controller.stickersProvider);
|
|
622
717
|
useEffect4(() => controller.stickers.subscribe(setProvider), [controller]);
|
|
623
718
|
const failed = selected.map((ref) => ({ ref, ...controller.stickerArtStatus(ref) })).filter((x) => x.status === "failed");
|
|
624
|
-
return /* @__PURE__ */
|
|
719
|
+
return /* @__PURE__ */ jsx7(
|
|
625
720
|
StickerLibraryPicker,
|
|
626
721
|
{
|
|
627
722
|
provider,
|
|
628
723
|
selected,
|
|
629
724
|
label,
|
|
630
725
|
onPick: (it) => onPick(it.ref),
|
|
631
|
-
footer: failed.map((f) => /* @__PURE__ */
|
|
726
|
+
footer: failed.map((f) => /* @__PURE__ */ jsxs6("p", { role: "alert", className: "text-[11px] text-rose-400", children: [
|
|
632
727
|
f.ref,
|
|
633
728
|
": ",
|
|
634
729
|
f.error
|
|
@@ -638,165 +733,62 @@ var StickerPicker = ({ controller, selected, onPick, label = "Stickers" }) => {
|
|
|
638
733
|
};
|
|
639
734
|
|
|
640
735
|
// src/paint-editor/BrushPanel.tsx
|
|
641
|
-
import {
|
|
736
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
642
737
|
var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, className }) => {
|
|
643
738
|
const state = usePaintEditorState(controller);
|
|
644
739
|
const [error, attempt] = useAttempt();
|
|
645
|
-
const [saveName, setSaveName] = useState6("");
|
|
646
740
|
const fileRef = useRef4(null);
|
|
647
741
|
const { brush, brushes } = state;
|
|
648
742
|
const paper = state.document.paper;
|
|
649
|
-
const thumbs =
|
|
743
|
+
const thumbs = useMemo5(
|
|
650
744
|
() => new Map(brushes.map((b) => [b.id, controller.brushThumbnail(b.id, { width: thumbnailWidth, height: thumbnailHeight, color: "#26324a" })])),
|
|
651
745
|
// Thumbnails follow the library and the paper.
|
|
652
746
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
653
747
|
[controller, brushes, paper, thumbnailWidth, thumbnailHeight]
|
|
654
748
|
);
|
|
655
|
-
const
|
|
749
|
+
const entries = useMemo5(() => brushes.map((b) => ({ brush: controller.getBrushSpec(b.id), builtin: Boolean(b.builtin) })), [controller, brushes]);
|
|
750
|
+
const spec = useMemo5(() => controller.getBrushSpec(), [controller, brush]);
|
|
751
|
+
const own = typeof spec.colour?.default === "string" && /^#[0-9a-f]{6}/i.test(spec.colour.default) ? spec.colour.default.slice(0, 7) : void 0;
|
|
752
|
+
const preview = useMemo5(() => controller.brushThumbnail(brush.id, { width: 240, height: 64, color: own }), [controller, brush, paper, state.color, own]);
|
|
656
753
|
const carried = brushLoadColor(state.mixerLoad);
|
|
657
754
|
const slug = (name) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "brush";
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
755
|
+
const loads = ["dab", "mixer", "impasto"].includes(brush.engine) || brush.engine === "wet" && brush.wet.tool === "paint";
|
|
756
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "brush-panel", children: [
|
|
757
|
+
/* @__PURE__ */ jsx8(BrushLibraryBrowser, { entries, activeId: brush.id, onSelect: (id) => controller.setBrush({ id }), thumbnail: (id) => thumbs.get(id) ?? null, thumbnailWidth, thumbnailHeight }),
|
|
758
|
+
/* @__PURE__ */ jsx8(
|
|
759
|
+
BrushEditor,
|
|
661
760
|
{
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
] }),
|
|
694
|
-
engine && /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-engine", children: [
|
|
695
|
-
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: engine.title }),
|
|
696
|
-
engine.wetTool && /* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
697
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Wet tool" }),
|
|
698
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Wet tool", value: brush.wet.tool, onChange: (e) => controller.setBrush({ wet: { tool: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_TOOLS.map((t) => /* @__PURE__ */ jsx6("option", { value: t, children: WET_TOOL_LABELS[t] }, t)) })
|
|
699
|
-
] }),
|
|
700
|
-
engine.wetTool && /* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
701
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Medium" }),
|
|
702
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Wet medium", value: brush.wet.medium, onChange: (e) => controller.setBrush({ wet: { medium: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_MEDIA.map((m) => /* @__PURE__ */ jsx6("option", { value: m, children: WET_MEDIUM_LABELS[m] }, m)) })
|
|
703
|
-
] }),
|
|
704
|
-
engine.particleMenus && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
705
|
-
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
706
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Particles" }),
|
|
707
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Particle kind", value: brush.particle.kind, onChange: (e) => controller.setBrush({ particle: { kind: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: PARTICLE_KINDS.map((k) => /* @__PURE__ */ jsx6("option", { value: k, children: PARTICLE_KIND_LABELS[k] }, k)) })
|
|
708
|
-
] }),
|
|
709
|
-
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
710
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Drawn as" }),
|
|
711
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Particle render", value: brush.particle.render, onChange: (e) => controller.setBrush({ particle: { render: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: PARTICLE_RENDERS.map((k) => /* @__PURE__ */ jsx6("option", { value: k, children: PARTICLE_RENDER_LABELS[k] }, k)) })
|
|
712
|
-
] }),
|
|
713
|
-
brush.particle.render === "ribbon" && /* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
714
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Ribbon joins" }),
|
|
715
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Ribbon pairs", value: brush.particle.ribbonPairs, onChange: (e) => controller.setBrush({ particle: { ribbonPairs: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: RIBBON_PAIRS.map((k) => /* @__PURE__ */ jsx6("option", { value: k, children: RIBBON_PAIR_LABELS[k] }, k)) })
|
|
716
|
-
] }),
|
|
717
|
-
(brush.particle.render === "dot" || brush.particle.render === "sequence") && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
718
|
-
/* @__PURE__ */ jsx6("div", { className: "flex flex-wrap gap-1", role: "group", "aria-label": "Dot textures", title: "Stamps drawn instead of round dots (up to 4; none: round)", children: STAMP_KINDS.map((k) => /* @__PURE__ */ jsx6(
|
|
719
|
-
"button",
|
|
720
|
-
{
|
|
721
|
-
type: "button",
|
|
722
|
-
"aria-pressed": brush.particle.dotTextures.includes(k),
|
|
723
|
-
className: `px-1.5 py-0.5 rounded text-[10px] ${brush.particle.dotTextures.includes(k) ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300"}`,
|
|
724
|
-
onClick: () => controller.setBrush({ particle: { dotTextures: toggleDotTexture(brush.particle.dotTextures, k) } }),
|
|
725
|
-
children: STAMP_LABELS[k]
|
|
726
|
-
},
|
|
727
|
-
k
|
|
728
|
-
)) }),
|
|
729
|
-
brush.particle.dotTextures.length > 0 && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
730
|
-
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
731
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Texture order" }),
|
|
732
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Dot texture order", value: brush.particle.dotTextureOrder, onChange: (e) => controller.setBrush({ particle: { dotTextureOrder: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: DOT_TEXTURE_ORDERS.map((k) => /* @__PURE__ */ jsx6("option", { value: k, children: DOT_TEXTURE_ORDER_LABELS[k] }, k)) })
|
|
733
|
-
] }),
|
|
734
|
-
/* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
735
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Texture turn" }),
|
|
736
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Dot rotation", value: brush.particle.dotRotation, onChange: (e) => controller.setBrush({ particle: { dotRotation: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: DOT_ROTATIONS.map((k) => /* @__PURE__ */ jsx6("option", { value: k, children: DOT_ROTATION_LABELS[k] }, k)) })
|
|
737
|
-
] })
|
|
738
|
-
] })
|
|
739
|
-
] })
|
|
740
|
-
] }),
|
|
741
|
-
engine.stickerStamps && /* @__PURE__ */ jsx6(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) }),
|
|
742
|
-
engine.impastoTool && /* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
743
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Tool" }),
|
|
744
|
-
/* @__PURE__ */ jsx6("select", { "aria-label": "Impasto tool", value: brush.impasto.tool, onChange: (e) => controller.setBrush({ impasto: { tool: e.target.value } }), className: "rounded bg-slate-800 px-1 py-0.5", children: IMPASTO_TOOLS.map((t) => /* @__PURE__ */ jsx6("option", { value: t, children: IMPASTO_TOOL_LABELS[t] }, t)) })
|
|
745
|
-
] }),
|
|
746
|
-
engine.sliders.map((c) => /* @__PURE__ */ jsx6(PaintSlider, { control: c, value: readPath(brush, c.path), onChange: (v) => controller.setBrush(patchPath(brush, c.path, v)) }, c.path)),
|
|
747
|
-
engine.mixingPath && /* @__PURE__ */ jsxs5("label", { className: "flex items-center justify-between gap-2", children: [
|
|
748
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Mixing" }),
|
|
749
|
-
/* @__PURE__ */ jsxs5(
|
|
750
|
-
"select",
|
|
751
|
-
{
|
|
752
|
-
"aria-label": "Brush mixing",
|
|
753
|
-
value: engine.mixingPath === "blender.mixing" ? brush.blender.mixing : engine.mixingPath === "smudge.mixing" ? brush.smudge.mixing : brush.behavior.mixing,
|
|
754
|
-
onChange: (e) => controller.setBrush(patchBrushValue(brush, engine.mixingPath, e.target.value)),
|
|
755
|
-
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
756
|
-
children: [
|
|
757
|
-
/* @__PURE__ */ jsx6("option", { value: "pigment", children: "Pigment" }),
|
|
758
|
-
/* @__PURE__ */ jsx6("option", { value: "rgb", children: "RGB" })
|
|
759
|
-
]
|
|
760
|
-
}
|
|
761
|
-
)
|
|
762
|
-
] }),
|
|
763
|
-
engine.light && brush.light.amount > 0 && /* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", title: "Pressure scales the light the brush lays", children: [
|
|
764
|
-
/* @__PURE__ */ jsx6("input", { type: "checkbox", "aria-label": "Light follows pressure", checked: brush.light.pressure, onChange: (e) => controller.setBrush({ light: { pressure: e.target.checked } }) }),
|
|
765
|
-
" Light follows pressure"
|
|
766
|
-
] }),
|
|
767
|
-
engine.dirty && /* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2", title: "Keep the colour the brush picked up for the next stroke (needs Pick-up above 0)", children: [
|
|
768
|
-
/* @__PURE__ */ jsx6("input", { type: "checkbox", "aria-label": "Dirty brush", checked: brush.behavior.dirty, onChange: (e) => controller.setBrush({ behavior: { dirty: e.target.checked } }) }),
|
|
769
|
-
" Dirty brush"
|
|
770
|
-
] }),
|
|
771
|
-
brushTakesPaint(brush) && /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
772
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-2", children: [
|
|
773
|
-
/* @__PURE__ */ jsx6("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" }),
|
|
774
|
-
/* @__PURE__ */ jsx6(
|
|
775
|
-
"button",
|
|
776
|
-
{
|
|
777
|
-
type: "button",
|
|
778
|
-
"aria-pressed": brush.paint !== null,
|
|
779
|
-
className: chip(brush.paint !== null),
|
|
780
|
-
onClick: () => attempt(() => controller.setBrush({ paint: brush.paint ? null : DEFAULT_PAINT_GRADIENT })),
|
|
781
|
-
children: brush.paint ? "On" : "Off"
|
|
782
|
-
}
|
|
783
|
-
)
|
|
784
|
-
] }),
|
|
785
|
-
brush.paint && /* @__PURE__ */ jsx6(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
786
|
-
] }),
|
|
787
|
-
engine.load && /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
|
|
788
|
-
/* @__PURE__ */ jsx6("span", { className: "text-slate-400", children: "Carries" }),
|
|
789
|
-
/* @__PURE__ */ jsx6("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
790
|
-
brush.engine === "mixer" && /* @__PURE__ */ jsx6("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
791
|
-
/* @__PURE__ */ jsx6("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
792
|
-
] })
|
|
793
|
-
] }),
|
|
794
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
795
|
-
/* @__PURE__ */ jsx6("input", { value: saveName, placeholder: "Brush name", "aria-label": "Brush name", onChange: (e) => setSaveName(e.target.value), className: "w-28 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
796
|
-
/* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: !saveName.trim(), onClick: () => attempt(() => (controller.saveBrush({ id: slug(saveName), name: saveName.trim() }), setSaveName(""))), children: "Save brush" }),
|
|
797
|
-
/* @__PURE__ */ jsx6("button", { type: "button", className: button, onClick: () => attempt(() => downloadBytes2(JSON.stringify(controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
798
|
-
/* @__PURE__ */ jsx6("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
799
|
-
/* @__PURE__ */ jsx6(
|
|
761
|
+
brush: spec,
|
|
762
|
+
profile: PAINT_PROFILE2,
|
|
763
|
+
preview,
|
|
764
|
+
onChange: (next) => attempt(() => controller.setBrushSpec(next)),
|
|
765
|
+
onSaveAs: (name) => controller.saveBrush({ id: slug(name), name }),
|
|
766
|
+
renderExtra: (section) => {
|
|
767
|
+
if (section === "shape" && brush.engine === "sticker")
|
|
768
|
+
return /* @__PURE__ */ jsx8(StickerPicker, { controller, label: "Sticker stamps", selected: brush.sticker.stamps, onPick: (ref) => controller.setBrush({ sticker: { stamps: toggleStickerRef(brush.sticker.stamps, ref) } }) });
|
|
769
|
+
if (section === "behaviour" && loads)
|
|
770
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1", children: [
|
|
771
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-400", children: "Carries" }),
|
|
772
|
+
/* @__PURE__ */ jsx8("span", { "aria-label": "Brush load", title: carried ?? "Clean", className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: carried ?? "transparent" } }),
|
|
773
|
+
brush.engine === "mixer" && /* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => controller.loadMixerBrush(), children: "Load" }),
|
|
774
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => controller.cleanMixerBrush(brush.engine === "mixer"), children: "Clean" })
|
|
775
|
+
] });
|
|
776
|
+
if (section === "colour" && brushTakesPaint(brush))
|
|
777
|
+
return /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5", "data-testid": "brush-gradient", children: [
|
|
778
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between gap-2", children: [
|
|
779
|
+
/* @__PURE__ */ jsx8("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" }),
|
|
780
|
+
/* @__PURE__ */ jsx8("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" })
|
|
781
|
+
] }),
|
|
782
|
+
brush.paint && /* @__PURE__ */ jsx8(PaintGradientEditor, { value: brush.paint, colors: { paint: state.color, secondary: state.secondaryColor }, onChange: (g) => attempt(() => controller.setBrush({ paint: g })) })
|
|
783
|
+
] });
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
789
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(async () => downloadBytes2(JSON.stringify(await controller.exportBrushes(), null, 2), "brushes.json", "application/json")), children: "Export" }),
|
|
790
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => fileRef.current?.click(), children: "Import\u2026" }),
|
|
791
|
+
/* @__PURE__ */ jsx8(
|
|
800
792
|
"input",
|
|
801
793
|
{
|
|
802
794
|
ref: fileRef,
|
|
@@ -812,24 +804,24 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
812
804
|
}
|
|
813
805
|
)
|
|
814
806
|
] }),
|
|
815
|
-
/* @__PURE__ */
|
|
807
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
816
808
|
] });
|
|
817
809
|
};
|
|
818
810
|
|
|
819
811
|
// src/paint-editor/PaperPanel.tsx
|
|
820
|
-
import { useMemo as
|
|
821
|
-
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath
|
|
822
|
-
import { jsx as
|
|
812
|
+
import { useMemo as useMemo6 } from "react";
|
|
813
|
+
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, patchPath, readPath, renderPaper } from "@pixerate/editor/paint-editor";
|
|
814
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
823
815
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
824
816
|
var PaperPanel = ({ controller, className }) => {
|
|
825
817
|
const state = usePaintEditorState(controller);
|
|
826
818
|
const [error, attempt] = useAttempt();
|
|
827
819
|
const paper = state.document.paper;
|
|
828
|
-
const previews =
|
|
829
|
-
return /* @__PURE__ */
|
|
830
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
832
|
-
/* @__PURE__ */
|
|
820
|
+
const previews = useMemo6(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
821
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
822
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs8("div", { children: [
|
|
823
|
+
/* @__PURE__ */ jsx9("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
824
|
+
/* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ jsx9(
|
|
833
825
|
"button",
|
|
834
826
|
{
|
|
835
827
|
type: "button",
|
|
@@ -838,37 +830,37 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
838
830
|
title: p.name,
|
|
839
831
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
840
832
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
841
|
-
children: /* @__PURE__ */
|
|
833
|
+
children: /* @__PURE__ */ jsx9(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
842
834
|
},
|
|
843
835
|
p.preset
|
|
844
836
|
)) })
|
|
845
837
|
] }, family)),
|
|
846
|
-
/* @__PURE__ */
|
|
847
|
-
/* @__PURE__ */
|
|
848
|
-
/* @__PURE__ */
|
|
849
|
-
/* @__PURE__ */
|
|
838
|
+
/* @__PURE__ */ jsx9("div", { className: "text-slate-300", children: paper.name }),
|
|
839
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between", children: [
|
|
840
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Colour" }),
|
|
841
|
+
/* @__PURE__ */ jsx9(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
850
842
|
] }),
|
|
851
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
852
|
-
/* @__PURE__ */
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
843
|
+
PAPER_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper(patchPath(paper, c.path, v))) }, c.path)),
|
|
844
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between", children: [
|
|
845
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
846
|
+
/* @__PURE__ */ jsx9(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" })
|
|
855
847
|
] }),
|
|
856
|
-
/* @__PURE__ */
|
|
857
|
-
/* @__PURE__ */
|
|
848
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
849
|
+
/* @__PURE__ */ jsx9("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
858
850
|
" Mirror tiling"
|
|
859
851
|
] }),
|
|
860
|
-
/* @__PURE__ */
|
|
861
|
-
/* @__PURE__ */
|
|
862
|
-
/* @__PURE__ */
|
|
863
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
864
|
-
/* @__PURE__ */
|
|
852
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
853
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
854
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "Light (thick paint, metallic paper)" }),
|
|
855
|
+
LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
856
|
+
/* @__PURE__ */ jsx9("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" })
|
|
865
857
|
] }),
|
|
866
|
-
/* @__PURE__ */
|
|
858
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
867
859
|
] });
|
|
868
860
|
};
|
|
869
861
|
|
|
870
862
|
// src/paint-editor/ColorPanel.tsx
|
|
871
|
-
import { useMemo as
|
|
863
|
+
import { useMemo as useMemo7, useRef as useRef5, useState as useState8 } from "react";
|
|
872
864
|
import {
|
|
873
865
|
HARMONY_KINDS,
|
|
874
866
|
MIXING_PAD_HEIGHT,
|
|
@@ -885,24 +877,24 @@ import {
|
|
|
885
877
|
wheelPoint
|
|
886
878
|
} from "@pixerate/editor/paint-editor";
|
|
887
879
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
888
|
-
import { jsx as
|
|
880
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
889
881
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
890
882
|
const state = usePaintEditorState(controller);
|
|
891
883
|
const [error, attempt] = useAttempt();
|
|
892
|
-
const [wheel, setWheel] =
|
|
893
|
-
const [kind, setKind] =
|
|
894
|
-
const [padTool, setPadTool] =
|
|
895
|
-
const [sample, setSample] =
|
|
896
|
-
const [parts, setParts] =
|
|
897
|
-
const [padName, setPadName] =
|
|
884
|
+
const [wheel, setWheel] = useState8("ryb");
|
|
885
|
+
const [kind, setKind] = useState8("complementary");
|
|
886
|
+
const [padTool, setPadTool] = useState8("paint");
|
|
887
|
+
const [sample, setSample] = useState8(3);
|
|
888
|
+
const [parts, setParts] = useState8([1, 1]);
|
|
889
|
+
const [padName, setPadName] = useState8("");
|
|
898
890
|
const padPoints = useRef5(null);
|
|
899
|
-
const ring =
|
|
891
|
+
const ring = useMemo7(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
900
892
|
const color = state.color;
|
|
901
|
-
const harmony =
|
|
893
|
+
const harmony = useMemo7(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
902
894
|
const [r, g, b] = parseHexColor(color);
|
|
903
895
|
const hsv = rgbToHsv(r, g, b);
|
|
904
|
-
const effectWell =
|
|
905
|
-
const pad =
|
|
896
|
+
const effectWell = useMemo7(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
897
|
+
const pad = useMemo7(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
906
898
|
const R = wheelSize / 2;
|
|
907
899
|
const mid = R * 0.82;
|
|
908
900
|
const setHsv = (s, v) => controller.setColor(rgbToHexColor(...hsvToRgb(hsv.h, s, v)));
|
|
@@ -914,9 +906,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
914
906
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
915
907
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
916
908
|
};
|
|
917
|
-
return /* @__PURE__ */
|
|
918
|
-
/* @__PURE__ */
|
|
919
|
-
/* @__PURE__ */
|
|
909
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
910
|
+
/* @__PURE__ */ jsxs9("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
911
|
+
/* @__PURE__ */ jsx10(
|
|
920
912
|
"div",
|
|
921
913
|
{
|
|
922
914
|
role: "slider",
|
|
@@ -930,20 +922,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
930
922
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
931
923
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
932
924
|
},
|
|
933
|
-
children: /* @__PURE__ */
|
|
925
|
+
children: /* @__PURE__ */ jsx10(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
934
926
|
}
|
|
935
927
|
),
|
|
936
|
-
/* @__PURE__ */
|
|
928
|
+
/* @__PURE__ */ jsx10("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
937
929
|
const p = wheelPoint(h.angle, mid);
|
|
938
|
-
return /* @__PURE__ */
|
|
930
|
+
return /* @__PURE__ */ jsx10("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);
|
|
939
931
|
}) }),
|
|
940
|
-
/* @__PURE__ */
|
|
932
|
+
/* @__PURE__ */ jsx10("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 } })
|
|
941
933
|
] }),
|
|
942
|
-
/* @__PURE__ */
|
|
943
|
-
/* @__PURE__ */
|
|
944
|
-
/* @__PURE__ */
|
|
945
|
-
/* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
934
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
|
|
935
|
+
/* @__PURE__ */ jsx10("input", { type: "color", "aria-label": "Paint colour", value: color, onChange: (e) => controller.setColor(e.target.value), className: "h-7 w-9 rounded bg-transparent" }),
|
|
936
|
+
/* @__PURE__ */ jsx10("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" }),
|
|
937
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
938
|
+
/* @__PURE__ */ jsx10(
|
|
947
939
|
"input",
|
|
948
940
|
{
|
|
949
941
|
"aria-label": "Hex colour",
|
|
@@ -954,8 +946,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
954
946
|
color
|
|
955
947
|
)
|
|
956
948
|
] }),
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
/* @__PURE__ */
|
|
949
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
950
|
+
/* @__PURE__ */ jsx10(
|
|
959
951
|
"span",
|
|
960
952
|
{
|
|
961
953
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -965,7 +957,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
965
957
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
966
958
|
}
|
|
967
959
|
),
|
|
968
|
-
/* @__PURE__ */
|
|
960
|
+
/* @__PURE__ */ jsx10(
|
|
969
961
|
"button",
|
|
970
962
|
{
|
|
971
963
|
type: "button",
|
|
@@ -977,26 +969,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
977
969
|
}
|
|
978
970
|
)
|
|
979
971
|
] }),
|
|
980
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
981
|
-
/* @__PURE__ */
|
|
982
|
-
/* @__PURE__ */
|
|
983
|
-
/* @__PURE__ */
|
|
972
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx10(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
973
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
974
|
+
/* @__PURE__ */ jsx10("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
975
|
+
/* @__PURE__ */ jsx10("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" })
|
|
984
976
|
] }),
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
987
|
-
/* @__PURE__ */
|
|
977
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
978
|
+
/* @__PURE__ */ jsx10("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
979
|
+
/* @__PURE__ */ jsx10("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" })
|
|
988
980
|
] }),
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
/* @__PURE__ */
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
981
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1", children: [
|
|
982
|
+
/* @__PURE__ */ jsx10("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__ */ jsx10("option", { value: k, children: k }, k)) }),
|
|
983
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
984
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
993
985
|
] }),
|
|
994
|
-
/* @__PURE__ */
|
|
995
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
996
|
-
/* @__PURE__ */
|
|
986
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
987
|
+
harmony.map((h, i) => /* @__PURE__ */ jsx10("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)),
|
|
988
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
997
989
|
] }),
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
990
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
991
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx10(
|
|
1000
992
|
"button",
|
|
1001
993
|
{
|
|
1002
994
|
type: "button",
|
|
@@ -1014,15 +1006,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1014
1006
|
},
|
|
1015
1007
|
i
|
|
1016
1008
|
)),
|
|
1017
|
-
/* @__PURE__ */
|
|
1009
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1018
1010
|
] }),
|
|
1019
|
-
mixingPad && /* @__PURE__ */
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1023
|
-
/* @__PURE__ */
|
|
1011
|
+
mixingPad && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1012
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1", children: [
|
|
1013
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1014
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ jsx10("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1015
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1024
1016
|
] }),
|
|
1025
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ jsx10(
|
|
1026
1018
|
"div",
|
|
1027
1019
|
{
|
|
1028
1020
|
role: "application",
|
|
@@ -1043,20 +1035,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1043
1035
|
padPoints.current = null;
|
|
1044
1036
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1045
1037
|
},
|
|
1046
|
-
children: /* @__PURE__ */
|
|
1038
|
+
children: /* @__PURE__ */ jsx10(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1047
1039
|
}
|
|
1048
1040
|
),
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
/* @__PURE__ */
|
|
1051
|
-
/* @__PURE__ */
|
|
1041
|
+
/* @__PURE__ */ jsx10("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-1", children: [
|
|
1042
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Sample" }),
|
|
1043
|
+
/* @__PURE__ */ jsx10("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__ */ jsx10("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1052
1044
|
] }) }),
|
|
1053
|
-
/* @__PURE__ */
|
|
1054
|
-
/* @__PURE__ */
|
|
1055
|
-
/* @__PURE__ */
|
|
1056
|
-
/* @__PURE__ */
|
|
1057
|
-
/* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1045
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1046
|
+
/* @__PURE__ */ jsx10("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1047
|
+
/* @__PURE__ */ jsx10("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" }),
|
|
1048
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-500", children: ":" }),
|
|
1049
|
+
/* @__PURE__ */ jsx10("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" }),
|
|
1050
|
+
/* @__PURE__ */ jsx10("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1051
|
+
/* @__PURE__ */ jsx10(
|
|
1060
1052
|
"button",
|
|
1061
1053
|
{
|
|
1062
1054
|
type: "button",
|
|
@@ -1075,23 +1067,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1075
1067
|
}
|
|
1076
1068
|
)
|
|
1077
1069
|
] }),
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
1080
|
-
/* @__PURE__ */
|
|
1070
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1071
|
+
/* @__PURE__ */ jsx10("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" }),
|
|
1072
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1081
1073
|
] }),
|
|
1082
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */
|
|
1074
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ jsx10("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ jsxs9("li", { className: "flex items-center gap-1", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1076
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1085
1077
|
] }, p.id)) })
|
|
1086
1078
|
] }),
|
|
1087
|
-
/* @__PURE__ */
|
|
1079
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1088
1080
|
] });
|
|
1089
1081
|
};
|
|
1090
1082
|
|
|
1091
1083
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1092
|
-
import { useState as
|
|
1093
|
-
import { BLEND_MENU_GROUPS
|
|
1094
|
-
import { jsx as
|
|
1084
|
+
import { useState as useState9 } from "react";
|
|
1085
|
+
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1086
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1095
1087
|
function siblingIndex(layers, l) {
|
|
1096
1088
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1097
1089
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1099,7 +1091,7 @@ function siblingIndex(layers, l) {
|
|
|
1099
1091
|
var PaintLayersPanel = ({ controller, className }) => {
|
|
1100
1092
|
usePaintEditorState(controller);
|
|
1101
1093
|
const [error, attempt] = useAttempt();
|
|
1102
|
-
const [renaming, setRenaming] =
|
|
1094
|
+
const [renaming, setRenaming] = useState9(null);
|
|
1103
1095
|
const layers = controller.listLayers();
|
|
1104
1096
|
const active = layers.find((l) => l.active) ?? null;
|
|
1105
1097
|
const light = active?.type === "pixel" ? controller.lightOf(active.id) : null;
|
|
@@ -1109,18 +1101,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1109
1101
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1110
1102
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1111
1103
|
};
|
|
1112
|
-
return /* @__PURE__ */
|
|
1113
|
-
/* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1116
|
-
/* @__PURE__ */
|
|
1117
|
-
/* @__PURE__ */
|
|
1118
|
-
/* @__PURE__ */
|
|
1119
|
-
/* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1104
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1105
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1106
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1107
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1108
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1109
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1110
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1111
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1112
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1113
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1122
1114
|
] }),
|
|
1123
|
-
/* @__PURE__ */
|
|
1115
|
+
/* @__PURE__ */ jsx11("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs10(
|
|
1124
1116
|
"li",
|
|
1125
1117
|
{
|
|
1126
1118
|
role: "treeitem",
|
|
@@ -1129,7 +1121,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1129
1121
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1130
1122
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1131
1123
|
children: [
|
|
1132
|
-
/* @__PURE__ */
|
|
1124
|
+
/* @__PURE__ */ jsx11(
|
|
1133
1125
|
"button",
|
|
1134
1126
|
{
|
|
1135
1127
|
type: "button",
|
|
@@ -1142,7 +1134,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1142
1134
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1143
1135
|
}
|
|
1144
1136
|
),
|
|
1145
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1137
|
+
renaming === l.id ? /* @__PURE__ */ jsx11(
|
|
1146
1138
|
"input",
|
|
1147
1139
|
{
|
|
1148
1140
|
autoFocus: true,
|
|
@@ -1159,23 +1151,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1159
1151
|
if (e.key === "Escape") setRenaming(null);
|
|
1160
1152
|
}
|
|
1161
1153
|
}
|
|
1162
|
-
) : /* @__PURE__ */
|
|
1154
|
+
) : /* @__PURE__ */ jsxs10("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1163
1155
|
l.type === "group" ? "\u25B8 " : "",
|
|
1164
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1156
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs10("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1165
1157
|
"\u270E",
|
|
1166
1158
|
" "
|
|
1167
1159
|
] }),
|
|
1168
1160
|
l.name
|
|
1169
1161
|
] }),
|
|
1170
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1162
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx11("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1171
1163
|
]
|
|
1172
1164
|
},
|
|
1173
1165
|
l.id
|
|
1174
1166
|
)) }),
|
|
1175
|
-
active && /* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
1167
|
+
active && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", children: [
|
|
1168
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1169
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1170
|
+
/* @__PURE__ */ jsx11(
|
|
1179
1171
|
"input",
|
|
1180
1172
|
{
|
|
1181
1173
|
type: "range",
|
|
@@ -1189,40 +1181,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1189
1181
|
}
|
|
1190
1182
|
)
|
|
1191
1183
|
] }),
|
|
1192
|
-
/* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
active.type === "group" && /* @__PURE__ */
|
|
1196
|
-
|
|
1184
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1185
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1186
|
+
/* @__PURE__ */ jsxs10("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: [
|
|
1187
|
+
active.type === "group" && /* @__PURE__ */ jsx11("option", { value: "pass-through", children: "Pass through" }),
|
|
1188
|
+
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ jsx11("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ jsx11("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1197
1189
|
] })
|
|
1198
1190
|
] }),
|
|
1199
|
-
/* @__PURE__ */
|
|
1200
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1201
|
-
/* @__PURE__ */
|
|
1191
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-1", children: [
|
|
1192
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ jsx11("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)),
|
|
1193
|
+
/* @__PURE__ */ jsx11("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1202
1194
|
] }),
|
|
1203
|
-
light?.hasLight && /* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1206
|
-
/* @__PURE__ */
|
|
1195
|
+
light?.hasLight && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1196
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1197
|
+
/* @__PURE__ */ jsx11("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1198
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1207
1199
|
] }),
|
|
1208
|
-
/* @__PURE__ */
|
|
1209
|
-
/* @__PURE__ */
|
|
1210
|
-
/* @__PURE__ */
|
|
1200
|
+
/* @__PURE__ */ jsxs10("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: [
|
|
1201
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1202
|
+
/* @__PURE__ */ jsx11("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" })
|
|
1211
1203
|
] }),
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */
|
|
1214
|
-
/* @__PURE__ */
|
|
1204
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1205
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1206
|
+
/* @__PURE__ */ jsx11("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" })
|
|
1215
1207
|
] })
|
|
1216
1208
|
] }),
|
|
1217
|
-
/* @__PURE__ */
|
|
1209
|
+
/* @__PURE__ */ jsx11("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__ */ jsx11(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1218
1210
|
] }),
|
|
1219
|
-
/* @__PURE__ */
|
|
1211
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1220
1212
|
] });
|
|
1221
1213
|
};
|
|
1222
1214
|
|
|
1223
1215
|
// src/paint-editor/WetPanel.tsx
|
|
1224
|
-
import { WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as
|
|
1225
|
-
import { jsx as
|
|
1216
|
+
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";
|
|
1217
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1226
1218
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1227
1219
|
var WetPanel = ({ controller, className }) => {
|
|
1228
1220
|
const state = usePaintEditorState(controller);
|
|
@@ -1231,31 +1223,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1231
1223
|
const layerId = state.document.activeLayerId;
|
|
1232
1224
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1233
1225
|
const backend = controller.wetState();
|
|
1234
|
-
return /* @__PURE__ */
|
|
1235
|
-
/* @__PURE__ */
|
|
1236
|
-
/* @__PURE__ */
|
|
1237
|
-
/* @__PURE__ */
|
|
1226
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1227
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
|
|
1228
|
+
/* @__PURE__ */ jsx12("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1229
|
+
/* @__PURE__ */ jsxs11("span", { className: "text-[10px] text-slate-500", children: [
|
|
1238
1230
|
"step ",
|
|
1239
1231
|
wet.clock
|
|
1240
1232
|
] })
|
|
1241
1233
|
] }),
|
|
1242
|
-
/* @__PURE__ */
|
|
1243
|
-
/* @__PURE__ */
|
|
1244
|
-
/* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1234
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap gap-1", children: [
|
|
1235
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1236
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1237
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1238
|
+
/* @__PURE__ */ jsx12("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" }),
|
|
1239
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1248
1240
|
] }),
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1251
|
-
info && /* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1255
|
-
/* @__PURE__ */
|
|
1256
|
-
/* @__PURE__ */
|
|
1241
|
+
/* @__PURE__ */ jsx12(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1242
|
+
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath2(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1243
|
+
info && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1244
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1245
|
+
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath2(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1246
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1247
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1248
|
+
/* @__PURE__ */ jsx12("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__ */ jsx12("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1257
1249
|
] }),
|
|
1258
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1250
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx12(
|
|
1259
1251
|
PaintSlider,
|
|
1260
1252
|
{
|
|
1261
1253
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1264,20 +1256,20 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1264
1256
|
}
|
|
1265
1257
|
)
|
|
1266
1258
|
] }),
|
|
1267
|
-
backend.message && /* @__PURE__ */
|
|
1268
|
-
backend.backend && /* @__PURE__ */
|
|
1269
|
-
/* @__PURE__ */
|
|
1270
|
-
/* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */
|
|
1259
|
+
backend.message && /* @__PURE__ */ jsx12("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1260
|
+
backend.backend && /* @__PURE__ */ jsx12("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" }),
|
|
1261
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1262
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Engine" }),
|
|
1263
|
+
/* @__PURE__ */ jsx12("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__ */ jsx12("option", { value: o.value, children: o.label }, o.value)) })
|
|
1272
1264
|
] }),
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
/* @__PURE__ */
|
|
1265
|
+
/* @__PURE__ */ jsx12("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1266
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1275
1267
|
] });
|
|
1276
1268
|
};
|
|
1277
1269
|
|
|
1278
1270
|
// src/paint-editor/StickerPanel.tsx
|
|
1279
|
-
import { STICKER_SLIDERS, readPath as
|
|
1280
|
-
import { jsx as
|
|
1271
|
+
import { STICKER_SLIDERS, readPath as readPath3, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1272
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1281
1273
|
var StickerPanel = ({ controller, className }) => {
|
|
1282
1274
|
const state = usePaintEditorState(controller);
|
|
1283
1275
|
const [error, attempt] = useAttempt();
|
|
@@ -1287,16 +1279,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1287
1279
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1288
1280
|
if (!stickers.length) return null;
|
|
1289
1281
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1290
|
-
return /* @__PURE__ */
|
|
1291
|
-
/* @__PURE__ */
|
|
1282
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1283
|
+
/* @__PURE__ */ jsxs12("span", { className: "font-medium text-slate-300", children: [
|
|
1292
1284
|
"Stickers (",
|
|
1293
1285
|
stickers.length,
|
|
1294
1286
|
")"
|
|
1295
1287
|
] }),
|
|
1296
|
-
/* @__PURE__ */
|
|
1297
|
-
sel && /* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1288
|
+
/* @__PURE__ */ jsx13("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Stickers", children: stickers.map((s) => /* @__PURE__ */ jsx13("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)) }),
|
|
1289
|
+
sel && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1290
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1291
|
+
/* @__PURE__ */ jsx13(
|
|
1300
1292
|
StickerPicker,
|
|
1301
1293
|
{
|
|
1302
1294
|
controller,
|
|
@@ -1310,9 +1302,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1310
1302
|
)
|
|
1311
1303
|
}
|
|
1312
1304
|
),
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1315
|
-
/* @__PURE__ */
|
|
1305
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1306
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Position" }),
|
|
1307
|
+
/* @__PURE__ */ jsx13("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx13(
|
|
1316
1308
|
"input",
|
|
1317
1309
|
{
|
|
1318
1310
|
type: "number",
|
|
@@ -1326,24 +1318,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1326
1318
|
`${sel.id}-${k}-${sel[k]}`
|
|
1327
1319
|
)) })
|
|
1328
1320
|
] }),
|
|
1329
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__PURE__ */
|
|
1321
|
+
STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx13(PaintSlider, { control: c, value: readPath3(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1322
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center justify-between", children: [
|
|
1323
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Colour" }),
|
|
1324
|
+
/* @__PURE__ */ jsx13(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" })
|
|
1333
1325
|
] }),
|
|
1334
|
-
/* @__PURE__ */
|
|
1335
|
-
/* @__PURE__ */
|
|
1336
|
-
/* @__PURE__ */
|
|
1337
|
-
/* @__PURE__ */
|
|
1326
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
|
|
1327
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1328
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1329
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1338
1330
|
] })
|
|
1339
1331
|
] }),
|
|
1340
|
-
/* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1341
1333
|
] });
|
|
1342
1334
|
};
|
|
1343
1335
|
|
|
1344
1336
|
// src/paint-editor/StrokePanel.tsx
|
|
1345
|
-
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as
|
|
1346
|
-
import { jsx as
|
|
1337
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath4 } from "@pixerate/editor/paint-editor";
|
|
1338
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1347
1339
|
var StrokePanel = ({ controller, className }) => {
|
|
1348
1340
|
const state = usePaintEditorState(controller);
|
|
1349
1341
|
const [error, attempt] = useAttempt();
|
|
@@ -1353,16 +1345,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1353
1345
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1354
1346
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1355
1347
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1356
|
-
return /* @__PURE__ */
|
|
1357
|
-
/* @__PURE__ */
|
|
1358
|
-
/* @__PURE__ */
|
|
1348
|
+
return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1349
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
|
|
1350
|
+
/* @__PURE__ */ jsxs13("span", { className: "font-medium text-slate-300", children: [
|
|
1359
1351
|
"Strokes (",
|
|
1360
1352
|
strokes.length,
|
|
1361
1353
|
")"
|
|
1362
1354
|
] }),
|
|
1363
|
-
/* @__PURE__ */
|
|
1355
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1364
1356
|
] }),
|
|
1365
|
-
/* @__PURE__ */
|
|
1357
|
+
/* @__PURE__ */ jsx14("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ jsx14(
|
|
1366
1358
|
"button",
|
|
1367
1359
|
{
|
|
1368
1360
|
type: "button",
|
|
@@ -1375,10 +1367,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1375
1367
|
},
|
|
1376
1368
|
s.id
|
|
1377
1369
|
)) }),
|
|
1378
|
-
sel && /* @__PURE__ */
|
|
1379
|
-
/* @__PURE__ */
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
/* @__PURE__ */
|
|
1370
|
+
sel && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1371
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1372
|
+
/* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Brush" }),
|
|
1373
|
+
/* @__PURE__ */ jsxs13(
|
|
1382
1374
|
"select",
|
|
1383
1375
|
{
|
|
1384
1376
|
"aria-label": "Stroke brush",
|
|
@@ -1386,38 +1378,38 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1386
1378
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1387
1379
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1388
1380
|
children: [
|
|
1389
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1390
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1381
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx14("option", { value: "", children: sel.brush.name }),
|
|
1382
|
+
brushes.map((b) => /* @__PURE__ */ jsx14("option", { value: b.id, children: b.name }, b.id))
|
|
1391
1383
|
]
|
|
1392
1384
|
}
|
|
1393
1385
|
)
|
|
1394
1386
|
] }),
|
|
1395
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1396
|
-
/* @__PURE__ */
|
|
1397
|
-
/* @__PURE__ */
|
|
1398
|
-
/* @__PURE__ */
|
|
1387
|
+
STROKE_SLIDERS.map((c) => /* @__PURE__ */ jsx14(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)),
|
|
1388
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center justify-between", children: [
|
|
1389
|
+
/* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Colour" }),
|
|
1390
|
+
/* @__PURE__ */ jsx14(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1399
1391
|
] }),
|
|
1400
|
-
/* @__PURE__ */
|
|
1401
|
-
/* @__PURE__ */
|
|
1402
|
-
/* @__PURE__ */
|
|
1403
|
-
/* @__PURE__ */
|
|
1404
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap gap-1", children: [
|
|
1393
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1394
|
+
/* @__PURE__ */ jsx14("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" }),
|
|
1395
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1396
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1405
1397
|
] })
|
|
1406
1398
|
] }),
|
|
1407
|
-
/* @__PURE__ */
|
|
1399
|
+
/* @__PURE__ */ jsx14(ErrorLine, { error })
|
|
1408
1400
|
] });
|
|
1409
1401
|
};
|
|
1410
1402
|
|
|
1411
1403
|
// src/paint-editor/PaintEditor.tsx
|
|
1412
|
-
import { useRef as useRef7, useState as
|
|
1404
|
+
import { useRef as useRef7, useState as useState11 } from "react";
|
|
1413
1405
|
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1414
1406
|
|
|
1415
1407
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1416
|
-
import { useEffect as useEffect5, useMemo as
|
|
1408
|
+
import { useEffect as useEffect5, useMemo as useMemo8, useRef as useRef6, useState as useState10 } from "react";
|
|
1417
1409
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1418
|
-
import { jsx as
|
|
1410
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1419
1411
|
function usePaintEffectsProvider(controller) {
|
|
1420
|
-
const [provider, setProvider] =
|
|
1412
|
+
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1421
1413
|
useEffect5(() => {
|
|
1422
1414
|
setProvider(controller.effectsProvider);
|
|
1423
1415
|
return controller.effects.subscribe(setProvider);
|
|
@@ -1434,19 +1426,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1434
1426
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1435
1427
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1436
1428
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1437
|
-
if (!provider) return /* @__PURE__ */
|
|
1429
|
+
if (!provider) return /* @__PURE__ */ jsxs14("p", { className: "text-[11px] text-slate-400", children: [
|
|
1438
1430
|
'No effects provider: "',
|
|
1439
1431
|
name ?? effect,
|
|
1440
1432
|
'" is kept as it was drawn.'
|
|
1441
1433
|
] });
|
|
1442
|
-
if (error) return /* @__PURE__ */
|
|
1443
|
-
if (!description) return /* @__PURE__ */
|
|
1434
|
+
if (error) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1435
|
+
if (!description) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1444
1436
|
const commit = (gesture) => {
|
|
1445
1437
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1446
1438
|
drags.current.add(gesture);
|
|
1447
1439
|
return true;
|
|
1448
1440
|
};
|
|
1449
|
-
return /* @__PURE__ */
|
|
1441
|
+
return /* @__PURE__ */ jsx15(
|
|
1450
1442
|
EffectParameters,
|
|
1451
1443
|
{
|
|
1452
1444
|
description,
|
|
@@ -1468,8 +1460,8 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1468
1460
|
const state = usePaintEditorState(controller);
|
|
1469
1461
|
const provider = usePaintEffectsProvider(controller);
|
|
1470
1462
|
const [error, attempt] = useAttempt();
|
|
1471
|
-
const [browse, setBrowse] =
|
|
1472
|
-
const [busy, setBusy] =
|
|
1463
|
+
const [browse, setBrowse] = useState10(null);
|
|
1464
|
+
const [busy, setBusy] = useState10(false);
|
|
1473
1465
|
const paper = controller.getPaperEffect();
|
|
1474
1466
|
const activeId = state.document.activeLayerId;
|
|
1475
1467
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
@@ -1481,7 +1473,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1481
1473
|
if (!effectPaint) return;
|
|
1482
1474
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1483
1475
|
};
|
|
1484
|
-
const thumbnail =
|
|
1476
|
+
const thumbnail = useMemo8(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1485
1477
|
const run = (work) => attempt(() => {
|
|
1486
1478
|
setBusy(true);
|
|
1487
1479
|
return work().finally(() => setBusy(false));
|
|
@@ -1497,28 +1489,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1497
1489
|
};
|
|
1498
1490
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1499
1491
|
const pixel = active?.type === "pixel";
|
|
1500
|
-
return /* @__PURE__ */
|
|
1501
|
-
/* @__PURE__ */
|
|
1502
|
-
/* @__PURE__ */
|
|
1503
|
-
/* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
1507
|
-
/* @__PURE__ */
|
|
1492
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1493
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1494
|
+
/* @__PURE__ */ jsx15("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1495
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1496
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1497
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1498
|
+
/* @__PURE__ */ jsx15("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" }),
|
|
1499
|
+
/* @__PURE__ */ jsx15("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" })
|
|
1508
1500
|
] }),
|
|
1509
|
-
!provider && /* @__PURE__ */
|
|
1510
|
-
browse && /* @__PURE__ */
|
|
1511
|
-
paper && /* @__PURE__ */
|
|
1512
|
-
/* @__PURE__ */
|
|
1513
|
-
/* @__PURE__ */
|
|
1501
|
+
!provider && /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1502
|
+
browse && /* @__PURE__ */ jsx15(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1503
|
+
paper && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1504
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1505
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1514
1506
|
"Paper: ",
|
|
1515
1507
|
paper.name ?? paper.effect
|
|
1516
1508
|
] }),
|
|
1517
|
-
/* @__PURE__ */
|
|
1509
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1518
1510
|
] }),
|
|
1519
|
-
/* @__PURE__ */
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
1511
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1512
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1513
|
+
/* @__PURE__ */ jsx15(
|
|
1522
1514
|
"input",
|
|
1523
1515
|
{
|
|
1524
1516
|
type: "range",
|
|
@@ -1540,39 +1532,39 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1540
1532
|
`o${paper.opacity}`
|
|
1541
1533
|
)
|
|
1542
1534
|
] }),
|
|
1543
|
-
/* @__PURE__ */
|
|
1544
|
-
/* @__PURE__ */
|
|
1545
|
-
/* @__PURE__ */
|
|
1535
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1536
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1537
|
+
/* @__PURE__ */ jsx15("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) => {
|
|
1546
1538
|
const blend = e.currentTarget.value;
|
|
1547
1539
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1548
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1540
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx15("option", { value: b, children: b }, b)) })
|
|
1549
1541
|
] }),
|
|
1550
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1551
1543
|
] }),
|
|
1552
|
-
effectPaint && /* @__PURE__ */
|
|
1553
|
-
/* @__PURE__ */
|
|
1554
|
-
thumbnail ? /* @__PURE__ */
|
|
1555
|
-
/* @__PURE__ */
|
|
1544
|
+
effectPaint && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1545
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1546
|
+
thumbnail ? /* @__PURE__ */ jsx15("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
1547
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1556
1548
|
"Paint: ",
|
|
1557
1549
|
effectPaint.effect,
|
|
1558
1550
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1559
1551
|
] }),
|
|
1560
|
-
/* @__PURE__ */
|
|
1552
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1561
1553
|
] }),
|
|
1562
|
-
/* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1554
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1555
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1556
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: Boolean(effectPaint.map), onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1565
1557
|
"Along the stroke"
|
|
1566
1558
|
] }),
|
|
1567
|
-
/* @__PURE__ */
|
|
1568
|
-
/* @__PURE__ */
|
|
1559
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1560
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1569
1561
|
"Live"
|
|
1570
1562
|
] })
|
|
1571
1563
|
] }),
|
|
1572
|
-
effectPaint.map && /* @__PURE__ */
|
|
1573
|
-
/* @__PURE__ */
|
|
1574
|
-
/* @__PURE__ */
|
|
1575
|
-
/* @__PURE__ */
|
|
1564
|
+
effectPaint.map && /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1565
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1566
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "Length" }),
|
|
1567
|
+
/* @__PURE__ */ jsx15(
|
|
1576
1568
|
"input",
|
|
1577
1569
|
{
|
|
1578
1570
|
type: "number",
|
|
@@ -1586,55 +1578,55 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1586
1578
|
effectPaint.map.length
|
|
1587
1579
|
)
|
|
1588
1580
|
] }),
|
|
1589
|
-
/* @__PURE__ */
|
|
1590
|
-
/* @__PURE__ */
|
|
1591
|
-
/* @__PURE__ */
|
|
1592
|
-
/* @__PURE__ */
|
|
1581
|
+
/* @__PURE__ */ jsxs14("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: [
|
|
1582
|
+
/* @__PURE__ */ jsx15("option", { value: "repeat", children: "Repeat" }),
|
|
1583
|
+
/* @__PURE__ */ jsx15("option", { value: "mirror", children: "Mirror" }),
|
|
1584
|
+
/* @__PURE__ */ jsx15("option", { value: "clamp", children: "Clamp" })
|
|
1593
1585
|
] })
|
|
1594
1586
|
] }),
|
|
1595
|
-
/* @__PURE__ */
|
|
1587
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1596
1588
|
] }),
|
|
1597
|
-
animation && /* @__PURE__ */
|
|
1598
|
-
/* @__PURE__ */
|
|
1589
|
+
animation && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1590
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1599
1591
|
"Live paint: ",
|
|
1600
1592
|
animation.strokes,
|
|
1601
1593
|
" ",
|
|
1602
1594
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1603
1595
|
] }),
|
|
1604
|
-
/* @__PURE__ */
|
|
1605
|
-
/* @__PURE__ */
|
|
1606
|
-
/* @__PURE__ */
|
|
1607
|
-
/* @__PURE__ */
|
|
1596
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1597
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1598
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "fps" }),
|
|
1599
|
+
/* @__PURE__ */ jsx15("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" })
|
|
1608
1600
|
] })
|
|
1609
1601
|
] }),
|
|
1610
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
/* @__PURE__ */
|
|
1602
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1603
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1604
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1613
1605
|
"Layer: ",
|
|
1614
1606
|
layerEffect.name ?? layerEffect.effect
|
|
1615
1607
|
] }),
|
|
1616
|
-
/* @__PURE__ */
|
|
1608
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1617
1609
|
] }),
|
|
1618
|
-
/* @__PURE__ */
|
|
1610
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1619
1611
|
] }),
|
|
1620
|
-
/* @__PURE__ */
|
|
1612
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1621
1613
|
] });
|
|
1622
1614
|
};
|
|
1623
1615
|
|
|
1624
1616
|
// src/paint-editor/PaintEditor.tsx
|
|
1625
|
-
import { jsx as
|
|
1617
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1626
1618
|
var PAINT_CONTROLS = {
|
|
1627
1619
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1628
1620
|
lighting: '[data-testid="light-panel"]',
|
|
1629
1621
|
symmetry: '[aria-label="Symmetry"]'
|
|
1630
1622
|
};
|
|
1631
1623
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1632
|
-
const [tool, setTool] =
|
|
1633
|
-
const [tab, setTab] =
|
|
1624
|
+
const [tool, setTool] = useState11("brush");
|
|
1625
|
+
const [tab, setTab] = useState11("color");
|
|
1634
1626
|
const tabRef = useRef7(tab);
|
|
1635
1627
|
tabRef.current = tab;
|
|
1636
1628
|
const rootRef = useRef7(null);
|
|
1637
|
-
const [ownPresence] =
|
|
1629
|
+
const [ownPresence] = useState11(() => new PaintPresence2());
|
|
1638
1630
|
const ambientPlayback = useAgentPlayback();
|
|
1639
1631
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1640
1632
|
const viewBox = () => {
|
|
@@ -1690,34 +1682,36 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
1690
1682
|
const box = rootRef.current?.getBoundingClientRect();
|
|
1691
1683
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1692
1684
|
};
|
|
1693
|
-
const [error, setError] =
|
|
1685
|
+
const [error, setError] = useState11(null);
|
|
1694
1686
|
const effects = usePaintEffectsProvider(controller);
|
|
1695
1687
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1696
|
-
return /* @__PURE__ */
|
|
1697
|
-
playing && /* @__PURE__ */
|
|
1698
|
-
/* @__PURE__ */
|
|
1699
|
-
/* @__PURE__ */
|
|
1700
|
-
/* @__PURE__ */
|
|
1701
|
-
/* @__PURE__ */
|
|
1702
|
-
/* @__PURE__ */
|
|
1703
|
-
error && /* @__PURE__ */
|
|
1688
|
+
return /* @__PURE__ */ jsxs15("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: [
|
|
1689
|
+
playing && /* @__PURE__ */ jsx16(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1690
|
+
/* @__PURE__ */ jsx16(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1691
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1692
|
+
/* @__PURE__ */ jsx16(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1693
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1694
|
+
/* @__PURE__ */ jsx16(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
1695
|
+
error && /* @__PURE__ */ jsx16("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1704
1696
|
] }),
|
|
1705
|
-
/* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
tab === "color" && /* @__PURE__ */
|
|
1709
|
-
tab === "wet" && /* @__PURE__ */
|
|
1710
|
-
tab === "paper" && /* @__PURE__ */
|
|
1711
|
-
tab === "layers" && /* @__PURE__ */
|
|
1712
|
-
tab === "layers" && /* @__PURE__ */
|
|
1713
|
-
tab === "layers" && /* @__PURE__ */
|
|
1714
|
-
tab === "effects" && effects && /* @__PURE__ */
|
|
1697
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1698
|
+
/* @__PURE__ */ jsx16("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx16("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)) }),
|
|
1699
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1700
|
+
tab === "color" && /* @__PURE__ */ jsx16(ColorPanel, { controller }),
|
|
1701
|
+
tab === "wet" && /* @__PURE__ */ jsx16(WetPanel, { controller }),
|
|
1702
|
+
tab === "paper" && /* @__PURE__ */ jsx16(PaperPanel, { controller }),
|
|
1703
|
+
tab === "layers" && /* @__PURE__ */ jsx16(PaintLayersPanel, { controller }),
|
|
1704
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StrokePanel, { controller }),
|
|
1705
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StickerPanel, { controller }),
|
|
1706
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx16(PaintEffectsPanel, { controller })
|
|
1715
1707
|
] })
|
|
1716
1708
|
] })
|
|
1717
1709
|
] })
|
|
1718
1710
|
] });
|
|
1719
1711
|
};
|
|
1720
1712
|
export {
|
|
1713
|
+
BrushEditor,
|
|
1714
|
+
BrushLibraryBrowser,
|
|
1721
1715
|
BrushPanel,
|
|
1722
1716
|
ColorPanel,
|
|
1723
1717
|
PaintCanvas,
|