@pixerate/editor-react 0.195.0 → 0.197.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/TimeMachinePanel.d.cts +13 -0
- package/dist/paint-editor/TimeMachinePanel.d.ts +13 -0
- package/dist/paint-editor/index.cjs +631 -558
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +404 -332
- package/package.json +3 -3
|
@@ -258,10 +258,10 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
258
258
|
y1: l.from.y,
|
|
259
259
|
x2: l.to.x,
|
|
260
260
|
y2: l.to.y,
|
|
261
|
-
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
262
|
-
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
263
|
-
strokeWidth: 1 / state.view.zoom,
|
|
264
|
-
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
261
|
+
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "stroke" || l.kind === "sticker" ? "#818cf8" : l.kind === "vortex" || l.kind === "vortex-reach" ? "#38bdf8" : "#f472b6",
|
|
262
|
+
strokeOpacity: l.kind === "vortex" ? 0.9 : l.kind === "symmetry" || l.kind === "stencil" || l.kind === "stroke" || l.kind === "sticker" ? 0.8 : l.kind === "vortex-reach" ? 0.45 : 0.35,
|
|
263
|
+
strokeWidth: (l.kind === "vortex" ? 1.5 : 1) / state.view.zoom,
|
|
264
|
+
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : l.kind === "vortex-reach" ? `${4 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
265
265
|
},
|
|
266
266
|
i
|
|
267
267
|
)),
|
|
@@ -820,7 +820,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
820
820
|
|
|
821
821
|
// src/paint-editor/PaperPanel.tsx
|
|
822
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
|
|
823
|
+
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath as readPath3, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
|
|
824
824
|
|
|
825
825
|
// src/paint-editor/FerroPanel.tsx
|
|
826
826
|
import { useMemo as useMemo4 } from "react";
|
|
@@ -884,8 +884,78 @@ var FerroPanel = ({ controller, className }) => {
|
|
|
884
884
|
] });
|
|
885
885
|
};
|
|
886
886
|
|
|
887
|
-
// src/paint-editor/
|
|
887
|
+
// src/paint-editor/TimeMachinePanel.tsx
|
|
888
|
+
import { AGE_SLIDERS, readPath as readPath2 } from "@pixerate/editor/paint-editor";
|
|
888
889
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
890
|
+
var TimeMachinePanel = ({ controller, className }) => {
|
|
891
|
+
const state = usePaintEditorState(controller);
|
|
892
|
+
const [error, attempt] = useAttempt();
|
|
893
|
+
const age = state.age;
|
|
894
|
+
return /* @__PURE__ */ jsxs6("div", { className: `${panel} ${className ?? ""}`, "data-testid": "time-machine-panel", children: [
|
|
895
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between gap-1", children: [
|
|
896
|
+
/* @__PURE__ */ jsx7("span", { className: "font-medium text-slate-300", children: "Time machine (ageing & X-ray)" }),
|
|
897
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap gap-1", children: [
|
|
898
|
+
/* @__PURE__ */ jsx7(
|
|
899
|
+
"button",
|
|
900
|
+
{
|
|
901
|
+
type: "button",
|
|
902
|
+
className: chip(age.years === 300),
|
|
903
|
+
onClick: () => attempt(() => controller.setAge({ years: 300 })),
|
|
904
|
+
children: "Age 300 yr"
|
|
905
|
+
}
|
|
906
|
+
),
|
|
907
|
+
age.years > 0 && /* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => attempt(() => controller.setAge({ years: 0 })), children: "Fresh" })
|
|
908
|
+
] })
|
|
909
|
+
] }),
|
|
910
|
+
/* @__PURE__ */ jsxs6("label", { className: "flex items-center gap-2", children: [
|
|
911
|
+
/* @__PURE__ */ jsx7(
|
|
912
|
+
"input",
|
|
913
|
+
{
|
|
914
|
+
type: "checkbox",
|
|
915
|
+
checked: state.xrayView,
|
|
916
|
+
onChange: (e) => attempt(() => controller.setXrayView(e.target.checked))
|
|
917
|
+
}
|
|
918
|
+
),
|
|
919
|
+
" ",
|
|
920
|
+
"X-ray view (pentimento)"
|
|
921
|
+
] }),
|
|
922
|
+
AGE_SLIDERS.map((c) => /* @__PURE__ */ jsx7(
|
|
923
|
+
PaintSlider,
|
|
924
|
+
{
|
|
925
|
+
control: c,
|
|
926
|
+
value: readPath2(age, c.path),
|
|
927
|
+
onChange: (v) => attempt(() => controller.setAge({ [c.path]: v }))
|
|
928
|
+
},
|
|
929
|
+
c.path
|
|
930
|
+
)),
|
|
931
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
932
|
+
/* @__PURE__ */ jsx7(
|
|
933
|
+
"button",
|
|
934
|
+
{
|
|
935
|
+
type: "button",
|
|
936
|
+
className: button,
|
|
937
|
+
disabled: age.years <= 0,
|
|
938
|
+
onClick: () => attempt(() => controller.bakeAge()),
|
|
939
|
+
children: "Bake age"
|
|
940
|
+
}
|
|
941
|
+
),
|
|
942
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: button, onClick: () => attempt(() => controller.setAge({ seed: age.seed + 1 })), children: "New crack seed" }),
|
|
943
|
+
/* @__PURE__ */ jsx7(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
type: "button",
|
|
947
|
+
className: chip(state.brush.id === "paint-scraper"),
|
|
948
|
+
onClick: () => attempt(() => controller.setBrush({ id: "paint-scraper" })),
|
|
949
|
+
children: "Scraper brush"
|
|
950
|
+
}
|
|
951
|
+
)
|
|
952
|
+
] }),
|
|
953
|
+
/* @__PURE__ */ jsx7(ErrorLine, { error })
|
|
954
|
+
] });
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
// src/paint-editor/PaperPanel.tsx
|
|
958
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
889
959
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
890
960
|
var PaperPanel = ({ controller, className }) => {
|
|
891
961
|
const state = usePaintEditorState(controller);
|
|
@@ -894,10 +964,10 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
894
964
|
useEffect4(() => tiltFollow ? startDeviceTilt2(controller) : void 0, [controller, tiltFollow]);
|
|
895
965
|
const paper = state.document.paper;
|
|
896
966
|
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__ */
|
|
898
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
/* @__PURE__ */
|
|
967
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
968
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs7("div", { children: [
|
|
969
|
+
/* @__PURE__ */ jsx8("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
970
|
+
/* @__PURE__ */ jsx8("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ jsx8(
|
|
901
971
|
"button",
|
|
902
972
|
{
|
|
903
973
|
type: "button",
|
|
@@ -906,32 +976,32 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
906
976
|
title: p.name,
|
|
907
977
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
908
978
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
909
|
-
children: /* @__PURE__ */
|
|
979
|
+
children: /* @__PURE__ */ jsx8(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
910
980
|
},
|
|
911
981
|
p.preset
|
|
912
982
|
)) })
|
|
913
983
|
] }, family)),
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
916
|
-
/* @__PURE__ */
|
|
917
|
-
/* @__PURE__ */
|
|
984
|
+
/* @__PURE__ */ jsx8("div", { className: "text-slate-300", children: paper.name }),
|
|
985
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center justify-between", children: [
|
|
986
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-400", children: "Colour" }),
|
|
987
|
+
/* @__PURE__ */ jsx8(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
918
988
|
] }),
|
|
919
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
920
|
-
/* @__PURE__ */
|
|
921
|
-
/* @__PURE__ */
|
|
922
|
-
/* @__PURE__ */
|
|
989
|
+
PAPER_SLIDERS.map((c) => /* @__PURE__ */ jsx8(PaintSlider, { control: c, value: readPath3(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper(patchPath(paper, c.path, v))) }, c.path)),
|
|
990
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center justify-between", children: [
|
|
991
|
+
/* @__PURE__ */ jsx8("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
992
|
+
/* @__PURE__ */ jsx8(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" })
|
|
923
993
|
] }),
|
|
924
|
-
/* @__PURE__ */
|
|
925
|
-
/* @__PURE__ */
|
|
994
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
995
|
+
/* @__PURE__ */ jsx8("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
926
996
|
" Mirror tiling"
|
|
927
997
|
] }),
|
|
928
|
-
/* @__PURE__ */
|
|
929
|
-
/* @__PURE__ */
|
|
930
|
-
/* @__PURE__ */
|
|
931
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
932
|
-
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
998
|
+
/* @__PURE__ */ jsx8("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" }),
|
|
999
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1000
|
+
/* @__PURE__ */ jsx8("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
1001
|
+
LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx8(PaintSlider, { control: c, value: readPath3(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1002
|
+
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx8(PaintSlider, { control: c, value: readPath3(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
1003
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1004
|
+
/* @__PURE__ */ jsx8(
|
|
935
1005
|
"button",
|
|
936
1006
|
{
|
|
937
1007
|
type: "button",
|
|
@@ -944,27 +1014,28 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
944
1014
|
children: "Device tilt"
|
|
945
1015
|
}
|
|
946
1016
|
),
|
|
947
|
-
/* @__PURE__ */
|
|
1017
|
+
/* @__PURE__ */ jsx8("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" })
|
|
948
1018
|
] })
|
|
949
1019
|
] }),
|
|
950
|
-
/* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
/* @__PURE__ */
|
|
953
|
-
/* @__PURE__ */
|
|
1020
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
1021
|
+
/* @__PURE__ */ jsx8("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
1022
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2", children: [
|
|
1023
|
+
/* @__PURE__ */ jsx8("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
954
1024
|
" UV blacklight"
|
|
955
1025
|
] }),
|
|
956
|
-
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
/* @__PURE__ */
|
|
959
|
-
/* @__PURE__ */
|
|
960
|
-
state.heat.hotCells > 0 && /* @__PURE__ */
|
|
1026
|
+
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx8(PaintSlider, { control: c, value: readPath3(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
1027
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-1.5", children: [
|
|
1028
|
+
/* @__PURE__ */ jsx8("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" }),
|
|
1029
|
+
/* @__PURE__ */ jsx8("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" }),
|
|
1030
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ jsxs7("span", { className: "text-[11px] text-amber-400", children: [
|
|
961
1031
|
Math.round(state.heat.max * 100),
|
|
962
1032
|
"% warm"
|
|
963
1033
|
] })
|
|
964
1034
|
] })
|
|
965
1035
|
] }),
|
|
966
|
-
/* @__PURE__ */
|
|
967
|
-
/* @__PURE__ */
|
|
1036
|
+
/* @__PURE__ */ jsx8(FerroPanel, { controller }),
|
|
1037
|
+
/* @__PURE__ */ jsx8(TimeMachinePanel, { controller }),
|
|
1038
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
968
1039
|
] });
|
|
969
1040
|
};
|
|
970
1041
|
|
|
@@ -986,7 +1057,7 @@ import {
|
|
|
986
1057
|
wheelPoint
|
|
987
1058
|
} from "@pixerate/editor/paint-editor";
|
|
988
1059
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
989
|
-
import { jsx as
|
|
1060
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
990
1061
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
991
1062
|
const state = usePaintEditorState(controller);
|
|
992
1063
|
const [error, attempt] = useAttempt();
|
|
@@ -1015,9 +1086,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1015
1086
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
1016
1087
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
1017
1088
|
};
|
|
1018
|
-
return /* @__PURE__ */
|
|
1019
|
-
/* @__PURE__ */
|
|
1020
|
-
/* @__PURE__ */
|
|
1089
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1090
|
+
/* @__PURE__ */ jsxs8("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1091
|
+
/* @__PURE__ */ jsx9(
|
|
1021
1092
|
"div",
|
|
1022
1093
|
{
|
|
1023
1094
|
role: "slider",
|
|
@@ -1031,20 +1102,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1031
1102
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1032
1103
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
1033
1104
|
},
|
|
1034
|
-
children: /* @__PURE__ */
|
|
1105
|
+
children: /* @__PURE__ */ jsx9(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
1035
1106
|
}
|
|
1036
1107
|
),
|
|
1037
|
-
/* @__PURE__ */
|
|
1108
|
+
/* @__PURE__ */ jsx9("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
1038
1109
|
const p = wheelPoint(h.angle, mid);
|
|
1039
|
-
return /* @__PURE__ */
|
|
1110
|
+
return /* @__PURE__ */ jsx9("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);
|
|
1040
1111
|
}) }),
|
|
1041
|
-
/* @__PURE__ */
|
|
1112
|
+
/* @__PURE__ */ jsx9("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 } })
|
|
1042
1113
|
] }),
|
|
1043
|
-
/* @__PURE__ */
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
/* @__PURE__ */
|
|
1046
|
-
/* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
1114
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
|
|
1115
|
+
/* @__PURE__ */ jsx9("input", { type: "color", "aria-label": "Paint colour", value: color, onChange: (e) => controller.setColor(e.target.value), className: "h-7 w-9 rounded bg-transparent" }),
|
|
1116
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1117
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1118
|
+
/* @__PURE__ */ jsx9(
|
|
1048
1119
|
"input",
|
|
1049
1120
|
{
|
|
1050
1121
|
"aria-label": "Hex colour",
|
|
@@ -1055,8 +1126,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1055
1126
|
color
|
|
1056
1127
|
)
|
|
1057
1128
|
] }),
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1129
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1130
|
+
/* @__PURE__ */ jsx9(
|
|
1060
1131
|
"span",
|
|
1061
1132
|
{
|
|
1062
1133
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -1066,7 +1137,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1066
1137
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1067
1138
|
}
|
|
1068
1139
|
),
|
|
1069
|
-
/* @__PURE__ */
|
|
1140
|
+
/* @__PURE__ */ jsx9(
|
|
1070
1141
|
"button",
|
|
1071
1142
|
{
|
|
1072
1143
|
type: "button",
|
|
@@ -1078,26 +1149,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1078
1149
|
}
|
|
1079
1150
|
)
|
|
1080
1151
|
] }),
|
|
1081
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
1082
|
-
/* @__PURE__ */
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */
|
|
1152
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx9(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1153
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1154
|
+
/* @__PURE__ */ jsx9("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1155
|
+
/* @__PURE__ */ jsx9("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" })
|
|
1085
1156
|
] }),
|
|
1086
|
-
/* @__PURE__ */
|
|
1087
|
-
/* @__PURE__ */
|
|
1088
|
-
/* @__PURE__ */
|
|
1157
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1158
|
+
/* @__PURE__ */ jsx9("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1159
|
+
/* @__PURE__ */ jsx9("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" })
|
|
1089
1160
|
] }),
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
/* @__PURE__ */
|
|
1092
|
-
/* @__PURE__ */
|
|
1093
|
-
/* @__PURE__ */
|
|
1161
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1", children: [
|
|
1162
|
+
/* @__PURE__ */ jsx9("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__ */ jsx9("option", { value: k, children: k }, k)) }),
|
|
1163
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1164
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1094
1165
|
] }),
|
|
1095
|
-
/* @__PURE__ */
|
|
1096
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
1097
|
-
/* @__PURE__ */
|
|
1166
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1167
|
+
harmony.map((h, i) => /* @__PURE__ */ jsx9("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)),
|
|
1168
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1098
1169
|
] }),
|
|
1099
|
-
/* @__PURE__ */
|
|
1100
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
1170
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1171
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx9(
|
|
1101
1172
|
"button",
|
|
1102
1173
|
{
|
|
1103
1174
|
type: "button",
|
|
@@ -1115,15 +1186,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1115
1186
|
},
|
|
1116
1187
|
i
|
|
1117
1188
|
)),
|
|
1118
|
-
/* @__PURE__ */
|
|
1189
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1119
1190
|
] }),
|
|
1120
|
-
mixingPad && /* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1124
|
-
/* @__PURE__ */
|
|
1191
|
+
mixingPad && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1192
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1", children: [
|
|
1193
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1194
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ jsx9("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1195
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1125
1196
|
] }),
|
|
1126
|
-
/* @__PURE__ */
|
|
1197
|
+
/* @__PURE__ */ jsx9(
|
|
1127
1198
|
"div",
|
|
1128
1199
|
{
|
|
1129
1200
|
role: "application",
|
|
@@ -1144,20 +1215,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1144
1215
|
padPoints.current = null;
|
|
1145
1216
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1146
1217
|
},
|
|
1147
|
-
children: /* @__PURE__ */
|
|
1218
|
+
children: /* @__PURE__ */ jsx9(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1148
1219
|
}
|
|
1149
1220
|
),
|
|
1150
|
-
/* @__PURE__ */
|
|
1151
|
-
/* @__PURE__ */
|
|
1152
|
-
/* @__PURE__ */
|
|
1221
|
+
/* @__PURE__ */ jsx9("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-1", children: [
|
|
1222
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Sample" }),
|
|
1223
|
+
/* @__PURE__ */ jsx9("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__ */ jsx9("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1153
1224
|
] }) }),
|
|
1154
|
-
/* @__PURE__ */
|
|
1155
|
-
/* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1157
|
-
/* @__PURE__ */
|
|
1158
|
-
/* @__PURE__ */
|
|
1159
|
-
/* @__PURE__ */
|
|
1160
|
-
/* @__PURE__ */
|
|
1225
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1226
|
+
/* @__PURE__ */ jsx9("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1227
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1228
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-500", children: ":" }),
|
|
1229
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1230
|
+
/* @__PURE__ */ jsx9("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1231
|
+
/* @__PURE__ */ jsx9(
|
|
1161
1232
|
"button",
|
|
1162
1233
|
{
|
|
1163
1234
|
type: "button",
|
|
@@ -1176,23 +1247,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1176
1247
|
}
|
|
1177
1248
|
)
|
|
1178
1249
|
] }),
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1250
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1252
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1182
1253
|
] }),
|
|
1183
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1254
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ jsx9("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ jsxs8("li", { className: "flex items-center gap-1", children: [
|
|
1255
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1256
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1186
1257
|
] }, p.id)) })
|
|
1187
1258
|
] }),
|
|
1188
|
-
/* @__PURE__ */
|
|
1259
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
1189
1260
|
] });
|
|
1190
1261
|
};
|
|
1191
1262
|
|
|
1192
1263
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1193
1264
|
import { useState as useState7 } from "react";
|
|
1194
1265
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1195
|
-
import { jsx as
|
|
1266
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1196
1267
|
function siblingIndex(layers, l) {
|
|
1197
1268
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1198
1269
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1210,18 +1281,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1210
1281
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1211
1282
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1212
1283
|
};
|
|
1213
|
-
return /* @__PURE__ */
|
|
1214
|
-
/* @__PURE__ */
|
|
1215
|
-
/* @__PURE__ */
|
|
1216
|
-
/* @__PURE__ */
|
|
1217
|
-
/* @__PURE__ */
|
|
1218
|
-
/* @__PURE__ */
|
|
1219
|
-
/* @__PURE__ */
|
|
1220
|
-
/* @__PURE__ */
|
|
1221
|
-
/* @__PURE__ */
|
|
1222
|
-
/* @__PURE__ */
|
|
1284
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1285
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", children: [
|
|
1286
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1287
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1288
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1289
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1290
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1291
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1292
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1293
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1223
1294
|
] }),
|
|
1224
|
-
/* @__PURE__ */
|
|
1295
|
+
/* @__PURE__ */ jsx10("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs9(
|
|
1225
1296
|
"li",
|
|
1226
1297
|
{
|
|
1227
1298
|
role: "treeitem",
|
|
@@ -1230,7 +1301,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1230
1301
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1231
1302
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1232
1303
|
children: [
|
|
1233
|
-
/* @__PURE__ */
|
|
1304
|
+
/* @__PURE__ */ jsx10(
|
|
1234
1305
|
"button",
|
|
1235
1306
|
{
|
|
1236
1307
|
type: "button",
|
|
@@ -1243,7 +1314,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1243
1314
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1244
1315
|
}
|
|
1245
1316
|
),
|
|
1246
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1317
|
+
renaming === l.id ? /* @__PURE__ */ jsx10(
|
|
1247
1318
|
"input",
|
|
1248
1319
|
{
|
|
1249
1320
|
autoFocus: true,
|
|
@@ -1260,23 +1331,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1260
1331
|
if (e.key === "Escape") setRenaming(null);
|
|
1261
1332
|
}
|
|
1262
1333
|
}
|
|
1263
|
-
) : /* @__PURE__ */
|
|
1334
|
+
) : /* @__PURE__ */ jsxs9("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1264
1335
|
l.type === "group" ? "\u25B8 " : "",
|
|
1265
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1336
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs9("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1266
1337
|
"\u270E",
|
|
1267
1338
|
" "
|
|
1268
1339
|
] }),
|
|
1269
1340
|
l.name
|
|
1270
1341
|
] }),
|
|
1271
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1342
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx10("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1272
1343
|
]
|
|
1273
1344
|
},
|
|
1274
1345
|
l.id
|
|
1275
1346
|
)) }),
|
|
1276
|
-
active && /* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
1278
|
-
/* @__PURE__ */
|
|
1279
|
-
/* @__PURE__ */
|
|
1347
|
+
active && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5", children: [
|
|
1348
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
1349
|
+
/* @__PURE__ */ jsx10("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1350
|
+
/* @__PURE__ */ jsx10(
|
|
1280
1351
|
"input",
|
|
1281
1352
|
{
|
|
1282
1353
|
type: "range",
|
|
@@ -1290,40 +1361,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1290
1361
|
}
|
|
1291
1362
|
)
|
|
1292
1363
|
] }),
|
|
1293
|
-
/* @__PURE__ */
|
|
1294
|
-
/* @__PURE__ */
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
active.type === "group" && /* @__PURE__ */
|
|
1297
|
-
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */
|
|
1364
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
1365
|
+
/* @__PURE__ */ jsx10("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1366
|
+
/* @__PURE__ */ jsxs9("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: [
|
|
1367
|
+
active.type === "group" && /* @__PURE__ */ jsx10("option", { value: "pass-through", children: "Pass through" }),
|
|
1368
|
+
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ jsx10("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ jsx10("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1298
1369
|
] })
|
|
1299
1370
|
] }),
|
|
1300
|
-
/* @__PURE__ */
|
|
1301
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1302
|
-
/* @__PURE__ */
|
|
1371
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex gap-1", children: [
|
|
1372
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ jsx10("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)),
|
|
1373
|
+
/* @__PURE__ */ jsx10("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1303
1374
|
] }),
|
|
1304
|
-
light?.hasLight && /* @__PURE__ */
|
|
1305
|
-
/* @__PURE__ */
|
|
1306
|
-
/* @__PURE__ */
|
|
1307
|
-
/* @__PURE__ */
|
|
1375
|
+
light?.hasLight && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1376
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between", children: [
|
|
1377
|
+
/* @__PURE__ */ jsx10("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1378
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1308
1379
|
] }),
|
|
1309
|
-
/* @__PURE__ */
|
|
1310
|
-
/* @__PURE__ */
|
|
1311
|
-
/* @__PURE__ */
|
|
1380
|
+
/* @__PURE__ */ jsxs9("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: [
|
|
1381
|
+
/* @__PURE__ */ jsx10("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1382
|
+
/* @__PURE__ */ jsx10("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" })
|
|
1312
1383
|
] }),
|
|
1313
|
-
/* @__PURE__ */
|
|
1314
|
-
/* @__PURE__ */
|
|
1315
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
1385
|
+
/* @__PURE__ */ jsx10("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1386
|
+
/* @__PURE__ */ jsx10("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" })
|
|
1316
1387
|
] })
|
|
1317
1388
|
] }),
|
|
1318
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ jsx10("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__ */ jsx10(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1319
1390
|
] }),
|
|
1320
|
-
/* @__PURE__ */
|
|
1391
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1321
1392
|
] });
|
|
1322
1393
|
};
|
|
1323
1394
|
|
|
1324
1395
|
// src/paint-editor/WetPanel.tsx
|
|
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
|
|
1326
|
-
import { jsx as
|
|
1396
|
+
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 readPath4, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1397
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1327
1398
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1328
1399
|
var WetPanel = ({ controller, className }) => {
|
|
1329
1400
|
const state = usePaintEditorState(controller);
|
|
@@ -1333,31 +1404,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1333
1404
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1334
1405
|
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1335
1406
|
const backend = controller.wetState();
|
|
1336
|
-
return /* @__PURE__ */
|
|
1337
|
-
/* @__PURE__ */
|
|
1338
|
-
/* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
1407
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1408
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1409
|
+
/* @__PURE__ */ jsx11("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1410
|
+
/* @__PURE__ */ jsxs10("span", { className: "text-[10px] text-slate-500", children: [
|
|
1340
1411
|
"step ",
|
|
1341
1412
|
wet.clock
|
|
1342
1413
|
] })
|
|
1343
1414
|
] }),
|
|
1344
|
-
/* @__PURE__ */
|
|
1345
|
-
/* @__PURE__ */
|
|
1346
|
-
/* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
/* @__PURE__ */
|
|
1415
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1416
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1417
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1418
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1419
|
+
/* @__PURE__ */ jsx11("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" }),
|
|
1420
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1350
1421
|
] }),
|
|
1351
|
-
/* @__PURE__ */
|
|
1352
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1353
|
-
info && /* @__PURE__ */
|
|
1354
|
-
/* @__PURE__ */
|
|
1355
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1356
|
-
/* @__PURE__ */
|
|
1357
|
-
/* @__PURE__ */
|
|
1358
|
-
/* @__PURE__ */
|
|
1422
|
+
/* @__PURE__ */ jsx11(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1423
|
+
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx11(PaintSlider, { control: c, value: readPath4(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1424
|
+
info && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1425
|
+
/* @__PURE__ */ jsx11("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1426
|
+
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ jsx11(PaintSlider, { control: c, value: readPath4(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1427
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1428
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1429
|
+
/* @__PURE__ */ jsx11("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__ */ jsx11("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1359
1430
|
] }),
|
|
1360
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1431
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx11(
|
|
1361
1432
|
PaintSlider,
|
|
1362
1433
|
{
|
|
1363
1434
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1366,10 +1437,10 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1366
1437
|
}
|
|
1367
1438
|
)
|
|
1368
1439
|
] }),
|
|
1369
|
-
livePattern && layerId && /* @__PURE__ */
|
|
1370
|
-
/* @__PURE__ */
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
/* @__PURE__ */
|
|
1440
|
+
livePattern && layerId && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
1441
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1442
|
+
/* @__PURE__ */ jsx11("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
1443
|
+
/* @__PURE__ */ jsx11(
|
|
1373
1444
|
"button",
|
|
1374
1445
|
{
|
|
1375
1446
|
type: "button",
|
|
@@ -1384,35 +1455,35 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1384
1455
|
}
|
|
1385
1456
|
)
|
|
1386
1457
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1388
|
-
/* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1458
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1459
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Pattern" }),
|
|
1460
|
+
/* @__PURE__ */ jsx11(
|
|
1390
1461
|
"select",
|
|
1391
1462
|
{
|
|
1392
1463
|
"aria-label": "Live pattern",
|
|
1393
1464
|
value: livePattern.settings.pattern,
|
|
1394
1465
|
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1395
1466
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1396
|
-
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */
|
|
1467
|
+
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ jsx11("option", { value: k, children: LIVE_PATTERN_LABELS[k] }, k))
|
|
1397
1468
|
}
|
|
1398
1469
|
)
|
|
1399
1470
|
] }),
|
|
1400
|
-
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */
|
|
1471
|
+
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ jsx11(PaintSlider, { control: c, value: readPath4(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1401
1472
|
] }),
|
|
1402
|
-
backend.message && /* @__PURE__ */
|
|
1403
|
-
backend.backend && /* @__PURE__ */
|
|
1404
|
-
/* @__PURE__ */
|
|
1405
|
-
/* @__PURE__ */
|
|
1406
|
-
/* @__PURE__ */
|
|
1473
|
+
backend.message && /* @__PURE__ */ jsx11("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1474
|
+
backend.backend && /* @__PURE__ */ jsx11("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" }),
|
|
1475
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1476
|
+
/* @__PURE__ */ jsx11("span", { className: "text-slate-400", children: "Engine" }),
|
|
1477
|
+
/* @__PURE__ */ jsx11("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__ */ jsx11("option", { value: o.value, children: o.label }, o.value)) })
|
|
1407
1478
|
] }),
|
|
1408
|
-
/* @__PURE__ */
|
|
1409
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ jsx11("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1480
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1410
1481
|
] });
|
|
1411
1482
|
};
|
|
1412
1483
|
|
|
1413
1484
|
// src/paint-editor/StickerPanel.tsx
|
|
1414
|
-
import { STICKER_SLIDERS, readPath as
|
|
1415
|
-
import { jsx as
|
|
1485
|
+
import { STICKER_SLIDERS, readPath as readPath5, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1486
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1416
1487
|
var StickerPanel = ({ controller, className }) => {
|
|
1417
1488
|
const state = usePaintEditorState(controller);
|
|
1418
1489
|
const [error, attempt] = useAttempt();
|
|
@@ -1422,16 +1493,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1422
1493
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1423
1494
|
if (!stickers.length) return null;
|
|
1424
1495
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1425
|
-
return /* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1496
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1497
|
+
/* @__PURE__ */ jsxs11("span", { className: "font-medium text-slate-300", children: [
|
|
1427
1498
|
"Stickers (",
|
|
1428
1499
|
stickers.length,
|
|
1429
1500
|
")"
|
|
1430
1501
|
] }),
|
|
1431
|
-
/* @__PURE__ */
|
|
1432
|
-
sel && /* @__PURE__ */
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1502
|
+
/* @__PURE__ */ jsx12("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Stickers", children: stickers.map((s) => /* @__PURE__ */ jsx12("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)) }),
|
|
1503
|
+
sel && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1504
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1505
|
+
/* @__PURE__ */ jsx12(
|
|
1435
1506
|
StickerPicker,
|
|
1436
1507
|
{
|
|
1437
1508
|
controller,
|
|
@@ -1445,9 +1516,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1445
1516
|
)
|
|
1446
1517
|
}
|
|
1447
1518
|
),
|
|
1448
|
-
/* @__PURE__ */
|
|
1449
|
-
/* @__PURE__ */
|
|
1450
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1520
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Position" }),
|
|
1521
|
+
/* @__PURE__ */ jsx12("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx12(
|
|
1451
1522
|
"input",
|
|
1452
1523
|
{
|
|
1453
1524
|
type: "number",
|
|
@@ -1461,24 +1532,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1461
1532
|
`${sel.id}-${k}-${sel[k]}`
|
|
1462
1533
|
)) })
|
|
1463
1534
|
] }),
|
|
1464
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1465
|
-
/* @__PURE__ */
|
|
1466
|
-
/* @__PURE__ */
|
|
1467
|
-
/* @__PURE__ */
|
|
1535
|
+
STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath5(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1536
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between", children: [
|
|
1537
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Colour" }),
|
|
1538
|
+
/* @__PURE__ */ jsx12(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" })
|
|
1468
1539
|
] }),
|
|
1469
|
-
/* @__PURE__ */
|
|
1470
|
-
/* @__PURE__ */
|
|
1471
|
-
/* @__PURE__ */
|
|
1472
|
-
/* @__PURE__ */
|
|
1540
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap gap-1", children: [
|
|
1541
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1542
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1543
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1473
1544
|
] })
|
|
1474
1545
|
] }),
|
|
1475
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1476
1547
|
] });
|
|
1477
1548
|
};
|
|
1478
1549
|
|
|
1479
1550
|
// src/paint-editor/StrokePanel.tsx
|
|
1480
|
-
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as
|
|
1481
|
-
import { jsx as
|
|
1551
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath6 } from "@pixerate/editor/paint-editor";
|
|
1552
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1482
1553
|
var StrokePanel = ({ controller, className }) => {
|
|
1483
1554
|
const state = usePaintEditorState(controller);
|
|
1484
1555
|
const [error, attempt] = useAttempt();
|
|
@@ -1488,16 +1559,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1488
1559
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1489
1560
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1490
1561
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1491
|
-
return /* @__PURE__ */
|
|
1492
|
-
/* @__PURE__ */
|
|
1493
|
-
/* @__PURE__ */
|
|
1562
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1563
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
|
|
1564
|
+
/* @__PURE__ */ jsxs12("span", { className: "font-medium text-slate-300", children: [
|
|
1494
1565
|
"Strokes (",
|
|
1495
1566
|
strokes.length,
|
|
1496
1567
|
")"
|
|
1497
1568
|
] }),
|
|
1498
|
-
/* @__PURE__ */
|
|
1569
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1499
1570
|
] }),
|
|
1500
|
-
/* @__PURE__ */
|
|
1571
|
+
/* @__PURE__ */ jsx13("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ jsx13(
|
|
1501
1572
|
"button",
|
|
1502
1573
|
{
|
|
1503
1574
|
type: "button",
|
|
@@ -1510,10 +1581,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1510
1581
|
},
|
|
1511
1582
|
s.id
|
|
1512
1583
|
)) }),
|
|
1513
|
-
sel && /* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
1515
|
-
/* @__PURE__ */
|
|
1516
|
-
/* @__PURE__ */
|
|
1584
|
+
sel && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1585
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1586
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Brush" }),
|
|
1587
|
+
/* @__PURE__ */ jsxs12(
|
|
1517
1588
|
"select",
|
|
1518
1589
|
{
|
|
1519
1590
|
"aria-label": "Stroke brush",
|
|
@@ -1521,41 +1592,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1521
1592
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1522
1593
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1523
1594
|
children: [
|
|
1524
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1525
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1595
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx13("option", { value: "", children: sel.brush.name }),
|
|
1596
|
+
brushes.map((b) => /* @__PURE__ */ jsx13("option", { value: b.id, children: b.name }, b.id))
|
|
1526
1597
|
]
|
|
1527
1598
|
}
|
|
1528
1599
|
)
|
|
1529
1600
|
] }),
|
|
1530
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1531
|
-
/* @__PURE__ */
|
|
1532
|
-
/* @__PURE__ */
|
|
1533
|
-
/* @__PURE__ */
|
|
1601
|
+
STROKE_SLIDERS.map((c) => /* @__PURE__ */ jsx13(PaintSlider, { control: c, value: readPath6(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1602
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center justify-between", children: [
|
|
1603
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Colour" }),
|
|
1604
|
+
/* @__PURE__ */ jsx13(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1534
1605
|
] }),
|
|
1535
|
-
/* @__PURE__ */
|
|
1536
|
-
/* @__PURE__ */
|
|
1537
|
-
/* @__PURE__ */
|
|
1538
|
-
/* @__PURE__ */
|
|
1539
|
-
/* @__PURE__ */
|
|
1606
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
|
|
1607
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1608
|
+
/* @__PURE__ */ jsx13("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" }),
|
|
1609
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1610
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1540
1611
|
] })
|
|
1541
1612
|
] }),
|
|
1542
|
-
/* @__PURE__ */
|
|
1613
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1543
1614
|
] });
|
|
1544
1615
|
};
|
|
1545
1616
|
|
|
1546
1617
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1547
1618
|
import { useState as useState8 } from "react";
|
|
1548
1619
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1549
|
-
import { jsx as
|
|
1620
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1550
1621
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1551
1622
|
const state = usePaintEditorState(controller);
|
|
1552
1623
|
const [error, attempt] = useAttempt();
|
|
1553
1624
|
const [path, setPath] = useState8("");
|
|
1554
1625
|
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1555
1626
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1556
|
-
return /* @__PURE__ */
|
|
1557
|
-
/* @__PURE__ */
|
|
1558
|
-
/* @__PURE__ */
|
|
1627
|
+
return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1628
|
+
/* @__PURE__ */ jsx14("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1629
|
+
/* @__PURE__ */ jsx14(
|
|
1559
1630
|
"textarea",
|
|
1560
1631
|
{
|
|
1561
1632
|
"aria-label": "SVG path data",
|
|
@@ -1566,11 +1637,11 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1566
1637
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1567
1638
|
}
|
|
1568
1639
|
),
|
|
1569
|
-
/* @__PURE__ */
|
|
1570
|
-
/* @__PURE__ */
|
|
1571
|
-
/* @__PURE__ */
|
|
1640
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
|
|
1641
|
+
/* @__PURE__ */ jsx14("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__ */ jsx14("option", { value: t.id, children: t.label }, t.id)) }),
|
|
1642
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1572
1643
|
] }),
|
|
1573
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ jsx14(ErrorLine, { error })
|
|
1574
1645
|
] });
|
|
1575
1646
|
};
|
|
1576
1647
|
|
|
@@ -1584,7 +1655,7 @@ import {
|
|
|
1584
1655
|
paintProposalGhost as paintProposalGhost2,
|
|
1585
1656
|
proposalGenomeStrokes
|
|
1586
1657
|
} from "@pixerate/editor/paint-editor";
|
|
1587
|
-
import { jsx as
|
|
1658
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1588
1659
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
1589
1660
|
const state = usePaintEditorState(controller);
|
|
1590
1661
|
const store = proposals ?? controller.proposals;
|
|
@@ -1607,16 +1678,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1607
1678
|
const toggleProposal = (id) => {
|
|
1608
1679
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
1609
1680
|
};
|
|
1610
|
-
return /* @__PURE__ */
|
|
1611
|
-
/* @__PURE__ */
|
|
1612
|
-
/* @__PURE__ */
|
|
1681
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
|
|
1682
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between", children: [
|
|
1683
|
+
/* @__PURE__ */ jsxs14("span", { className: "font-medium text-slate-300", children: [
|
|
1613
1684
|
"Evolution (",
|
|
1614
1685
|
eligibleStrokes.length,
|
|
1615
1686
|
")"
|
|
1616
1687
|
] }),
|
|
1617
|
-
/* @__PURE__ */
|
|
1618
|
-
/* @__PURE__ */
|
|
1619
|
-
/* @__PURE__ */
|
|
1688
|
+
/* @__PURE__ */ jsx15("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs14("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
|
|
1689
|
+
/* @__PURE__ */ jsx15("span", { children: "Count" }),
|
|
1690
|
+
/* @__PURE__ */ jsx15(
|
|
1620
1691
|
"input",
|
|
1621
1692
|
{
|
|
1622
1693
|
type: "number",
|
|
@@ -1630,9 +1701,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1630
1701
|
)
|
|
1631
1702
|
] }) })
|
|
1632
1703
|
] }),
|
|
1633
|
-
eligibleStrokes.length > 0 && /* @__PURE__ */
|
|
1704
|
+
eligibleStrokes.length > 0 && /* @__PURE__ */ jsx15("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
|
|
1634
1705
|
const on = effectiveStrokeIds.includes(s.id);
|
|
1635
|
-
return /* @__PURE__ */
|
|
1706
|
+
return /* @__PURE__ */ jsx15(
|
|
1636
1707
|
"button",
|
|
1637
1708
|
{
|
|
1638
1709
|
type: "button",
|
|
@@ -1648,7 +1719,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1648
1719
|
}) }),
|
|
1649
1720
|
EVOLUTION_SLIDERS.map((c) => {
|
|
1650
1721
|
const key = c.path;
|
|
1651
|
-
return /* @__PURE__ */
|
|
1722
|
+
return /* @__PURE__ */ jsx15(
|
|
1652
1723
|
PaintSlider,
|
|
1653
1724
|
{
|
|
1654
1725
|
control: c,
|
|
@@ -1658,8 +1729,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1658
1729
|
c.path
|
|
1659
1730
|
);
|
|
1660
1731
|
}),
|
|
1661
|
-
/* @__PURE__ */
|
|
1662
|
-
/* @__PURE__ */
|
|
1732
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap gap-1", children: [
|
|
1733
|
+
/* @__PURE__ */ jsx15(
|
|
1663
1734
|
"button",
|
|
1664
1735
|
{
|
|
1665
1736
|
type: "button",
|
|
@@ -1672,7 +1743,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1672
1743
|
children: "Breed strokes"
|
|
1673
1744
|
}
|
|
1674
1745
|
),
|
|
1675
|
-
activeProposalIds.length === 2 && /* @__PURE__ */
|
|
1746
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ jsx15(
|
|
1676
1747
|
"button",
|
|
1677
1748
|
{
|
|
1678
1749
|
type: "button",
|
|
@@ -1685,7 +1756,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1685
1756
|
children: "Cross over (2)"
|
|
1686
1757
|
}
|
|
1687
1758
|
),
|
|
1688
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1759
|
+
variants.length > 0 && /* @__PURE__ */ jsx15(
|
|
1689
1760
|
"button",
|
|
1690
1761
|
{
|
|
1691
1762
|
type: "button",
|
|
@@ -1698,16 +1769,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1698
1769
|
}
|
|
1699
1770
|
)
|
|
1700
1771
|
] }),
|
|
1701
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1772
|
+
variants.length > 0 && /* @__PURE__ */ jsx15("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
|
|
1702
1773
|
const g = paintProposalGhost2(p);
|
|
1703
1774
|
const picked = activeProposalIds.includes(p.id);
|
|
1704
|
-
return /* @__PURE__ */
|
|
1775
|
+
return /* @__PURE__ */ jsxs14(
|
|
1705
1776
|
"div",
|
|
1706
1777
|
{
|
|
1707
1778
|
"data-testid": `evolution-variant-${p.id}`,
|
|
1708
1779
|
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"}`,
|
|
1709
1780
|
children: [
|
|
1710
|
-
/* @__PURE__ */
|
|
1781
|
+
/* @__PURE__ */ jsx15("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx15(
|
|
1711
1782
|
"button",
|
|
1712
1783
|
{
|
|
1713
1784
|
type: "button",
|
|
@@ -1717,10 +1788,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1717
1788
|
children: p.title
|
|
1718
1789
|
}
|
|
1719
1790
|
) }),
|
|
1720
|
-
g && /* @__PURE__ */
|
|
1721
|
-
p.rationale && /* @__PURE__ */
|
|
1722
|
-
/* @__PURE__ */
|
|
1723
|
-
/* @__PURE__ */
|
|
1791
|
+
g && /* @__PURE__ */ jsx15("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ jsx15(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
|
|
1792
|
+
p.rationale && /* @__PURE__ */ jsx15("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
|
|
1793
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-wrap gap-1", children: [
|
|
1794
|
+
/* @__PURE__ */ jsx15(
|
|
1724
1795
|
"button",
|
|
1725
1796
|
{
|
|
1726
1797
|
type: "button",
|
|
@@ -1733,16 +1804,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1733
1804
|
children: "Breed from"
|
|
1734
1805
|
}
|
|
1735
1806
|
),
|
|
1736
|
-
/* @__PURE__ */
|
|
1737
|
-
/* @__PURE__ */
|
|
1807
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
|
|
1808
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
|
|
1738
1809
|
] })
|
|
1739
1810
|
]
|
|
1740
1811
|
},
|
|
1741
1812
|
p.id
|
|
1742
1813
|
);
|
|
1743
1814
|
}) }),
|
|
1744
|
-
contactSheetUrl && /* @__PURE__ */
|
|
1745
|
-
/* @__PURE__ */
|
|
1815
|
+
contactSheetUrl && /* @__PURE__ */ jsx15("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
|
|
1816
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1746
1817
|
] });
|
|
1747
1818
|
};
|
|
1748
1819
|
|
|
@@ -1754,7 +1825,7 @@ import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2,
|
|
|
1754
1825
|
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6, useState as useState10 } from "react";
|
|
1755
1826
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1756
1827
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1757
|
-
import { jsx as
|
|
1828
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1758
1829
|
function usePaintEffectsProvider(controller) {
|
|
1759
1830
|
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1760
1831
|
useEffect5(() => {
|
|
@@ -1773,19 +1844,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1773
1844
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1774
1845
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1775
1846
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1776
|
-
if (!provider) return /* @__PURE__ */
|
|
1847
|
+
if (!provider) return /* @__PURE__ */ jsxs15("p", { className: "text-[11px] text-slate-400", children: [
|
|
1777
1848
|
'No effects provider: "',
|
|
1778
1849
|
name ?? effect,
|
|
1779
1850
|
'" is kept as it was drawn.'
|
|
1780
1851
|
] });
|
|
1781
|
-
if (error) return /* @__PURE__ */
|
|
1782
|
-
if (!description) return /* @__PURE__ */
|
|
1852
|
+
if (error) return /* @__PURE__ */ jsx16("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1853
|
+
if (!description) return /* @__PURE__ */ jsx16("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1783
1854
|
const commit = (gesture) => {
|
|
1784
1855
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1785
1856
|
drags.current.add(gesture);
|
|
1786
1857
|
return true;
|
|
1787
1858
|
};
|
|
1788
|
-
return /* @__PURE__ */
|
|
1859
|
+
return /* @__PURE__ */ jsx16(
|
|
1789
1860
|
EffectParameters,
|
|
1790
1861
|
{
|
|
1791
1862
|
description,
|
|
@@ -1838,28 +1909,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1838
1909
|
};
|
|
1839
1910
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1840
1911
|
const pixel = active?.type === "pixel";
|
|
1841
|
-
return /* @__PURE__ */
|
|
1842
|
-
/* @__PURE__ */
|
|
1843
|
-
/* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
1845
|
-
/* @__PURE__ */
|
|
1846
|
-
/* @__PURE__ */
|
|
1847
|
-
/* @__PURE__ */
|
|
1848
|
-
/* @__PURE__ */
|
|
1912
|
+
return /* @__PURE__ */ jsxs15("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
1913
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1914
|
+
/* @__PURE__ */ jsx16("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
1915
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
1916
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
1917
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
1918
|
+
/* @__PURE__ */ jsx16("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" }),
|
|
1919
|
+
/* @__PURE__ */ jsx16("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" })
|
|
1849
1920
|
] }),
|
|
1850
|
-
!provider && /* @__PURE__ */
|
|
1851
|
-
browse && /* @__PURE__ */
|
|
1852
|
-
paper && /* @__PURE__ */
|
|
1853
|
-
/* @__PURE__ */
|
|
1854
|
-
/* @__PURE__ */
|
|
1921
|
+
!provider && /* @__PURE__ */ jsx16("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
1922
|
+
browse && /* @__PURE__ */ jsx16(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
1923
|
+
paper && /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
1924
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1", children: [
|
|
1925
|
+
/* @__PURE__ */ jsxs15("span", { className: "flex-1 truncate", children: [
|
|
1855
1926
|
"Paper: ",
|
|
1856
1927
|
paper.name ?? paper.effect
|
|
1857
1928
|
] }),
|
|
1858
|
-
/* @__PURE__ */
|
|
1929
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1859
1930
|
] }),
|
|
1860
|
-
/* @__PURE__ */
|
|
1861
|
-
/* @__PURE__ */
|
|
1862
|
-
/* @__PURE__ */
|
|
1931
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", children: [
|
|
1932
|
+
/* @__PURE__ */ jsx16("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
1933
|
+
/* @__PURE__ */ jsx16(
|
|
1863
1934
|
"input",
|
|
1864
1935
|
{
|
|
1865
1936
|
type: "range",
|
|
@@ -1881,43 +1952,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1881
1952
|
`o${paper.opacity}`
|
|
1882
1953
|
)
|
|
1883
1954
|
] }),
|
|
1884
|
-
/* @__PURE__ */
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
1955
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", children: [
|
|
1956
|
+
/* @__PURE__ */ jsx16("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
1957
|
+
/* @__PURE__ */ jsx16("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) => {
|
|
1887
1958
|
const blend = e.currentTarget.value;
|
|
1888
1959
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1889
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
1960
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx16("option", { value: b, children: b }, b)) })
|
|
1890
1961
|
] }),
|
|
1891
|
-
/* @__PURE__ */
|
|
1962
|
+
/* @__PURE__ */ jsx16(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1892
1963
|
] }),
|
|
1893
|
-
effectPaint && /* @__PURE__ */
|
|
1894
|
-
/* @__PURE__ */
|
|
1895
|
-
thumbnail ? /* @__PURE__ */
|
|
1896
|
-
/* @__PURE__ */
|
|
1964
|
+
effectPaint && /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
1965
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1", children: [
|
|
1966
|
+
thumbnail ? /* @__PURE__ */ jsx16("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
1967
|
+
/* @__PURE__ */ jsxs15("span", { className: "flex-1 truncate", children: [
|
|
1897
1968
|
"Paint: ",
|
|
1898
1969
|
effectPaint.effect,
|
|
1899
1970
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1900
1971
|
] }),
|
|
1901
|
-
/* @__PURE__ */
|
|
1972
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1902
1973
|
] }),
|
|
1903
|
-
/* @__PURE__ */
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
/* @__PURE__ */
|
|
1974
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
1975
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
1976
|
+
/* @__PURE__ */ jsx16("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1906
1977
|
"Along the stroke"
|
|
1907
1978
|
] }),
|
|
1908
|
-
hasPathControl && /* @__PURE__ */
|
|
1909
|
-
/* @__PURE__ */
|
|
1979
|
+
hasPathControl && /* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
|
|
1980
|
+
/* @__PURE__ */ jsx16("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
|
|
1910
1981
|
"Along the stroke (native)"
|
|
1911
1982
|
] }),
|
|
1912
|
-
/* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1983
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
1984
|
+
/* @__PURE__ */ jsx16("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1914
1985
|
"Live"
|
|
1915
1986
|
] })
|
|
1916
1987
|
] }),
|
|
1917
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
1919
|
-
/* @__PURE__ */
|
|
1920
|
-
/* @__PURE__ */
|
|
1988
|
+
effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1989
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", children: [
|
|
1990
|
+
/* @__PURE__ */ jsx16("span", { className: "text-slate-400", children: "Length" }),
|
|
1991
|
+
/* @__PURE__ */ jsx16(
|
|
1921
1992
|
"input",
|
|
1922
1993
|
{
|
|
1923
1994
|
type: "number",
|
|
@@ -1931,43 +2002,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1931
2002
|
effectPaint.map.length
|
|
1932
2003
|
)
|
|
1933
2004
|
] }),
|
|
1934
|
-
/* @__PURE__ */
|
|
1935
|
-
/* @__PURE__ */
|
|
1936
|
-
/* @__PURE__ */
|
|
1937
|
-
/* @__PURE__ */
|
|
2005
|
+
/* @__PURE__ */ jsxs15("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: [
|
|
2006
|
+
/* @__PURE__ */ jsx16("option", { value: "repeat", children: "Repeat" }),
|
|
2007
|
+
/* @__PURE__ */ jsx16("option", { value: "mirror", children: "Mirror" }),
|
|
2008
|
+
/* @__PURE__ */ jsx16("option", { value: "clamp", children: "Clamp" })
|
|
1938
2009
|
] })
|
|
1939
2010
|
] }),
|
|
1940
|
-
/* @__PURE__ */
|
|
2011
|
+
/* @__PURE__ */ jsx16(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
1941
2012
|
] }),
|
|
1942
|
-
animation && /* @__PURE__ */
|
|
1943
|
-
/* @__PURE__ */
|
|
2013
|
+
animation && /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
2014
|
+
/* @__PURE__ */ jsxs15("span", { className: "flex-1 truncate", children: [
|
|
1944
2015
|
"Live paint: ",
|
|
1945
2016
|
animation.strokes,
|
|
1946
2017
|
" ",
|
|
1947
2018
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
1948
2019
|
] }),
|
|
1949
|
-
/* @__PURE__ */
|
|
1950
|
-
/* @__PURE__ */
|
|
1951
|
-
/* @__PURE__ */
|
|
1952
|
-
/* @__PURE__ */
|
|
2020
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
2021
|
+
/* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1", children: [
|
|
2022
|
+
/* @__PURE__ */ jsx16("span", { className: "text-slate-400", children: "fps" }),
|
|
2023
|
+
/* @__PURE__ */ jsx16("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" })
|
|
1953
2024
|
] })
|
|
1954
2025
|
] }),
|
|
1955
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
1957
|
-
/* @__PURE__ */
|
|
2026
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
2027
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1", children: [
|
|
2028
|
+
/* @__PURE__ */ jsxs15("span", { className: "flex-1 truncate", children: [
|
|
1958
2029
|
"Layer: ",
|
|
1959
2030
|
layerEffect.name ?? layerEffect.effect
|
|
1960
2031
|
] }),
|
|
1961
|
-
/* @__PURE__ */
|
|
2032
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
1962
2033
|
] }),
|
|
1963
|
-
/* @__PURE__ */
|
|
2034
|
+
/* @__PURE__ */ jsx16(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
1964
2035
|
] }),
|
|
1965
|
-
/* @__PURE__ */
|
|
2036
|
+
/* @__PURE__ */ jsx16(ErrorLine, { error })
|
|
1966
2037
|
] });
|
|
1967
2038
|
};
|
|
1968
2039
|
|
|
1969
2040
|
// src/paint-editor/PaintEditor.tsx
|
|
1970
|
-
import { jsx as
|
|
2041
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1971
2042
|
var PAINT_CONTROLS = {
|
|
1972
2043
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1973
2044
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -2039,27 +2110,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
2039
2110
|
const [error, setError] = useState11(null);
|
|
2040
2111
|
const effects = usePaintEffectsProvider(controller);
|
|
2041
2112
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
2042
|
-
return /* @__PURE__ */
|
|
2043
|
-
playing && /* @__PURE__ */
|
|
2044
|
-
/* @__PURE__ */
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
/* @__PURE__ */
|
|
2047
|
-
/* @__PURE__ */
|
|
2048
|
-
/* @__PURE__ */
|
|
2049
|
-
error && /* @__PURE__ */
|
|
2113
|
+
return /* @__PURE__ */ jsxs16("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: [
|
|
2114
|
+
playing && /* @__PURE__ */ jsx17(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
2115
|
+
/* @__PURE__ */ jsx17(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
2116
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
2117
|
+
/* @__PURE__ */ jsx17(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
2118
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
2119
|
+
/* @__PURE__ */ jsx17(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
2120
|
+
error && /* @__PURE__ */ jsx17("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
2050
2121
|
] }),
|
|
2051
|
-
/* @__PURE__ */
|
|
2052
|
-
/* @__PURE__ */
|
|
2053
|
-
/* @__PURE__ */
|
|
2054
|
-
tab === "color" && /* @__PURE__ */
|
|
2055
|
-
tab === "wet" && /* @__PURE__ */
|
|
2056
|
-
tab === "paper" && /* @__PURE__ */
|
|
2057
|
-
tab === "layers" && /* @__PURE__ */
|
|
2058
|
-
tab === "layers" && /* @__PURE__ */
|
|
2059
|
-
tab === "layers" && /* @__PURE__ */
|
|
2060
|
-
tab === "layers" && /* @__PURE__ */
|
|
2061
|
-
tab === "layers" && /* @__PURE__ */
|
|
2062
|
-
tab === "effects" && effects && /* @__PURE__ */
|
|
2122
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
2123
|
+
/* @__PURE__ */ jsx17("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx17("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)) }),
|
|
2124
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
2125
|
+
tab === "color" && /* @__PURE__ */ jsx17(ColorPanel, { controller }),
|
|
2126
|
+
tab === "wet" && /* @__PURE__ */ jsx17(WetPanel, { controller }),
|
|
2127
|
+
tab === "paper" && /* @__PURE__ */ jsx17(PaperPanel, { controller }),
|
|
2128
|
+
tab === "layers" && /* @__PURE__ */ jsx17(PaintLayersPanel, { controller }),
|
|
2129
|
+
tab === "layers" && /* @__PURE__ */ jsx17(StrokePanel, { controller }),
|
|
2130
|
+
tab === "layers" && /* @__PURE__ */ jsx17(PathStrokePanel, { controller }),
|
|
2131
|
+
tab === "layers" && /* @__PURE__ */ jsx17(EvolutionPanel, { controller, proposals }),
|
|
2132
|
+
tab === "layers" && /* @__PURE__ */ jsx17(StickerPanel, { controller }),
|
|
2133
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx17(PaintEffectsPanel, { controller })
|
|
2063
2134
|
] })
|
|
2064
2135
|
] })
|
|
2065
2136
|
] })
|
|
@@ -2086,6 +2157,7 @@ export {
|
|
|
2086
2157
|
StickerPanel,
|
|
2087
2158
|
StickerPicker,
|
|
2088
2159
|
StrokePanel,
|
|
2160
|
+
TimeMachinePanel,
|
|
2089
2161
|
WetPanel,
|
|
2090
2162
|
useMutationRequests,
|
|
2091
2163
|
usePaintChangeFeed,
|