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