@pixerate/editor-react 0.190.0 → 0.192.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paint-editor/FerroPanel.d.cts +12 -0
- package/dist/paint-editor/FerroPanel.d.ts +12 -0
- package/dist/paint-editor/index.cjs +801 -660
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +469 -328
- 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 { 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);
|
|
@@ -1225,32 +1331,33 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1225
1331
|
const wet = state.wet;
|
|
1226
1332
|
const layerId = state.document.activeLayerId;
|
|
1227
1333
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1334
|
+
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1228
1335
|
const backend = controller.wetState();
|
|
1229
|
-
return /* @__PURE__ */
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1232
|
-
/* @__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: [
|
|
1233
1340
|
"step ",
|
|
1234
1341
|
wet.clock
|
|
1235
1342
|
] })
|
|
1236
1343
|
] }),
|
|
1237
|
-
/* @__PURE__ */
|
|
1238
|
-
/* @__PURE__ */
|
|
1239
|
-
/* @__PURE__ */
|
|
1240
|
-
/* @__PURE__ */
|
|
1241
|
-
/* @__PURE__ */
|
|
1242
|
-
/* @__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" })
|
|
1243
1350
|
] }),
|
|
1244
|
-
/* @__PURE__ */
|
|
1245
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1246
|
-
info && /* @__PURE__ */
|
|
1247
|
-
/* @__PURE__ */
|
|
1248
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__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)) })
|
|
1252
1359
|
] }),
|
|
1253
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1360
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx10(
|
|
1254
1361
|
PaintSlider,
|
|
1255
1362
|
{
|
|
1256
1363
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1259,20 +1366,53 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1259
1366
|
}
|
|
1260
1367
|
)
|
|
1261
1368
|
] }),
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
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(
|
|
1373
|
+
"button",
|
|
1374
|
+
{
|
|
1375
|
+
type: "button",
|
|
1376
|
+
className: button,
|
|
1377
|
+
onClick: () => attempt(async () => {
|
|
1378
|
+
await controller.wetIdle();
|
|
1379
|
+
const cx = Math.round(state.document.canvas.width / 2);
|
|
1380
|
+
const cy = Math.round(state.document.canvas.height / 2);
|
|
1381
|
+
controller.seedLivePatterns({ layerId, points: [{ x: cx, y: cy }] });
|
|
1382
|
+
}),
|
|
1383
|
+
children: "Seed pattern"
|
|
1384
|
+
}
|
|
1385
|
+
)
|
|
1386
|
+
] }),
|
|
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(
|
|
1390
|
+
"select",
|
|
1391
|
+
{
|
|
1392
|
+
"aria-label": "Live pattern",
|
|
1393
|
+
value: livePattern.settings.pattern,
|
|
1394
|
+
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1395
|
+
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1396
|
+
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: LIVE_PATTERN_LABELS[k] }, k))
|
|
1397
|
+
}
|
|
1398
|
+
)
|
|
1399
|
+
] }),
|
|
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))
|
|
1267
1401
|
] }),
|
|
1268
|
-
/* @__PURE__ */
|
|
1269
|
-
/* @__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)) })
|
|
1407
|
+
] }),
|
|
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 })
|
|
1270
1410
|
] });
|
|
1271
1411
|
};
|
|
1272
1412
|
|
|
1273
1413
|
// src/paint-editor/StickerPanel.tsx
|
|
1274
|
-
import { STICKER_SLIDERS, readPath as
|
|
1275
|
-
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";
|
|
1276
1416
|
var StickerPanel = ({ controller, className }) => {
|
|
1277
1417
|
const state = usePaintEditorState(controller);
|
|
1278
1418
|
const [error, attempt] = useAttempt();
|
|
@@ -1282,16 +1422,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1282
1422
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1283
1423
|
if (!stickers.length) return null;
|
|
1284
1424
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1285
|
-
return /* @__PURE__ */
|
|
1286
|
-
/* @__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: [
|
|
1287
1427
|
"Stickers (",
|
|
1288
1428
|
stickers.length,
|
|
1289
1429
|
")"
|
|
1290
1430
|
] }),
|
|
1291
|
-
/* @__PURE__ */
|
|
1292
|
-
sel && /* @__PURE__ */
|
|
1293
|
-
/* @__PURE__ */
|
|
1294
|
-
/* @__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(
|
|
1295
1435
|
StickerPicker,
|
|
1296
1436
|
{
|
|
1297
1437
|
controller,
|
|
@@ -1305,9 +1445,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1305
1445
|
)
|
|
1306
1446
|
}
|
|
1307
1447
|
),
|
|
1308
|
-
/* @__PURE__ */
|
|
1309
|
-
/* @__PURE__ */
|
|
1310
|
-
/* @__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(
|
|
1311
1451
|
"input",
|
|
1312
1452
|
{
|
|
1313
1453
|
type: "number",
|
|
@@ -1321,24 +1461,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1321
1461
|
`${sel.id}-${k}-${sel[k]}`
|
|
1322
1462
|
)) })
|
|
1323
1463
|
] }),
|
|
1324
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
/* @__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" })
|
|
1328
1468
|
] }),
|
|
1329
|
-
/* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
/* @__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" })
|
|
1333
1473
|
] })
|
|
1334
1474
|
] }),
|
|
1335
|
-
/* @__PURE__ */
|
|
1475
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1336
1476
|
] });
|
|
1337
1477
|
};
|
|
1338
1478
|
|
|
1339
1479
|
// src/paint-editor/StrokePanel.tsx
|
|
1340
|
-
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as
|
|
1341
|
-
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";
|
|
1342
1482
|
var StrokePanel = ({ controller, className }) => {
|
|
1343
1483
|
const state = usePaintEditorState(controller);
|
|
1344
1484
|
const [error, attempt] = useAttempt();
|
|
@@ -1348,16 +1488,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1348
1488
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1349
1489
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1350
1490
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1351
|
-
return /* @__PURE__ */
|
|
1352
|
-
/* @__PURE__ */
|
|
1353
|
-
/* @__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: [
|
|
1354
1494
|
"Strokes (",
|
|
1355
1495
|
strokes.length,
|
|
1356
1496
|
")"
|
|
1357
1497
|
] }),
|
|
1358
|
-
/* @__PURE__ */
|
|
1498
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1359
1499
|
] }),
|
|
1360
|
-
/* @__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(
|
|
1361
1501
|
"button",
|
|
1362
1502
|
{
|
|
1363
1503
|
type: "button",
|
|
@@ -1370,10 +1510,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1370
1510
|
},
|
|
1371
1511
|
s.id
|
|
1372
1512
|
)) }),
|
|
1373
|
-
sel && /* @__PURE__ */
|
|
1374
|
-
/* @__PURE__ */
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
/* @__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(
|
|
1377
1517
|
"select",
|
|
1378
1518
|
{
|
|
1379
1519
|
"aria-label": "Stroke brush",
|
|
@@ -1381,41 +1521,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1381
1521
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1382
1522
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1383
1523
|
children: [
|
|
1384
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1385
|
-
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))
|
|
1386
1526
|
]
|
|
1387
1527
|
}
|
|
1388
1528
|
)
|
|
1389
1529
|
] }),
|
|
1390
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1391
|
-
/* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
/* @__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" })
|
|
1394
1534
|
] }),
|
|
1395
|
-
/* @__PURE__ */
|
|
1396
|
-
/* @__PURE__ */
|
|
1397
|
-
/* @__PURE__ */
|
|
1398
|
-
/* @__PURE__ */
|
|
1399
|
-
/* @__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" })
|
|
1400
1540
|
] })
|
|
1401
1541
|
] }),
|
|
1402
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1403
1543
|
] });
|
|
1404
1544
|
};
|
|
1405
1545
|
|
|
1406
1546
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1407
1547
|
import { useState as useState8 } from "react";
|
|
1408
1548
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1409
|
-
import { jsx as
|
|
1549
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1410
1550
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1411
1551
|
const state = usePaintEditorState(controller);
|
|
1412
1552
|
const [error, attempt] = useAttempt();
|
|
1413
1553
|
const [path, setPath] = useState8("");
|
|
1414
1554
|
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1415
1555
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1416
|
-
return /* @__PURE__ */
|
|
1417
|
-
/* @__PURE__ */
|
|
1418
|
-
/* @__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(
|
|
1419
1559
|
"textarea",
|
|
1420
1560
|
{
|
|
1421
1561
|
"aria-label": "SVG path data",
|
|
@@ -1426,11 +1566,11 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1426
1566
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1427
1567
|
}
|
|
1428
1568
|
),
|
|
1429
|
-
/* @__PURE__ */
|
|
1430
|
-
/* @__PURE__ */
|
|
1431
|
-
/* @__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" })
|
|
1432
1572
|
] }),
|
|
1433
|
-
/* @__PURE__ */
|
|
1573
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1434
1574
|
] });
|
|
1435
1575
|
};
|
|
1436
1576
|
|
|
@@ -1444,7 +1584,7 @@ import {
|
|
|
1444
1584
|
paintProposalGhost as paintProposalGhost2,
|
|
1445
1585
|
proposalGenomeStrokes
|
|
1446
1586
|
} from "@pixerate/editor/paint-editor";
|
|
1447
|
-
import { jsx as
|
|
1587
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1448
1588
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
1449
1589
|
const state = usePaintEditorState(controller);
|
|
1450
1590
|
const store = proposals ?? controller.proposals;
|
|
@@ -1467,16 +1607,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1467
1607
|
const toggleProposal = (id) => {
|
|
1468
1608
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
1469
1609
|
};
|
|
1470
|
-
return /* @__PURE__ */
|
|
1471
|
-
/* @__PURE__ */
|
|
1472
|
-
/* @__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: [
|
|
1473
1613
|
"Evolution (",
|
|
1474
1614
|
eligibleStrokes.length,
|
|
1475
1615
|
")"
|
|
1476
1616
|
] }),
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
/* @__PURE__ */
|
|
1479
|
-
/* @__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(
|
|
1480
1620
|
"input",
|
|
1481
1621
|
{
|
|
1482
1622
|
type: "number",
|
|
@@ -1490,9 +1630,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1490
1630
|
)
|
|
1491
1631
|
] }) })
|
|
1492
1632
|
] }),
|
|
1493
|
-
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) => {
|
|
1494
1634
|
const on = effectiveStrokeIds.includes(s.id);
|
|
1495
|
-
return /* @__PURE__ */
|
|
1635
|
+
return /* @__PURE__ */ jsx14(
|
|
1496
1636
|
"button",
|
|
1497
1637
|
{
|
|
1498
1638
|
type: "button",
|
|
@@ -1508,7 +1648,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1508
1648
|
}) }),
|
|
1509
1649
|
EVOLUTION_SLIDERS.map((c) => {
|
|
1510
1650
|
const key = c.path;
|
|
1511
|
-
return /* @__PURE__ */
|
|
1651
|
+
return /* @__PURE__ */ jsx14(
|
|
1512
1652
|
PaintSlider,
|
|
1513
1653
|
{
|
|
1514
1654
|
control: c,
|
|
@@ -1518,8 +1658,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1518
1658
|
c.path
|
|
1519
1659
|
);
|
|
1520
1660
|
}),
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
/* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap gap-1", children: [
|
|
1662
|
+
/* @__PURE__ */ jsx14(
|
|
1523
1663
|
"button",
|
|
1524
1664
|
{
|
|
1525
1665
|
type: "button",
|
|
@@ -1532,7 +1672,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1532
1672
|
children: "Breed strokes"
|
|
1533
1673
|
}
|
|
1534
1674
|
),
|
|
1535
|
-
activeProposalIds.length === 2 && /* @__PURE__ */
|
|
1675
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ jsx14(
|
|
1536
1676
|
"button",
|
|
1537
1677
|
{
|
|
1538
1678
|
type: "button",
|
|
@@ -1545,7 +1685,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1545
1685
|
children: "Cross over (2)"
|
|
1546
1686
|
}
|
|
1547
1687
|
),
|
|
1548
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1688
|
+
variants.length > 0 && /* @__PURE__ */ jsx14(
|
|
1549
1689
|
"button",
|
|
1550
1690
|
{
|
|
1551
1691
|
type: "button",
|
|
@@ -1558,16 +1698,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1558
1698
|
}
|
|
1559
1699
|
)
|
|
1560
1700
|
] }),
|
|
1561
|
-
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) => {
|
|
1562
1702
|
const g = paintProposalGhost2(p);
|
|
1563
1703
|
const picked = activeProposalIds.includes(p.id);
|
|
1564
|
-
return /* @__PURE__ */
|
|
1704
|
+
return /* @__PURE__ */ jsxs13(
|
|
1565
1705
|
"div",
|
|
1566
1706
|
{
|
|
1567
1707
|
"data-testid": `evolution-variant-${p.id}`,
|
|
1568
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"}`,
|
|
1569
1709
|
children: [
|
|
1570
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ jsx14("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx14(
|
|
1571
1711
|
"button",
|
|
1572
1712
|
{
|
|
1573
1713
|
type: "button",
|
|
@@ -1577,10 +1717,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1577
1717
|
children: p.title
|
|
1578
1718
|
}
|
|
1579
1719
|
) }),
|
|
1580
|
-
g && /* @__PURE__ */
|
|
1581
|
-
p.rationale && /* @__PURE__ */
|
|
1582
|
-
/* @__PURE__ */
|
|
1583
|
-
/* @__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(
|
|
1584
1724
|
"button",
|
|
1585
1725
|
{
|
|
1586
1726
|
type: "button",
|
|
@@ -1593,28 +1733,28 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1593
1733
|
children: "Breed from"
|
|
1594
1734
|
}
|
|
1595
1735
|
),
|
|
1596
|
-
/* @__PURE__ */
|
|
1597
|
-
/* @__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" })
|
|
1598
1738
|
] })
|
|
1599
1739
|
]
|
|
1600
1740
|
},
|
|
1601
1741
|
p.id
|
|
1602
1742
|
);
|
|
1603
1743
|
}) }),
|
|
1604
|
-
contactSheetUrl && /* @__PURE__ */
|
|
1605
|
-
/* @__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 })
|
|
1606
1746
|
] });
|
|
1607
1747
|
};
|
|
1608
1748
|
|
|
1609
1749
|
// src/paint-editor/PaintEditor.tsx
|
|
1610
1750
|
import { useRef as useRef7, useState as useState11 } from "react";
|
|
1611
|
-
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";
|
|
1612
1752
|
|
|
1613
1753
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1614
|
-
import { useEffect as useEffect5, useMemo as
|
|
1754
|
+
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6, useState as useState10 } from "react";
|
|
1615
1755
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1616
1756
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1617
|
-
import { jsx as
|
|
1757
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1618
1758
|
function usePaintEffectsProvider(controller) {
|
|
1619
1759
|
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1620
1760
|
useEffect5(() => {
|
|
@@ -1633,19 +1773,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1633
1773
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1634
1774
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1635
1775
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1636
|
-
if (!provider) return /* @__PURE__ */
|
|
1776
|
+
if (!provider) return /* @__PURE__ */ jsxs14("p", { className: "text-[11px] text-slate-400", children: [
|
|
1637
1777
|
'No effects provider: "',
|
|
1638
1778
|
name ?? effect,
|
|
1639
1779
|
'" is kept as it was drawn.'
|
|
1640
1780
|
] });
|
|
1641
|
-
if (error) return /* @__PURE__ */
|
|
1642
|
-
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" });
|
|
1643
1783
|
const commit = (gesture) => {
|
|
1644
1784
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1645
1785
|
drags.current.add(gesture);
|
|
1646
1786
|
return true;
|
|
1647
1787
|
};
|
|
1648
|
-
return /* @__PURE__ */
|
|
1788
|
+
return /* @__PURE__ */ jsx15(
|
|
1649
1789
|
EffectParameters,
|
|
1650
1790
|
{
|
|
1651
1791
|
description,
|
|
@@ -1682,7 +1822,7 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1682
1822
|
if (!effectPaint) return;
|
|
1683
1823
|
run(() => controller.setEffectPaint({ effect: effectPaint.effect, values: effectPaint.values, time: effectPaint.time, map: effectPaint.map, live: effectPaint.live, ...patch }));
|
|
1684
1824
|
};
|
|
1685
|
-
const thumbnail =
|
|
1825
|
+
const thumbnail = useMemo7(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
1686
1826
|
const run = (work) => attempt(() => {
|
|
1687
1827
|
setBusy(true);
|
|
1688
1828
|
return work().finally(() => setBusy(false));
|
|
@@ -1698,28 +1838,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1698
1838
|
};
|
|
1699
1839
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1700
1840
|
const pixel = active?.type === "pixel";
|
|
1701
|
-
return /* @__PURE__ */
|
|
1702
|
-
/* @__PURE__ */
|
|
1703
|
-
/* @__PURE__ */
|
|
1704
|
-
/* @__PURE__ */
|
|
1705
|
-
/* @__PURE__ */
|
|
1706
|
-
/* @__PURE__ */
|
|
1707
|
-
/* @__PURE__ */
|
|
1708
|
-
/* @__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" })
|
|
1709
1849
|
] }),
|
|
1710
|
-
!provider && /* @__PURE__ */
|
|
1711
|
-
browse && /* @__PURE__ */
|
|
1712
|
-
paper && /* @__PURE__ */
|
|
1713
|
-
/* @__PURE__ */
|
|
1714
|
-
/* @__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: [
|
|
1715
1855
|
"Paper: ",
|
|
1716
1856
|
paper.name ?? paper.effect
|
|
1717
1857
|
] }),
|
|
1718
|
-
/* @__PURE__ */
|
|
1858
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1719
1859
|
] }),
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
/* @__PURE__ */
|
|
1722
|
-
/* @__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(
|
|
1723
1863
|
"input",
|
|
1724
1864
|
{
|
|
1725
1865
|
type: "range",
|
|
@@ -1741,43 +1881,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1741
1881
|
`o${paper.opacity}`
|
|
1742
1882
|
)
|
|
1743
1883
|
] }),
|
|
1744
|
-
/* @__PURE__ */
|
|
1745
|
-
/* @__PURE__ */
|
|
1746
|
-
/* @__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) => {
|
|
1747
1887
|
const blend = e.currentTarget.value;
|
|
1748
1888
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1749
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1889
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx15("option", { value: b, children: b }, b)) })
|
|
1750
1890
|
] }),
|
|
1751
|
-
/* @__PURE__ */
|
|
1891
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1752
1892
|
] }),
|
|
1753
|
-
effectPaint && /* @__PURE__ */
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
thumbnail ? /* @__PURE__ */
|
|
1756
|
-
/* @__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: [
|
|
1757
1897
|
"Paint: ",
|
|
1758
1898
|
effectPaint.effect,
|
|
1759
1899
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1760
1900
|
] }),
|
|
1761
|
-
/* @__PURE__ */
|
|
1901
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1762
1902
|
] }),
|
|
1763
|
-
/* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1765
|
-
/* @__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" } }) }),
|
|
1766
1906
|
"Along the stroke"
|
|
1767
1907
|
] }),
|
|
1768
|
-
hasPathControl && /* @__PURE__ */
|
|
1769
|
-
/* @__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" } }) }),
|
|
1770
1910
|
"Along the stroke (native)"
|
|
1771
1911
|
] }),
|
|
1772
|
-
/* @__PURE__ */
|
|
1773
|
-
/* @__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 }) }),
|
|
1774
1914
|
"Live"
|
|
1775
1915
|
] })
|
|
1776
1916
|
] }),
|
|
1777
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */
|
|
1778
|
-
/* @__PURE__ */
|
|
1779
|
-
/* @__PURE__ */
|
|
1780
|
-
/* @__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(
|
|
1781
1921
|
"input",
|
|
1782
1922
|
{
|
|
1783
1923
|
type: "number",
|
|
@@ -1791,43 +1931,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1791
1931
|
effectPaint.map.length
|
|
1792
1932
|
)
|
|
1793
1933
|
] }),
|
|
1794
|
-
/* @__PURE__ */
|
|
1795
|
-
/* @__PURE__ */
|
|
1796
|
-
/* @__PURE__ */
|
|
1797
|
-
/* @__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" })
|
|
1798
1938
|
] })
|
|
1799
1939
|
] }),
|
|
1800
|
-
/* @__PURE__ */
|
|
1940
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1801
1941
|
] }),
|
|
1802
|
-
animation && /* @__PURE__ */
|
|
1803
|
-
/* @__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: [
|
|
1804
1944
|
"Live paint: ",
|
|
1805
1945
|
animation.strokes,
|
|
1806
1946
|
" ",
|
|
1807
1947
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1808
1948
|
] }),
|
|
1809
|
-
/* @__PURE__ */
|
|
1810
|
-
/* @__PURE__ */
|
|
1811
|
-
/* @__PURE__ */
|
|
1812
|
-
/* @__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" })
|
|
1813
1953
|
] })
|
|
1814
1954
|
] }),
|
|
1815
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1816
|
-
/* @__PURE__ */
|
|
1817
|
-
/* @__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: [
|
|
1818
1958
|
"Layer: ",
|
|
1819
1959
|
layerEffect.name ?? layerEffect.effect
|
|
1820
1960
|
] }),
|
|
1821
|
-
/* @__PURE__ */
|
|
1961
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1822
1962
|
] }),
|
|
1823
|
-
/* @__PURE__ */
|
|
1963
|
+
/* @__PURE__ */ jsx15(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1824
1964
|
] }),
|
|
1825
|
-
/* @__PURE__ */
|
|
1965
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1826
1966
|
] });
|
|
1827
1967
|
};
|
|
1828
1968
|
|
|
1829
1969
|
// src/paint-editor/PaintEditor.tsx
|
|
1830
|
-
import { jsx as
|
|
1970
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1831
1971
|
var PAINT_CONTROLS = {
|
|
1832
1972
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1833
1973
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -1856,7 +1996,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1856
1996
|
};
|
|
1857
1997
|
const clientToDoc = (p) => {
|
|
1858
1998
|
const r = viewBox();
|
|
1859
|
-
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;
|
|
1860
2000
|
};
|
|
1861
2001
|
const elementRect = (selector) => {
|
|
1862
2002
|
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
@@ -1899,27 +2039,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
1899
2039
|
const [error, setError] = useState11(null);
|
|
1900
2040
|
const effects = usePaintEffectsProvider(controller);
|
|
1901
2041
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1902
|
-
return /* @__PURE__ */
|
|
1903
|
-
playing && /* @__PURE__ */
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
/* @__PURE__ */
|
|
1906
|
-
/* @__PURE__ */
|
|
1907
|
-
/* @__PURE__ */
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
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 })
|
|
1910
2050
|
] }),
|
|
1911
|
-
/* @__PURE__ */
|
|
1912
|
-
/* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
tab === "color" && /* @__PURE__ */
|
|
1915
|
-
tab === "wet" && /* @__PURE__ */
|
|
1916
|
-
tab === "paper" && /* @__PURE__ */
|
|
1917
|
-
tab === "layers" && /* @__PURE__ */
|
|
1918
|
-
tab === "layers" && /* @__PURE__ */
|
|
1919
|
-
tab === "layers" && /* @__PURE__ */
|
|
1920
|
-
tab === "layers" && /* @__PURE__ */
|
|
1921
|
-
tab === "layers" && /* @__PURE__ */
|
|
1922
|
-
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 })
|
|
1923
2063
|
] })
|
|
1924
2064
|
] })
|
|
1925
2065
|
] })
|
|
@@ -1931,6 +2071,7 @@ export {
|
|
|
1931
2071
|
BrushPanel,
|
|
1932
2072
|
ColorPanel,
|
|
1933
2073
|
EvolutionPanel,
|
|
2074
|
+
FerroPanel,
|
|
1934
2075
|
PaintCanvas,
|
|
1935
2076
|
PaintEditor,
|
|
1936
2077
|
PaintEffectsPanel,
|