@pixerate/editor-react 0.191.0 → 0.193.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-2JNRWM6S.js → chunk-QBU4WMBA.js} +80 -2
- package/dist/index.cjs +143 -66
- package/dist/index.js +4 -2
- package/dist/paint-editor/FerroPanel.d.cts +12 -0
- package/dist/paint-editor/FerroPanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +776 -669
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +444 -337
- package/dist/persistence/index.cjs +80 -3
- package/dist/persistence/index.d.cts +1 -0
- package/dist/persistence/index.d.ts +1 -0
- package/dist/persistence/index.js +5 -3
- package/dist/persistence/useAutosave.d.cts +6 -0
- package/dist/persistence/useAutosave.d.ts +6 -0
- package/dist/persistence/useEditorSync.d.cts +30 -0
- package/dist/persistence/useEditorSync.d.ts +30 -0
- package/package.json +3 -3
|
@@ -112,6 +112,7 @@ import {
|
|
|
112
112
|
PaintCanvasPresenter,
|
|
113
113
|
PaintGesture,
|
|
114
114
|
documentToScreen,
|
|
115
|
+
screenToDocument,
|
|
115
116
|
drawWaterOverlay,
|
|
116
117
|
startDeviceTilt,
|
|
117
118
|
startWetClock,
|
|
@@ -132,6 +133,7 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
132
133
|
const measured = useRef2(false);
|
|
133
134
|
const [predicted, setPredicted] = useState2([]);
|
|
134
135
|
const [strokeDrag, setStrokeDrag] = useState2(null);
|
|
136
|
+
const magnetDrag = useRef2(null);
|
|
135
137
|
const presenter = useMemo2(() => new PaintCanvasPresenter(controller), [controller]);
|
|
136
138
|
const gesture = useMemo2(
|
|
137
139
|
() => new PaintGesture(controller, () => {
|
|
@@ -267,6 +269,45 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
267
269
|
predicted.length > 0 && /* @__PURE__ */ jsx("polyline", { points: predicted.map((p) => `${p.x},${p.y}`).join(" "), fill: "none", stroke: state.color, strokeOpacity: 0.5, strokeWidth: Math.max(1, state.brush.tip.size / 2), strokeLinecap: "round" })
|
|
268
270
|
] }),
|
|
269
271
|
state.guides.references.filter((r) => r.visible).map((r) => /* @__PURE__ */ jsx(ReferencePanel, { controller, id: r.id }, r.id)),
|
|
272
|
+
showGuides && (state.document.magnets ?? []).map((m) => {
|
|
273
|
+
const p = documentToScreen(state.view, doc, size, m.x, m.y);
|
|
274
|
+
return /* @__PURE__ */ jsx(
|
|
275
|
+
"button",
|
|
276
|
+
{
|
|
277
|
+
type: "button",
|
|
278
|
+
"aria-label": `Magnet ${m.id}`,
|
|
279
|
+
"data-testid": `paint-magnet-${m.id}`,
|
|
280
|
+
"data-magnet": m.id,
|
|
281
|
+
title: `Magnet ${m.id} (${Math.round(m.x)}, ${Math.round(m.y)})`,
|
|
282
|
+
className: "absolute -translate-x-1/2 -translate-y-1/2 flex h-5 w-5 items-center justify-center rounded-full border border-indigo-300 bg-slate-900/90 text-[9px] font-bold text-indigo-200 shadow cursor-move",
|
|
283
|
+
style: { left: p.x, top: p.y },
|
|
284
|
+
onPointerDown: (e) => {
|
|
285
|
+
e.stopPropagation();
|
|
286
|
+
magnetDrag.current = { id: m.id, moved: false };
|
|
287
|
+
e.target.setPointerCapture?.(e.pointerId);
|
|
288
|
+
},
|
|
289
|
+
onPointerMove: (e) => {
|
|
290
|
+
const d = magnetDrag.current;
|
|
291
|
+
if (!d || d.id !== m.id) return;
|
|
292
|
+
e.stopPropagation();
|
|
293
|
+
const r = viewport.current?.getBoundingClientRect();
|
|
294
|
+
const box = { width: r?.width || size.width, height: r?.height || size.height };
|
|
295
|
+
const pt = screenToDocument(state.view, doc, box, e.clientX - (r?.left ?? 0), e.clientY - (r?.top ?? 0));
|
|
296
|
+
controller.updateMagnet(m.id, { x: Math.round(pt.x * 100) / 100, y: Math.round(pt.y * 100) / 100 }, !d.moved);
|
|
297
|
+
d.moved = true;
|
|
298
|
+
},
|
|
299
|
+
onPointerUp: (e) => {
|
|
300
|
+
e.stopPropagation();
|
|
301
|
+
magnetDrag.current = null;
|
|
302
|
+
},
|
|
303
|
+
onPointerCancel: () => {
|
|
304
|
+
magnetDrag.current = null;
|
|
305
|
+
},
|
|
306
|
+
children: m.strength >= 0 ? "N" : "S"
|
|
307
|
+
},
|
|
308
|
+
m.id
|
|
309
|
+
);
|
|
310
|
+
}),
|
|
270
311
|
proposals && /* @__PURE__ */ jsx(PaintProposalGhosts, { proposals, transform, zoom: state.view.zoom }),
|
|
271
312
|
presence && /* @__PURE__ */ jsx(PaintPresenceLayer, { presence, view: state.view, canvas: doc, viewport: size }),
|
|
272
313
|
/* @__PURE__ */ jsxs("div", { className: "absolute bottom-1 right-2 text-[10px] text-slate-500 pointer-events-none", "data-testid": "paint-view-status", children: [
|
|
@@ -778,9 +819,73 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
778
819
|
};
|
|
779
820
|
|
|
780
821
|
// src/paint-editor/PaperPanel.tsx
|
|
781
|
-
import { useEffect as useEffect4, useMemo as
|
|
782
|
-
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
|
|
822
|
+
import { useEffect as useEffect4, useMemo as useMemo5, useState as useState5 } from "react";
|
|
823
|
+
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath as readPath2, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
|
|
824
|
+
|
|
825
|
+
// src/paint-editor/FerroPanel.tsx
|
|
826
|
+
import { useMemo as useMemo4 } from "react";
|
|
827
|
+
import { MAGNET_SLIDERS, readPath } from "@pixerate/editor/paint-editor";
|
|
783
828
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
829
|
+
var FerroPanel = ({ controller, className }) => {
|
|
830
|
+
const state = usePaintEditorState(controller);
|
|
831
|
+
const [error, attempt] = useAttempt();
|
|
832
|
+
const magnets = state.document.magnets ?? [];
|
|
833
|
+
const activeId = state.document.activeLayerId;
|
|
834
|
+
const info = useMemo4(() => {
|
|
835
|
+
try {
|
|
836
|
+
return activeId ? controller.getFerrofluid(activeId) : null;
|
|
837
|
+
} catch {
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
}, [controller, state.document, activeId]);
|
|
841
|
+
return /* @__PURE__ */ jsxs5("div", { className: `${panel} ${className ?? ""}`, "data-testid": "ferro-panel", children: [
|
|
842
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between", children: [
|
|
843
|
+
/* @__PURE__ */ jsx6("span", { className: "font-medium text-slate-300", children: "Ferrofluid & magnets" }),
|
|
844
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex gap-1", children: [
|
|
845
|
+
/* @__PURE__ */ jsx6(
|
|
846
|
+
"button",
|
|
847
|
+
{
|
|
848
|
+
type: "button",
|
|
849
|
+
className: button,
|
|
850
|
+
onClick: () => attempt(() => controller.addMagnet({ x: Math.round(state.document.canvas.width / 2), y: Math.round(state.document.canvas.height / 2) })),
|
|
851
|
+
children: "Add magnet"
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
magnets.length > 0 && /* @__PURE__ */ jsx6("button", { type: "button", className: button, onClick: () => attempt(() => controller.removeMagnets()), children: "Clear magnets" })
|
|
855
|
+
] })
|
|
856
|
+
] }),
|
|
857
|
+
magnets.map((m) => /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1 rounded border border-slate-800 p-1.5", "data-magnet": m.id, children: [
|
|
858
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between text-[11px]", children: [
|
|
859
|
+
/* @__PURE__ */ jsxs5("span", { className: "font-mono text-slate-300", children: [
|
|
860
|
+
m.id,
|
|
861
|
+
" (",
|
|
862
|
+
Math.round(m.x),
|
|
863
|
+
", ",
|
|
864
|
+
Math.round(m.y),
|
|
865
|
+
")"
|
|
866
|
+
] }),
|
|
867
|
+
/* @__PURE__ */ jsx6("button", { type: "button", "aria-label": `Remove magnet ${m.id}`, className: "px-1 text-slate-400 hover:text-white", onClick: () => attempt(() => controller.removeMagnets([m.id])), children: "\xD7" })
|
|
868
|
+
] }),
|
|
869
|
+
MAGNET_SLIDERS.map((c) => /* @__PURE__ */ jsx6(
|
|
870
|
+
PaintSlider,
|
|
871
|
+
{
|
|
872
|
+
control: { ...c, label: `${c.label} (${m.id})` },
|
|
873
|
+
value: readPath(m, c.path),
|
|
874
|
+
onCommit: (v) => attempt(() => controller.updateMagnet(m.id, { [c.path]: v }))
|
|
875
|
+
},
|
|
876
|
+
c.path
|
|
877
|
+
))
|
|
878
|
+
] }, m.id)),
|
|
879
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between gap-2", children: [
|
|
880
|
+
/* @__PURE__ */ jsx6("span", { className: "text-[11px] text-slate-400", children: info?.ferro ? `${info.activeSpikeArea} spike px \xB7 max ${Math.round(info.maxSpikeHeight * 100)}%` : "No liquid ferrofluid on layer" }),
|
|
881
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: button, disabled: !info?.ferro, onClick: () => attempt(() => controller.cureFerrofluid()), children: "Cure ferrofluid" })
|
|
882
|
+
] }),
|
|
883
|
+
/* @__PURE__ */ jsx6(ErrorLine, { error })
|
|
884
|
+
] });
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
// src/paint-editor/PaperPanel.tsx
|
|
888
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
784
889
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
785
890
|
var PaperPanel = ({ controller, className }) => {
|
|
786
891
|
const state = usePaintEditorState(controller);
|
|
@@ -788,11 +893,11 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
788
893
|
const [tiltFollow, setTiltFollow] = useState5(false);
|
|
789
894
|
useEffect4(() => tiltFollow ? startDeviceTilt2(controller) : void 0, [controller, tiltFollow]);
|
|
790
895
|
const paper = state.document.paper;
|
|
791
|
-
const previews =
|
|
792
|
-
return /* @__PURE__ */
|
|
793
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
794
|
-
/* @__PURE__ */
|
|
795
|
-
/* @__PURE__ */
|
|
896
|
+
const previews = useMemo5(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
897
|
+
return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
898
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs6("div", { children: [
|
|
899
|
+
/* @__PURE__ */ jsx7("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
900
|
+
/* @__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(
|
|
796
901
|
"button",
|
|
797
902
|
{
|
|
798
903
|
type: "button",
|
|
@@ -801,32 +906,32 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
801
906
|
title: p.name,
|
|
802
907
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
803
908
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
804
|
-
children: /* @__PURE__ */
|
|
909
|
+
children: /* @__PURE__ */ jsx7(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
805
910
|
},
|
|
806
911
|
p.preset
|
|
807
912
|
)) })
|
|
808
913
|
] }, family)),
|
|
809
|
-
/* @__PURE__ */
|
|
810
|
-
/* @__PURE__ */
|
|
811
|
-
/* @__PURE__ */
|
|
812
|
-
/* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ jsx7("div", { className: "text-slate-300", children: paper.name }),
|
|
915
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center justify-between", children: [
|
|
916
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Colour" }),
|
|
917
|
+
/* @__PURE__ */ jsx7(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
813
918
|
] }),
|
|
814
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
/* @__PURE__ */
|
|
817
|
-
/* @__PURE__ */
|
|
919
|
+
PAPER_SLIDERS.map((c) => /* @__PURE__ */ jsx7(PaintSlider, { control: c, value: readPath2(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper(patchPath(paper, c.path, v))) }, c.path)),
|
|
920
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center justify-between", children: [
|
|
921
|
+
/* @__PURE__ */ jsx7("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
922
|
+
/* @__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" })
|
|
818
923
|
] }),
|
|
819
|
-
/* @__PURE__ */
|
|
820
|
-
/* @__PURE__ */
|
|
924
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
925
|
+
/* @__PURE__ */ jsx7("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
821
926
|
" Mirror tiling"
|
|
822
927
|
] }),
|
|
823
|
-
/* @__PURE__ */
|
|
824
|
-
/* @__PURE__ */
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
827
|
-
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
-
/* @__PURE__ */
|
|
928
|
+
/* @__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" }),
|
|
929
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
930
|
+
/* @__PURE__ */ jsx7("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
931
|
+
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)),
|
|
932
|
+
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx7(PaintSlider, { control: c, value: readPath2(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
933
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
934
|
+
/* @__PURE__ */ jsx7(
|
|
830
935
|
"button",
|
|
831
936
|
{
|
|
832
937
|
type: "button",
|
|
@@ -839,31 +944,32 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
839
944
|
children: "Device tilt"
|
|
840
945
|
}
|
|
841
946
|
),
|
|
842
|
-
/* @__PURE__ */
|
|
947
|
+
/* @__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" })
|
|
843
948
|
] })
|
|
844
949
|
] }),
|
|
845
|
-
/* @__PURE__ */
|
|
846
|
-
/* @__PURE__ */
|
|
847
|
-
/* @__PURE__ */
|
|
848
|
-
/* @__PURE__ */
|
|
950
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
951
|
+
/* @__PURE__ */ jsx7("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
952
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
953
|
+
/* @__PURE__ */ jsx7("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
849
954
|
" UV blacklight"
|
|
850
955
|
] }),
|
|
851
|
-
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
852
|
-
/* @__PURE__ */
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
855
|
-
state.heat.hotCells > 0 && /* @__PURE__ */
|
|
956
|
+
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx7(PaintSlider, { control: c, value: readPath2(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
957
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-1.5", children: [
|
|
958
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.advanceHeat(10)), children: "Step heat" }),
|
|
959
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.clearHeat()), children: "Cool canvas" }),
|
|
960
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ jsxs6("span", { className: "text-[11px] text-amber-400", children: [
|
|
856
961
|
Math.round(state.heat.max * 100),
|
|
857
962
|
"% warm"
|
|
858
963
|
] })
|
|
859
964
|
] })
|
|
860
965
|
] }),
|
|
861
|
-
/* @__PURE__ */
|
|
966
|
+
/* @__PURE__ */ jsx7(FerroPanel, { controller }),
|
|
967
|
+
/* @__PURE__ */ jsx7(ErrorLine, { error })
|
|
862
968
|
] });
|
|
863
969
|
};
|
|
864
970
|
|
|
865
971
|
// src/paint-editor/ColorPanel.tsx
|
|
866
|
-
import { useMemo as
|
|
972
|
+
import { useMemo as useMemo6, useRef as useRef5, useState as useState6 } from "react";
|
|
867
973
|
import {
|
|
868
974
|
HARMONY_KINDS,
|
|
869
975
|
MIXING_PAD_HEIGHT,
|
|
@@ -880,7 +986,7 @@ import {
|
|
|
880
986
|
wheelPoint
|
|
881
987
|
} from "@pixerate/editor/paint-editor";
|
|
882
988
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
883
|
-
import { jsx as
|
|
989
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
884
990
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
885
991
|
const state = usePaintEditorState(controller);
|
|
886
992
|
const [error, attempt] = useAttempt();
|
|
@@ -891,13 +997,13 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
891
997
|
const [parts, setParts] = useState6([1, 1]);
|
|
892
998
|
const [padName, setPadName] = useState6("");
|
|
893
999
|
const padPoints = useRef5(null);
|
|
894
|
-
const ring =
|
|
1000
|
+
const ring = useMemo6(() => renderColorWheel(wheelSize, wheel), [wheelSize, wheel]);
|
|
895
1001
|
const color = state.color;
|
|
896
|
-
const harmony =
|
|
1002
|
+
const harmony = useMemo6(() => controller.harmony(kind, { color, wheel }), [controller, kind, color, wheel]);
|
|
897
1003
|
const [r, g, b] = parseHexColor(color);
|
|
898
1004
|
const hsv = rgbToHsv(r, g, b);
|
|
899
|
-
const effectWell =
|
|
900
|
-
const pad =
|
|
1005
|
+
const effectWell = useMemo6(() => state.effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(64) : null, [controller, state.effectPaint, state.effectPaintRendering]);
|
|
1006
|
+
const pad = useMemo6(() => ({ width: MIXING_PAD_WIDTH, height: MIXING_PAD_HEIGHT, data: controller.mixingPad.pixels() }), [controller, state.mixingPadVersion]);
|
|
901
1007
|
const R = wheelSize / 2;
|
|
902
1008
|
const mid = R * 0.82;
|
|
903
1009
|
const setHsv = (s, v) => controller.setColor(rgbToHexColor(...hsvToRgb(hsv.h, s, v)));
|
|
@@ -909,9 +1015,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
909
1015
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
910
1016
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
911
1017
|
};
|
|
912
|
-
return /* @__PURE__ */
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
1018
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1019
|
+
/* @__PURE__ */ jsxs7("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1020
|
+
/* @__PURE__ */ jsx8(
|
|
915
1021
|
"div",
|
|
916
1022
|
{
|
|
917
1023
|
role: "slider",
|
|
@@ -925,20 +1031,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
925
1031
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
926
1032
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
927
1033
|
},
|
|
928
|
-
children: /* @__PURE__ */
|
|
1034
|
+
children: /* @__PURE__ */ jsx8(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
929
1035
|
}
|
|
930
1036
|
),
|
|
931
|
-
/* @__PURE__ */
|
|
1037
|
+
/* @__PURE__ */ jsx8("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
932
1038
|
const p = wheelPoint(h.angle, mid);
|
|
933
|
-
return /* @__PURE__ */
|
|
1039
|
+
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);
|
|
934
1040
|
}) }),
|
|
935
|
-
/* @__PURE__ */
|
|
1041
|
+
/* @__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 } })
|
|
936
1042
|
] }),
|
|
937
|
-
/* @__PURE__ */
|
|
938
|
-
/* @__PURE__ */
|
|
939
|
-
/* @__PURE__ */
|
|
940
|
-
/* @__PURE__ */
|
|
941
|
-
/* @__PURE__ */
|
|
1043
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
|
|
1044
|
+
/* @__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" }),
|
|
1045
|
+
/* @__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" }),
|
|
1046
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1047
|
+
/* @__PURE__ */ jsx8(
|
|
942
1048
|
"input",
|
|
943
1049
|
{
|
|
944
1050
|
"aria-label": "Hex colour",
|
|
@@ -949,8 +1055,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
949
1055
|
color
|
|
950
1056
|
)
|
|
951
1057
|
] }),
|
|
952
|
-
/* @__PURE__ */
|
|
953
|
-
/* @__PURE__ */
|
|
1058
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1059
|
+
/* @__PURE__ */ jsx8(
|
|
954
1060
|
"span",
|
|
955
1061
|
{
|
|
956
1062
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -960,7 +1066,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
960
1066
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
961
1067
|
}
|
|
962
1068
|
),
|
|
963
|
-
/* @__PURE__ */
|
|
1069
|
+
/* @__PURE__ */ jsx8(
|
|
964
1070
|
"button",
|
|
965
1071
|
{
|
|
966
1072
|
type: "button",
|
|
@@ -972,26 +1078,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
972
1078
|
}
|
|
973
1079
|
)
|
|
974
1080
|
] }),
|
|
975
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
976
|
-
/* @__PURE__ */
|
|
977
|
-
/* @__PURE__ */
|
|
978
|
-
/* @__PURE__ */
|
|
1081
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx8(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1082
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1083
|
+
/* @__PURE__ */ jsx8("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1084
|
+
/* @__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" })
|
|
979
1085
|
] }),
|
|
980
|
-
/* @__PURE__ */
|
|
981
|
-
/* @__PURE__ */
|
|
982
|
-
/* @__PURE__ */
|
|
1086
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1087
|
+
/* @__PURE__ */ jsx8("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1088
|
+
/* @__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" })
|
|
983
1089
|
] }),
|
|
984
|
-
/* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
987
|
-
/* @__PURE__ */
|
|
1090
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1", children: [
|
|
1091
|
+
/* @__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)) }),
|
|
1092
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1093
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
988
1094
|
] }),
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
991
|
-
/* @__PURE__ */
|
|
1095
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1096
|
+
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)),
|
|
1097
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
992
1098
|
] }),
|
|
993
|
-
/* @__PURE__ */
|
|
994
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
1099
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1100
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx8(
|
|
995
1101
|
"button",
|
|
996
1102
|
{
|
|
997
1103
|
type: "button",
|
|
@@ -1009,15 +1115,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1009
1115
|
},
|
|
1010
1116
|
i
|
|
1011
1117
|
)),
|
|
1012
|
-
/* @__PURE__ */
|
|
1118
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1013
1119
|
] }),
|
|
1014
|
-
mixingPad && /* @__PURE__ */
|
|
1015
|
-
/* @__PURE__ */
|
|
1016
|
-
/* @__PURE__ */
|
|
1017
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1018
|
-
/* @__PURE__ */
|
|
1120
|
+
mixingPad && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1121
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1", children: [
|
|
1122
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1123
|
+
["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)),
|
|
1124
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1019
1125
|
] }),
|
|
1020
|
-
/* @__PURE__ */
|
|
1126
|
+
/* @__PURE__ */ jsx8(
|
|
1021
1127
|
"div",
|
|
1022
1128
|
{
|
|
1023
1129
|
role: "application",
|
|
@@ -1038,20 +1144,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1038
1144
|
padPoints.current = null;
|
|
1039
1145
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1040
1146
|
},
|
|
1041
|
-
children: /* @__PURE__ */
|
|
1147
|
+
children: /* @__PURE__ */ jsx8(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1042
1148
|
}
|
|
1043
1149
|
),
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
/* @__PURE__ */
|
|
1046
|
-
/* @__PURE__ */
|
|
1150
|
+
/* @__PURE__ */ jsx8("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-1", children: [
|
|
1151
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-400", children: "Sample" }),
|
|
1152
|
+
/* @__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)) })
|
|
1047
1153
|
] }) }),
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1050
|
-
/* @__PURE__ */
|
|
1051
|
-
/* @__PURE__ */
|
|
1052
|
-
/* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */
|
|
1054
|
-
/* @__PURE__ */
|
|
1154
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1155
|
+
/* @__PURE__ */ jsx8("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1156
|
+
/* @__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" }),
|
|
1157
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-500", children: ":" }),
|
|
1158
|
+
/* @__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" }),
|
|
1159
|
+
/* @__PURE__ */ jsx8("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1160
|
+
/* @__PURE__ */ jsx8(
|
|
1055
1161
|
"button",
|
|
1056
1162
|
{
|
|
1057
1163
|
type: "button",
|
|
@@ -1070,23 +1176,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1070
1176
|
}
|
|
1071
1177
|
)
|
|
1072
1178
|
] }),
|
|
1073
|
-
/* @__PURE__ */
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
/* @__PURE__ */
|
|
1179
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1180
|
+
/* @__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" }),
|
|
1181
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1076
1182
|
] }),
|
|
1077
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
1183
|
+
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: [
|
|
1184
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1185
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1080
1186
|
] }, p.id)) })
|
|
1081
1187
|
] }),
|
|
1082
|
-
/* @__PURE__ */
|
|
1188
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
1083
1189
|
] });
|
|
1084
1190
|
};
|
|
1085
1191
|
|
|
1086
1192
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1087
1193
|
import { useState as useState7 } from "react";
|
|
1088
1194
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1089
|
-
import { jsx as
|
|
1195
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1090
1196
|
function siblingIndex(layers, l) {
|
|
1091
1197
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1092
1198
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1104,18 +1210,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1104
1210
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1105
1211
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1106
1212
|
};
|
|
1107
|
-
return /* @__PURE__ */
|
|
1108
|
-
/* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
/* @__PURE__ */
|
|
1113
|
-
/* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1116
|
-
/* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1214
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-1", children: [
|
|
1215
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1216
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1217
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1218
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1219
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1220
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1221
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1222
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1117
1223
|
] }),
|
|
1118
|
-
/* @__PURE__ */
|
|
1224
|
+
/* @__PURE__ */ jsx9("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs8(
|
|
1119
1225
|
"li",
|
|
1120
1226
|
{
|
|
1121
1227
|
role: "treeitem",
|
|
@@ -1124,7 +1230,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1124
1230
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1125
1231
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1126
1232
|
children: [
|
|
1127
|
-
/* @__PURE__ */
|
|
1233
|
+
/* @__PURE__ */ jsx9(
|
|
1128
1234
|
"button",
|
|
1129
1235
|
{
|
|
1130
1236
|
type: "button",
|
|
@@ -1137,7 +1243,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1137
1243
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1138
1244
|
}
|
|
1139
1245
|
),
|
|
1140
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1246
|
+
renaming === l.id ? /* @__PURE__ */ jsx9(
|
|
1141
1247
|
"input",
|
|
1142
1248
|
{
|
|
1143
1249
|
autoFocus: true,
|
|
@@ -1154,23 +1260,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1154
1260
|
if (e.key === "Escape") setRenaming(null);
|
|
1155
1261
|
}
|
|
1156
1262
|
}
|
|
1157
|
-
) : /* @__PURE__ */
|
|
1263
|
+
) : /* @__PURE__ */ jsxs8("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1158
1264
|
l.type === "group" ? "\u25B8 " : "",
|
|
1159
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1265
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs8("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1160
1266
|
"\u270E",
|
|
1161
1267
|
" "
|
|
1162
1268
|
] }),
|
|
1163
1269
|
l.name
|
|
1164
1270
|
] }),
|
|
1165
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1271
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx9("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1166
1272
|
]
|
|
1167
1273
|
},
|
|
1168
1274
|
l.id
|
|
1169
1275
|
)) }),
|
|
1170
|
-
active && /* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1276
|
+
active && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", children: [
|
|
1277
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1278
|
+
/* @__PURE__ */ jsx9("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1279
|
+
/* @__PURE__ */ jsx9(
|
|
1174
1280
|
"input",
|
|
1175
1281
|
{
|
|
1176
1282
|
type: "range",
|
|
@@ -1184,40 +1290,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1184
1290
|
}
|
|
1185
1291
|
)
|
|
1186
1292
|
] }),
|
|
1187
|
-
/* @__PURE__ */
|
|
1188
|
-
/* @__PURE__ */
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
active.type === "group" && /* @__PURE__ */
|
|
1191
|
-
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */
|
|
1293
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1294
|
+
/* @__PURE__ */ jsx9("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1295
|
+
/* @__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: [
|
|
1296
|
+
active.type === "group" && /* @__PURE__ */ jsx9("option", { value: "pass-through", children: "Pass through" }),
|
|
1297
|
+
BLEND_MENU_GROUPS.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))
|
|
1192
1298
|
] })
|
|
1193
1299
|
] }),
|
|
1194
|
-
/* @__PURE__ */
|
|
1195
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1196
|
-
/* @__PURE__ */
|
|
1300
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex gap-1", children: [
|
|
1301
|
+
["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)),
|
|
1302
|
+
/* @__PURE__ */ jsx9("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1197
1303
|
] }),
|
|
1198
|
-
light?.hasLight && /* @__PURE__ */
|
|
1199
|
-
/* @__PURE__ */
|
|
1200
|
-
/* @__PURE__ */
|
|
1201
|
-
/* @__PURE__ */
|
|
1304
|
+
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: [
|
|
1305
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
|
|
1306
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1307
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1202
1308
|
] }),
|
|
1203
|
-
/* @__PURE__ */
|
|
1204
|
-
/* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1309
|
+
/* @__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: [
|
|
1310
|
+
/* @__PURE__ */ jsx9("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1311
|
+
/* @__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" })
|
|
1206
1312
|
] }),
|
|
1207
|
-
/* @__PURE__ */
|
|
1208
|
-
/* @__PURE__ */
|
|
1209
|
-
/* @__PURE__ */
|
|
1313
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1314
|
+
/* @__PURE__ */ jsx9("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1315
|
+
/* @__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" })
|
|
1210
1316
|
] })
|
|
1211
1317
|
] }),
|
|
1212
|
-
/* @__PURE__ */
|
|
1318
|
+
/* @__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 }) })
|
|
1213
1319
|
] }),
|
|
1214
|
-
/* @__PURE__ */
|
|
1320
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
1215
1321
|
] });
|
|
1216
1322
|
};
|
|
1217
1323
|
|
|
1218
1324
|
// src/paint-editor/WetPanel.tsx
|
|
1219
|
-
import { LIVE_PATTERN_KINDS, LIVE_PATTERN_LABELS, LIVE_PATTERN_SLIDERS, WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as
|
|
1220
|
-
import { jsx as
|
|
1325
|
+
import { LIVE_PATTERN_KINDS, LIVE_PATTERN_LABELS, LIVE_PATTERN_SLIDERS, WET_FLOW_KINDS, WET_GPU_OPTIONS, WET_PARAM_SLIDERS, WET_SPEED_SLIDER, WET_TILT_SLIDERS, readPath as readPath3, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1326
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1221
1327
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1222
1328
|
var WetPanel = ({ controller, className }) => {
|
|
1223
1329
|
const state = usePaintEditorState(controller);
|
|
@@ -1227,31 +1333,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1227
1333
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1228
1334
|
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1229
1335
|
const backend = controller.wetState();
|
|
1230
|
-
return /* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1232
|
-
/* @__PURE__ */
|
|
1233
|
-
/* @__PURE__ */
|
|
1336
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1337
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between", children: [
|
|
1338
|
+
/* @__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" }),
|
|
1339
|
+
/* @__PURE__ */ jsxs9("span", { className: "text-[10px] text-slate-500", children: [
|
|
1234
1340
|
"step ",
|
|
1235
1341
|
wet.clock
|
|
1236
1342
|
] })
|
|
1237
1343
|
] }),
|
|
1238
|
-
/* @__PURE__ */
|
|
1239
|
-
/* @__PURE__ */
|
|
1240
|
-
/* @__PURE__ */
|
|
1241
|
-
/* @__PURE__ */
|
|
1242
|
-
/* @__PURE__ */
|
|
1243
|
-
/* @__PURE__ */
|
|
1344
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", children: [
|
|
1345
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1346
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1347
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1348
|
+
/* @__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" }),
|
|
1349
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1244
1350
|
] }),
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1247
|
-
info && /* @__PURE__ */
|
|
1248
|
-
/* @__PURE__ */
|
|
1249
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1351
|
+
/* @__PURE__ */ jsx10(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1352
|
+
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)),
|
|
1353
|
+
info && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1354
|
+
/* @__PURE__ */ jsx10("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1355
|
+
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)),
|
|
1356
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1357
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1358
|
+
/* @__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)) })
|
|
1253
1359
|
] }),
|
|
1254
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1360
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx10(
|
|
1255
1361
|
PaintSlider,
|
|
1256
1362
|
{
|
|
1257
1363
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1260,10 +1366,10 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1260
1366
|
}
|
|
1261
1367
|
)
|
|
1262
1368
|
] }),
|
|
1263
|
-
livePattern && layerId && /* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1369
|
+
livePattern && layerId && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
1370
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between", children: [
|
|
1371
|
+
/* @__PURE__ */ jsx10("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
1372
|
+
/* @__PURE__ */ jsx10(
|
|
1267
1373
|
"button",
|
|
1268
1374
|
{
|
|
1269
1375
|
type: "button",
|
|
@@ -1278,35 +1384,35 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1278
1384
|
}
|
|
1279
1385
|
)
|
|
1280
1386
|
] }),
|
|
1281
|
-
/* @__PURE__ */
|
|
1282
|
-
/* @__PURE__ */
|
|
1283
|
-
/* @__PURE__ */
|
|
1387
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1388
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Pattern" }),
|
|
1389
|
+
/* @__PURE__ */ jsx10(
|
|
1284
1390
|
"select",
|
|
1285
1391
|
{
|
|
1286
1392
|
"aria-label": "Live pattern",
|
|
1287
1393
|
value: livePattern.settings.pattern,
|
|
1288
1394
|
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1289
1395
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1290
|
-
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */
|
|
1396
|
+
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: LIVE_PATTERN_LABELS[k] }, k))
|
|
1291
1397
|
}
|
|
1292
1398
|
)
|
|
1293
1399
|
] }),
|
|
1294
|
-
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */
|
|
1400
|
+
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ jsx10(PaintSlider, { control: c, value: readPath3(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1295
1401
|
] }),
|
|
1296
|
-
backend.message && /* @__PURE__ */
|
|
1297
|
-
backend.backend && /* @__PURE__ */
|
|
1298
|
-
/* @__PURE__ */
|
|
1299
|
-
/* @__PURE__ */
|
|
1300
|
-
/* @__PURE__ */
|
|
1402
|
+
backend.message && /* @__PURE__ */ jsx10("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1403
|
+
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" }),
|
|
1404
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1405
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Engine" }),
|
|
1406
|
+
/* @__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)) })
|
|
1301
1407
|
] }),
|
|
1302
|
-
/* @__PURE__ */
|
|
1303
|
-
/* @__PURE__ */
|
|
1408
|
+
/* @__PURE__ */ jsx10("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1409
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1304
1410
|
] });
|
|
1305
1411
|
};
|
|
1306
1412
|
|
|
1307
1413
|
// src/paint-editor/StickerPanel.tsx
|
|
1308
|
-
import { STICKER_SLIDERS, readPath as
|
|
1309
|
-
import { jsx as
|
|
1414
|
+
import { STICKER_SLIDERS, readPath as readPath4, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1415
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1310
1416
|
var StickerPanel = ({ controller, className }) => {
|
|
1311
1417
|
const state = usePaintEditorState(controller);
|
|
1312
1418
|
const [error, attempt] = useAttempt();
|
|
@@ -1316,16 +1422,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1316
1422
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1317
1423
|
if (!stickers.length) return null;
|
|
1318
1424
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1319
|
-
return /* @__PURE__ */
|
|
1320
|
-
/* @__PURE__ */
|
|
1425
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1426
|
+
/* @__PURE__ */ jsxs10("span", { className: "font-medium text-slate-300", children: [
|
|
1321
1427
|
"Stickers (",
|
|
1322
1428
|
stickers.length,
|
|
1323
1429
|
")"
|
|
1324
1430
|
] }),
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
sel && /* @__PURE__ */
|
|
1327
|
-
/* @__PURE__ */
|
|
1328
|
-
/* @__PURE__ */
|
|
1431
|
+
/* @__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)) }),
|
|
1432
|
+
sel && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1433
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1434
|
+
/* @__PURE__ */ jsx11(
|
|
1329
1435
|
StickerPicker,
|
|
1330
1436
|
{
|
|
1331
1437
|
controller,
|
|
@@ -1339,9 +1445,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1339
1445
|
)
|
|
1340
1446
|
}
|
|
1341
1447
|
),
|
|
1342
|
-
/* @__PURE__ */
|
|
1343
|
-
/* @__PURE__ */
|
|
1344
|
-
/* @__PURE__ */
|
|
1448
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1449
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Position" }),
|
|
1450
|
+
/* @__PURE__ */ jsx11("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx11(
|
|
1345
1451
|
"input",
|
|
1346
1452
|
{
|
|
1347
1453
|
type: "number",
|
|
@@ -1355,24 +1461,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1355
1461
|
`${sel.id}-${k}-${sel[k]}`
|
|
1356
1462
|
)) })
|
|
1357
1463
|
] }),
|
|
1358
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1359
|
-
/* @__PURE__ */
|
|
1360
|
-
/* @__PURE__ */
|
|
1361
|
-
/* @__PURE__ */
|
|
1464
|
+
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)),
|
|
1465
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between", children: [
|
|
1466
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Colour" }),
|
|
1467
|
+
/* @__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" })
|
|
1362
1468
|
] }),
|
|
1363
|
-
/* @__PURE__ */
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
/* @__PURE__ */
|
|
1469
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1470
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1471
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1472
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1367
1473
|
] })
|
|
1368
1474
|
] }),
|
|
1369
|
-
/* @__PURE__ */
|
|
1475
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1370
1476
|
] });
|
|
1371
1477
|
};
|
|
1372
1478
|
|
|
1373
1479
|
// src/paint-editor/StrokePanel.tsx
|
|
1374
|
-
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as
|
|
1375
|
-
import { jsx as
|
|
1480
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath5 } from "@pixerate/editor/paint-editor";
|
|
1481
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1376
1482
|
var StrokePanel = ({ controller, className }) => {
|
|
1377
1483
|
const state = usePaintEditorState(controller);
|
|
1378
1484
|
const [error, attempt] = useAttempt();
|
|
@@ -1382,16 +1488,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1382
1488
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1383
1489
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1384
1490
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1385
|
-
return /* @__PURE__ */
|
|
1386
|
-
/* @__PURE__ */
|
|
1387
|
-
/* @__PURE__ */
|
|
1491
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1492
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
|
|
1493
|
+
/* @__PURE__ */ jsxs11("span", { className: "font-medium text-slate-300", children: [
|
|
1388
1494
|
"Strokes (",
|
|
1389
1495
|
strokes.length,
|
|
1390
1496
|
")"
|
|
1391
1497
|
] }),
|
|
1392
|
-
/* @__PURE__ */
|
|
1498
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1393
1499
|
] }),
|
|
1394
|
-
/* @__PURE__ */
|
|
1500
|
+
/* @__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(
|
|
1395
1501
|
"button",
|
|
1396
1502
|
{
|
|
1397
1503
|
type: "button",
|
|
@@ -1404,10 +1510,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1404
1510
|
},
|
|
1405
1511
|
s.id
|
|
1406
1512
|
)) }),
|
|
1407
|
-
sel && /* @__PURE__ */
|
|
1408
|
-
/* @__PURE__ */
|
|
1409
|
-
/* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1513
|
+
sel && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1514
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1515
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Brush" }),
|
|
1516
|
+
/* @__PURE__ */ jsxs11(
|
|
1411
1517
|
"select",
|
|
1412
1518
|
{
|
|
1413
1519
|
"aria-label": "Stroke brush",
|
|
@@ -1415,41 +1521,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1415
1521
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1416
1522
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1417
1523
|
children: [
|
|
1418
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1419
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1524
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx12("option", { value: "", children: sel.brush.name }),
|
|
1525
|
+
brushes.map((b) => /* @__PURE__ */ jsx12("option", { value: b.id, children: b.name }, b.id))
|
|
1420
1526
|
]
|
|
1421
1527
|
}
|
|
1422
1528
|
)
|
|
1423
1529
|
] }),
|
|
1424
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1530
|
+
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)),
|
|
1531
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between", children: [
|
|
1532
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Colour" }),
|
|
1533
|
+
/* @__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" })
|
|
1428
1534
|
] }),
|
|
1429
|
-
/* @__PURE__ */
|
|
1430
|
-
/* @__PURE__ */
|
|
1431
|
-
/* @__PURE__ */
|
|
1432
|
-
/* @__PURE__ */
|
|
1433
|
-
/* @__PURE__ */
|
|
1535
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap gap-1", children: [
|
|
1536
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1537
|
+
/* @__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" }),
|
|
1538
|
+
/* @__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" }),
|
|
1539
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1434
1540
|
] })
|
|
1435
1541
|
] }),
|
|
1436
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1437
1543
|
] });
|
|
1438
1544
|
};
|
|
1439
1545
|
|
|
1440
1546
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1441
1547
|
import { useState as useState8 } from "react";
|
|
1442
1548
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1443
|
-
import { jsx as
|
|
1549
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1444
1550
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1445
1551
|
const state = usePaintEditorState(controller);
|
|
1446
1552
|
const [error, attempt] = useAttempt();
|
|
1447
1553
|
const [path, setPath] = useState8("");
|
|
1448
1554
|
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1449
1555
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1450
|
-
return /* @__PURE__ */
|
|
1451
|
-
/* @__PURE__ */
|
|
1452
|
-
/* @__PURE__ */
|
|
1556
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1557
|
+
/* @__PURE__ */ jsx13("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1558
|
+
/* @__PURE__ */ jsx13(
|
|
1453
1559
|
"textarea",
|
|
1454
1560
|
{
|
|
1455
1561
|
"aria-label": "SVG path data",
|
|
@@ -1460,11 +1566,11 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1460
1566
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1461
1567
|
}
|
|
1462
1568
|
),
|
|
1463
|
-
/* @__PURE__ */
|
|
1464
|
-
/* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
1569
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
|
|
1570
|
+
/* @__PURE__ */ jsx13("select", { "aria-label": "Pressure along the path", value: taper, onChange: (e) => setTaper(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: PATH_STROKE_TAPERS.map((t) => /* @__PURE__ */ jsx13("option", { value: t.id, children: t.label }, t.id)) }),
|
|
1571
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1466
1572
|
] }),
|
|
1467
|
-
/* @__PURE__ */
|
|
1573
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1468
1574
|
] });
|
|
1469
1575
|
};
|
|
1470
1576
|
|
|
@@ -1478,7 +1584,7 @@ import {
|
|
|
1478
1584
|
paintProposalGhost as paintProposalGhost2,
|
|
1479
1585
|
proposalGenomeStrokes
|
|
1480
1586
|
} from "@pixerate/editor/paint-editor";
|
|
1481
|
-
import { jsx as
|
|
1587
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1482
1588
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
1483
1589
|
const state = usePaintEditorState(controller);
|
|
1484
1590
|
const store = proposals ?? controller.proposals;
|
|
@@ -1501,16 +1607,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1501
1607
|
const toggleProposal = (id) => {
|
|
1502
1608
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
1503
1609
|
};
|
|
1504
|
-
return /* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1506
|
-
/* @__PURE__ */
|
|
1610
|
+
return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
|
|
1611
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
|
|
1612
|
+
/* @__PURE__ */ jsxs13("span", { className: "font-medium text-slate-300", children: [
|
|
1507
1613
|
"Evolution (",
|
|
1508
1614
|
eligibleStrokes.length,
|
|
1509
1615
|
")"
|
|
1510
1616
|
] }),
|
|
1511
|
-
/* @__PURE__ */
|
|
1512
|
-
/* @__PURE__ */
|
|
1513
|
-
/* @__PURE__ */
|
|
1617
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
|
|
1618
|
+
/* @__PURE__ */ jsx14("span", { children: "Count" }),
|
|
1619
|
+
/* @__PURE__ */ jsx14(
|
|
1514
1620
|
"input",
|
|
1515
1621
|
{
|
|
1516
1622
|
type: "number",
|
|
@@ -1524,9 +1630,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1524
1630
|
)
|
|
1525
1631
|
] }) })
|
|
1526
1632
|
] }),
|
|
1527
|
-
eligibleStrokes.length > 0 && /* @__PURE__ */
|
|
1633
|
+
eligibleStrokes.length > 0 && /* @__PURE__ */ jsx14("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
|
|
1528
1634
|
const on = effectiveStrokeIds.includes(s.id);
|
|
1529
|
-
return /* @__PURE__ */
|
|
1635
|
+
return /* @__PURE__ */ jsx14(
|
|
1530
1636
|
"button",
|
|
1531
1637
|
{
|
|
1532
1638
|
type: "button",
|
|
@@ -1542,7 +1648,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1542
1648
|
}) }),
|
|
1543
1649
|
EVOLUTION_SLIDERS.map((c) => {
|
|
1544
1650
|
const key = c.path;
|
|
1545
|
-
return /* @__PURE__ */
|
|
1651
|
+
return /* @__PURE__ */ jsx14(
|
|
1546
1652
|
PaintSlider,
|
|
1547
1653
|
{
|
|
1548
1654
|
control: c,
|
|
@@ -1552,8 +1658,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1552
1658
|
c.path
|
|
1553
1659
|
);
|
|
1554
1660
|
}),
|
|
1555
|
-
/* @__PURE__ */
|
|
1556
|
-
/* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap gap-1", children: [
|
|
1662
|
+
/* @__PURE__ */ jsx14(
|
|
1557
1663
|
"button",
|
|
1558
1664
|
{
|
|
1559
1665
|
type: "button",
|
|
@@ -1566,7 +1672,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1566
1672
|
children: "Breed strokes"
|
|
1567
1673
|
}
|
|
1568
1674
|
),
|
|
1569
|
-
activeProposalIds.length === 2 && /* @__PURE__ */
|
|
1675
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ jsx14(
|
|
1570
1676
|
"button",
|
|
1571
1677
|
{
|
|
1572
1678
|
type: "button",
|
|
@@ -1579,7 +1685,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1579
1685
|
children: "Cross over (2)"
|
|
1580
1686
|
}
|
|
1581
1687
|
),
|
|
1582
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1688
|
+
variants.length > 0 && /* @__PURE__ */ jsx14(
|
|
1583
1689
|
"button",
|
|
1584
1690
|
{
|
|
1585
1691
|
type: "button",
|
|
@@ -1592,16 +1698,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1592
1698
|
}
|
|
1593
1699
|
)
|
|
1594
1700
|
] }),
|
|
1595
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1701
|
+
variants.length > 0 && /* @__PURE__ */ jsx14("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
|
|
1596
1702
|
const g = paintProposalGhost2(p);
|
|
1597
1703
|
const picked = activeProposalIds.includes(p.id);
|
|
1598
|
-
return /* @__PURE__ */
|
|
1704
|
+
return /* @__PURE__ */ jsxs13(
|
|
1599
1705
|
"div",
|
|
1600
1706
|
{
|
|
1601
1707
|
"data-testid": `evolution-variant-${p.id}`,
|
|
1602
1708
|
className: `flex flex-col gap-1 rounded border p-1.5 ${picked ? "border-indigo-500 bg-slate-800/90" : "border-slate-800 bg-slate-950/60"}`,
|
|
1603
1709
|
children: [
|
|
1604
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx14(
|
|
1605
1711
|
"button",
|
|
1606
1712
|
{
|
|
1607
1713
|
type: "button",
|
|
@@ -1611,10 +1717,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1611
1717
|
children: p.title
|
|
1612
1718
|
}
|
|
1613
1719
|
) }),
|
|
1614
|
-
g && /* @__PURE__ */
|
|
1615
|
-
p.rationale && /* @__PURE__ */
|
|
1616
|
-
/* @__PURE__ */
|
|
1617
|
-
/* @__PURE__ */
|
|
1720
|
+
g && /* @__PURE__ */ jsx14("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ jsx14(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
|
|
1721
|
+
p.rationale && /* @__PURE__ */ jsx14("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
|
|
1722
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap gap-1", children: [
|
|
1723
|
+
/* @__PURE__ */ jsx14(
|
|
1618
1724
|
"button",
|
|
1619
1725
|
{
|
|
1620
1726
|
type: "button",
|
|
@@ -1627,28 +1733,28 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1627
1733
|
children: "Breed from"
|
|
1628
1734
|
}
|
|
1629
1735
|
),
|
|
1630
|
-
/* @__PURE__ */
|
|
1631
|
-
/* @__PURE__ */
|
|
1736
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
|
|
1737
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
|
|
1632
1738
|
] })
|
|
1633
1739
|
]
|
|
1634
1740
|
},
|
|
1635
1741
|
p.id
|
|
1636
1742
|
);
|
|
1637
1743
|
}) }),
|
|
1638
|
-
contactSheetUrl && /* @__PURE__ */
|
|
1639
|
-
/* @__PURE__ */
|
|
1744
|
+
contactSheetUrl && /* @__PURE__ */ jsx14("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
|
|
1745
|
+
/* @__PURE__ */ jsx14(ErrorLine, { error })
|
|
1640
1746
|
] });
|
|
1641
1747
|
};
|
|
1642
1748
|
|
|
1643
1749
|
// src/paint-editor/PaintEditor.tsx
|
|
1644
1750
|
import { useRef as useRef7, useState as useState11 } from "react";
|
|
1645
|
-
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1751
|
+
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument as screenToDocument2 } from "@pixerate/editor/paint-editor";
|
|
1646
1752
|
|
|
1647
1753
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1648
|
-
import { useEffect as useEffect5, useMemo as
|
|
1754
|
+
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6, useState as useState10 } from "react";
|
|
1649
1755
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1650
1756
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1651
|
-
import { jsx as
|
|
1757
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1652
1758
|
function usePaintEffectsProvider(controller) {
|
|
1653
1759
|
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1654
1760
|
useEffect5(() => {
|
|
@@ -1667,19 +1773,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1667
1773
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1668
1774
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1669
1775
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1670
|
-
if (!provider) return /* @__PURE__ */
|
|
1776
|
+
if (!provider) return /* @__PURE__ */ jsxs14("p", { className: "text-[11px] text-slate-400", children: [
|
|
1671
1777
|
'No effects provider: "',
|
|
1672
1778
|
name ?? effect,
|
|
1673
1779
|
'" is kept as it was drawn.'
|
|
1674
1780
|
] });
|
|
1675
|
-
if (error) return /* @__PURE__ */
|
|
1676
|
-
if (!description) return /* @__PURE__ */
|
|
1781
|
+
if (error) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1782
|
+
if (!description) return /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1677
1783
|
const commit = (gesture) => {
|
|
1678
1784
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1679
1785
|
drags.current.add(gesture);
|
|
1680
1786
|
return true;
|
|
1681
1787
|
};
|
|
1682
|
-
return /* @__PURE__ */
|
|
1788
|
+
return /* @__PURE__ */ jsx15(
|
|
1683
1789
|
EffectParameters,
|
|
1684
1790
|
{
|
|
1685
1791
|
description,
|
|
@@ -1716,7 +1822,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1716
1822
|
if (!effectPaint) return;
|
|
1717
1823
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1718
1824
|
};
|
|
1719
|
-
const thumbnail =
|
|
1825
|
+
const thumbnail = useMemo7(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1720
1826
|
const run = (work) => attempt(() => {
|
|
1721
1827
|
setBusy(true);
|
|
1722
1828
|
return work().finally(() => setBusy(false));
|
|
@@ -1732,28 +1838,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1732
1838
|
};
|
|
1733
1839
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1734
1840
|
const pixel = active?.type === "pixel";
|
|
1735
|
-
return /* @__PURE__ */
|
|
1736
|
-
/* @__PURE__ */
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
/* @__PURE__ */
|
|
1739
|
-
/* @__PURE__ */
|
|
1740
|
-
/* @__PURE__ */
|
|
1741
|
-
/* @__PURE__ */
|
|
1742
|
-
/* @__PURE__ */
|
|
1841
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1842
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1843
|
+
/* @__PURE__ */ jsx15("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1844
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1845
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1846
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1847
|
+
/* @__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" }),
|
|
1848
|
+
/* @__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" })
|
|
1743
1849
|
] }),
|
|
1744
|
-
!provider && /* @__PURE__ */
|
|
1745
|
-
browse && /* @__PURE__ */
|
|
1746
|
-
paper && /* @__PURE__ */
|
|
1747
|
-
/* @__PURE__ */
|
|
1748
|
-
/* @__PURE__ */
|
|
1850
|
+
!provider && /* @__PURE__ */ jsx15("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1851
|
+
browse && /* @__PURE__ */ jsx15(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1852
|
+
paper && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1853
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1854
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1749
1855
|
"Paper: ",
|
|
1750
1856
|
paper.name ?? paper.effect
|
|
1751
1857
|
] }),
|
|
1752
|
-
/* @__PURE__ */
|
|
1858
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1753
1859
|
] }),
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
/* @__PURE__ */
|
|
1756
|
-
/* @__PURE__ */
|
|
1860
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1861
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1862
|
+
/* @__PURE__ */ jsx15(
|
|
1757
1863
|
"input",
|
|
1758
1864
|
{
|
|
1759
1865
|
type: "range",
|
|
@@ -1775,43 +1881,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1775
1881
|
`o${paper.opacity}`
|
|
1776
1882
|
)
|
|
1777
1883
|
] }),
|
|
1778
|
-
/* @__PURE__ */
|
|
1779
|
-
/* @__PURE__ */
|
|
1780
|
-
/* @__PURE__ */
|
|
1884
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1885
|
+
/* @__PURE__ */ jsx15("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1886
|
+
/* @__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) => {
|
|
1781
1887
|
const blend = e.currentTarget.value;
|
|
1782
1888
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1783
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1889
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx15("option", { value: b, children: b }, b)) })
|
|
1784
1890
|
] }),
|
|
1785
|
-
/* @__PURE__ */
|
|
1891
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1786
1892
|
] }),
|
|
1787
|
-
effectPaint && /* @__PURE__ */
|
|
1788
|
-
/* @__PURE__ */
|
|
1789
|
-
thumbnail ? /* @__PURE__ */
|
|
1790
|
-
/* @__PURE__ */
|
|
1893
|
+
effectPaint && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1894
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1895
|
+
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,
|
|
1896
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1791
1897
|
"Paint: ",
|
|
1792
1898
|
effectPaint.effect,
|
|
1793
1899
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1794
1900
|
] }),
|
|
1795
|
-
/* @__PURE__ */
|
|
1901
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1796
1902
|
] }),
|
|
1797
|
-
/* @__PURE__ */
|
|
1798
|
-
/* @__PURE__ */
|
|
1799
|
-
/* @__PURE__ */
|
|
1903
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1904
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1905
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1800
1906
|
"Along the stroke"
|
|
1801
1907
|
] }),
|
|
1802
|
-
hasPathControl && /* @__PURE__ */
|
|
1803
|
-
/* @__PURE__ */
|
|
1908
|
+
hasPathControl && /* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
|
|
1909
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
|
|
1804
1910
|
"Along the stroke (native)"
|
|
1805
1911
|
] }),
|
|
1806
|
-
/* @__PURE__ */
|
|
1807
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1913
|
+
/* @__PURE__ */ jsx15("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1808
1914
|
"Live"
|
|
1809
1915
|
] })
|
|
1810
1916
|
] }),
|
|
1811
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */
|
|
1812
|
-
/* @__PURE__ */
|
|
1813
|
-
/* @__PURE__ */
|
|
1814
|
-
/* @__PURE__ */
|
|
1917
|
+
effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1918
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1919
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "Length" }),
|
|
1920
|
+
/* @__PURE__ */ jsx15(
|
|
1815
1921
|
"input",
|
|
1816
1922
|
{
|
|
1817
1923
|
type: "number",
|
|
@@ -1825,43 +1931,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1825
1931
|
effectPaint.map.length
|
|
1826
1932
|
)
|
|
1827
1933
|
] }),
|
|
1828
|
-
/* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
/* @__PURE__ */
|
|
1831
|
-
/* @__PURE__ */
|
|
1934
|
+
/* @__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: [
|
|
1935
|
+
/* @__PURE__ */ jsx15("option", { value: "repeat", children: "Repeat" }),
|
|
1936
|
+
/* @__PURE__ */ jsx15("option", { value: "mirror", children: "Mirror" }),
|
|
1937
|
+
/* @__PURE__ */ jsx15("option", { value: "clamp", children: "Clamp" })
|
|
1832
1938
|
] })
|
|
1833
1939
|
] }),
|
|
1834
|
-
/* @__PURE__ */
|
|
1940
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1835
1941
|
] }),
|
|
1836
|
-
animation && /* @__PURE__ */
|
|
1837
|
-
/* @__PURE__ */
|
|
1942
|
+
animation && /* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
1943
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1838
1944
|
"Live paint: ",
|
|
1839
1945
|
animation.strokes,
|
|
1840
1946
|
" ",
|
|
1841
1947
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1842
1948
|
] }),
|
|
1843
|
-
/* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
1845
|
-
/* @__PURE__ */
|
|
1846
|
-
/* @__PURE__ */
|
|
1949
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
1950
|
+
/* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1", children: [
|
|
1951
|
+
/* @__PURE__ */ jsx15("span", { className: "text-slate-400", children: "fps" }),
|
|
1952
|
+
/* @__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" })
|
|
1847
1953
|
] })
|
|
1848
1954
|
] }),
|
|
1849
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1850
|
-
/* @__PURE__ */
|
|
1851
|
-
/* @__PURE__ */
|
|
1955
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs14("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
1956
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-1", children: [
|
|
1957
|
+
/* @__PURE__ */ jsxs14("span", { className: "flex-1 truncate", children: [
|
|
1852
1958
|
"Layer: ",
|
|
1853
1959
|
layerEffect.name ?? layerEffect.effect
|
|
1854
1960
|
] }),
|
|
1855
|
-
/* @__PURE__ */
|
|
1961
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1856
1962
|
] }),
|
|
1857
|
-
/* @__PURE__ */
|
|
1963
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1858
1964
|
] }),
|
|
1859
|
-
/* @__PURE__ */
|
|
1965
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1860
1966
|
] });
|
|
1861
1967
|
};
|
|
1862
1968
|
|
|
1863
1969
|
// src/paint-editor/PaintEditor.tsx
|
|
1864
|
-
import { jsx as
|
|
1970
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1865
1971
|
var PAINT_CONTROLS = {
|
|
1866
1972
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1867
1973
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -1890,7 +1996,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1890
1996
|
};
|
|
1891
1997
|
const clientToDoc = (p) => {
|
|
1892
1998
|
const r = viewBox();
|
|
1893
|
-
return r ?
|
|
1999
|
+
return r ? screenToDocument2(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
1894
2000
|
};
|
|
1895
2001
|
const elementRect = (selector) => {
|
|
1896
2002
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -1933,27 +2039,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1933
2039
|
const [error, setError] = useState11(null);
|
|
1934
2040
|
const effects = usePaintEffectsProvider(controller);
|
|
1935
2041
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1936
|
-
return /* @__PURE__ */
|
|
1937
|
-
playing && /* @__PURE__ */
|
|
1938
|
-
/* @__PURE__ */
|
|
1939
|
-
/* @__PURE__ */
|
|
1940
|
-
/* @__PURE__ */
|
|
1941
|
-
/* @__PURE__ */
|
|
1942
|
-
/* @__PURE__ */
|
|
1943
|
-
error && /* @__PURE__ */
|
|
2042
|
+
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: [
|
|
2043
|
+
playing && /* @__PURE__ */ jsx16(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
2044
|
+
/* @__PURE__ */ jsx16(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
2045
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
2046
|
+
/* @__PURE__ */ jsx16(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
2047
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
2048
|
+
/* @__PURE__ */ jsx16(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
2049
|
+
error && /* @__PURE__ */ jsx16("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1944
2050
|
] }),
|
|
1945
|
-
/* @__PURE__ */
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
tab === "color" && /* @__PURE__ */
|
|
1949
|
-
tab === "wet" && /* @__PURE__ */
|
|
1950
|
-
tab === "paper" && /* @__PURE__ */
|
|
1951
|
-
tab === "layers" && /* @__PURE__ */
|
|
1952
|
-
tab === "layers" && /* @__PURE__ */
|
|
1953
|
-
tab === "layers" && /* @__PURE__ */
|
|
1954
|
-
tab === "layers" && /* @__PURE__ */
|
|
1955
|
-
tab === "layers" && /* @__PURE__ */
|
|
1956
|
-
tab === "effects" && effects && /* @__PURE__ */
|
|
2051
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
2052
|
+
/* @__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)) }),
|
|
2053
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
2054
|
+
tab === "color" && /* @__PURE__ */ jsx16(ColorPanel, { controller }),
|
|
2055
|
+
tab === "wet" && /* @__PURE__ */ jsx16(WetPanel, { controller }),
|
|
2056
|
+
tab === "paper" && /* @__PURE__ */ jsx16(PaperPanel, { controller }),
|
|
2057
|
+
tab === "layers" && /* @__PURE__ */ jsx16(PaintLayersPanel, { controller }),
|
|
2058
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StrokePanel, { controller }),
|
|
2059
|
+
tab === "layers" && /* @__PURE__ */ jsx16(PathStrokePanel, { controller }),
|
|
2060
|
+
tab === "layers" && /* @__PURE__ */ jsx16(EvolutionPanel, { controller, proposals }),
|
|
2061
|
+
tab === "layers" && /* @__PURE__ */ jsx16(StickerPanel, { controller }),
|
|
2062
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx16(PaintEffectsPanel, { controller })
|
|
1957
2063
|
] })
|
|
1958
2064
|
] })
|
|
1959
2065
|
] })
|
|
@@ -1965,6 +2071,7 @@ export {
|
|
|
1965
2071
|
BrushPanel,
|
|
1966
2072
|
ColorPanel,
|
|
1967
2073
|
EvolutionPanel,
|
|
2074
|
+
FerroPanel,
|
|
1968
2075
|
PaintCanvas,
|
|
1969
2076
|
PaintEditor,
|
|
1970
2077
|
PaintEffectsPanel,
|