@pixerate/editor-react 0.197.0 → 0.198.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/paint-editor/CulturePanel.d.cts +13 -0
- package/dist/paint-editor/CulturePanel.d.ts +13 -0
- package/dist/paint-editor/index.cjs +647 -556
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +421 -330
- package/package.json +3 -3
|
@@ -116,6 +116,7 @@ import {
|
|
|
116
116
|
drawWaterOverlay,
|
|
117
117
|
startDeviceTilt,
|
|
118
118
|
startWetClock,
|
|
119
|
+
startCultureCatchUp,
|
|
119
120
|
fitZoom,
|
|
120
121
|
guideOverlay,
|
|
121
122
|
handlePaintShortcut,
|
|
@@ -178,8 +179,14 @@ var PaintCanvas = ({ controller, tool = "brush", fillOptions, showGuides = true,
|
|
|
178
179
|
if (ctx && typeof ctx.createImageData === "function") drawWaterOverlay(controller, ctx);
|
|
179
180
|
}, [state, controller]);
|
|
180
181
|
useEffect2(() => {
|
|
182
|
+
const stopCatchUp = startCultureCatchUp(controller);
|
|
181
183
|
const player = controller.playEffects();
|
|
182
|
-
|
|
184
|
+
const cultures = controller.playCultures();
|
|
185
|
+
return () => {
|
|
186
|
+
stopCatchUp();
|
|
187
|
+
player.stop();
|
|
188
|
+
cultures.stop();
|
|
189
|
+
};
|
|
183
190
|
}, [controller]);
|
|
184
191
|
useEffect2(() => {
|
|
185
192
|
const el = viewport.current;
|
|
@@ -820,7 +827,7 @@ var BrushPanel = ({ controller, thumbnailWidth = 112, thumbnailHeight = 32, clas
|
|
|
820
827
|
|
|
821
828
|
// src/paint-editor/PaperPanel.tsx
|
|
822
829
|
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
|
|
830
|
+
import { DEFAULT_BACKLIGHT_COLOR, LIGHT_SLIDERS, PAPER_FAMILIES, PAPER_LIBRARY, PAPER_SLIDERS, UV_LIGHT_SLIDERS, VIEW_TILT_SLIDERS, patchPath, readPath as readPath4, renderPaper, requestDeviceTiltPermission, startDeviceTilt as startDeviceTilt2 } from "@pixerate/editor/paint-editor";
|
|
824
831
|
|
|
825
832
|
// src/paint-editor/FerroPanel.tsx
|
|
826
833
|
import { useMemo as useMemo4 } from "react";
|
|
@@ -954,8 +961,90 @@ var TimeMachinePanel = ({ controller, className }) => {
|
|
|
954
961
|
] });
|
|
955
962
|
};
|
|
956
963
|
|
|
957
|
-
// src/paint-editor/
|
|
964
|
+
// src/paint-editor/CulturePanel.tsx
|
|
965
|
+
import { CULTURE_SLIDERS, readPath as readPath3 } from "@pixerate/editor/paint-editor";
|
|
958
966
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
967
|
+
var CulturePanel = ({ controller, className }) => {
|
|
968
|
+
const state = usePaintEditorState(controller);
|
|
969
|
+
const [error, attempt] = useAttempt();
|
|
970
|
+
const { cultures, brush } = state;
|
|
971
|
+
const activeId = state.document.activeLayerId;
|
|
972
|
+
const activeColony = cultures.layers.find((l) => l.layerId === activeId) ?? cultures.layers[0] ?? null;
|
|
973
|
+
const totalTips = cultures.layers.reduce((acc, l) => acc + l.tips, 0);
|
|
974
|
+
const totalSegments = cultures.layers.reduce((acc, l) => acc + l.segments, 0);
|
|
975
|
+
const canCarryCulture = ["dab", "mixer", "impasto", "particle", "bristle"].includes(brush.engine);
|
|
976
|
+
return /* @__PURE__ */ jsxs7("div", { className: `${panel} ${className ?? ""}`, "data-testid": "culture-panel", children: [
|
|
977
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
|
|
978
|
+
/* @__PURE__ */ jsx8("span", { className: "font-medium text-slate-300", children: "Biopaint (mycelial ink)" }),
|
|
979
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex gap-1", children: [
|
|
980
|
+
/* @__PURE__ */ jsx8("button", { type: "button", className: button, onClick: () => attempt(() => controller.growCultures({ steps: 40 })), children: "Grow" }),
|
|
981
|
+
/* @__PURE__ */ jsx8(
|
|
982
|
+
"button",
|
|
983
|
+
{
|
|
984
|
+
type: "button",
|
|
985
|
+
"aria-pressed": cultures.paused,
|
|
986
|
+
className: chip(cultures.paused),
|
|
987
|
+
onClick: () => controller.setCulturePaused(!cultures.paused),
|
|
988
|
+
children: cultures.paused ? "Paused" : "Pause"
|
|
989
|
+
}
|
|
990
|
+
),
|
|
991
|
+
/* @__PURE__ */ jsx8(
|
|
992
|
+
"button",
|
|
993
|
+
{
|
|
994
|
+
type: "button",
|
|
995
|
+
className: button,
|
|
996
|
+
disabled: !activeColony || activeColony.tips === 0,
|
|
997
|
+
onClick: () => attempt(() => controller.removeCultures(activeColony?.layerId)),
|
|
998
|
+
children: "Kill colony"
|
|
999
|
+
}
|
|
1000
|
+
)
|
|
1001
|
+
] })
|
|
1002
|
+
] }),
|
|
1003
|
+
/* @__PURE__ */ jsx8("div", { className: "flex items-center justify-between text-[11px] text-slate-400", children: /* @__PURE__ */ jsx8("span", { children: activeColony ? `${totalTips} living tips \xB7 ${totalSegments} segments (${activeColony.status})` : "No mycelial colony on canvas" }) }),
|
|
1004
|
+
/* @__PURE__ */ jsxs7("label", { className: "flex items-center gap-2 text-[11px]", children: [
|
|
1005
|
+
/* @__PURE__ */ jsx8(
|
|
1006
|
+
"input",
|
|
1007
|
+
{
|
|
1008
|
+
type: "checkbox",
|
|
1009
|
+
checked: cultures.growWhileClosed,
|
|
1010
|
+
onChange: (e) => attempt(() => controller.setCultureOptions({ growWhileClosed: e.target.checked }))
|
|
1011
|
+
}
|
|
1012
|
+
),
|
|
1013
|
+
"Grow while closed"
|
|
1014
|
+
] }),
|
|
1015
|
+
canCarryCulture && /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 border-t border-slate-800 pt-1.5", children: [
|
|
1016
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
|
|
1017
|
+
/* @__PURE__ */ jsx8("span", { className: "text-[11px] text-slate-400", children: "Brush spores" }),
|
|
1018
|
+
/* @__PURE__ */ jsx8(
|
|
1019
|
+
"button",
|
|
1020
|
+
{
|
|
1021
|
+
type: "button",
|
|
1022
|
+
"aria-pressed": Boolean(brush.culture),
|
|
1023
|
+
className: chip(Boolean(brush.culture)),
|
|
1024
|
+
onClick: () => attempt(() => controller.setBrush({ culture: brush.culture ? null : {} })),
|
|
1025
|
+
children: brush.culture ? "On" : "Off"
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
] }),
|
|
1029
|
+
brush.culture && CULTURE_SLIDERS.map((c) => {
|
|
1030
|
+
const key = c.path.replace(/^culture\./, "");
|
|
1031
|
+
return /* @__PURE__ */ jsx8(
|
|
1032
|
+
PaintSlider,
|
|
1033
|
+
{
|
|
1034
|
+
control: c,
|
|
1035
|
+
value: readPath3(brush.culture, key),
|
|
1036
|
+
onCommit: (v) => attempt(() => controller.setBrush({ culture: { [key]: v } }))
|
|
1037
|
+
},
|
|
1038
|
+
c.path
|
|
1039
|
+
);
|
|
1040
|
+
})
|
|
1041
|
+
] }),
|
|
1042
|
+
/* @__PURE__ */ jsx8(ErrorLine, { error })
|
|
1043
|
+
] });
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
// src/paint-editor/PaperPanel.tsx
|
|
1047
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
959
1048
|
var SWATCH = { x: 0, y: 0, width: 64, height: 40 };
|
|
960
1049
|
var PaperPanel = ({ controller, className }) => {
|
|
961
1050
|
const state = usePaintEditorState(controller);
|
|
@@ -964,10 +1053,10 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
964
1053
|
useEffect4(() => tiltFollow ? startDeviceTilt2(controller) : void 0, [controller, tiltFollow]);
|
|
965
1054
|
const paper = state.document.paper;
|
|
966
1055
|
const previews = useMemo5(() => new Map(PAPER_LIBRARY.map((p) => [p.preset, { ...SWATCH, data: renderPaper({ ...p, shading: Math.max(0.8, p.shading) }, SWATCH) }])), []);
|
|
967
|
-
return /* @__PURE__ */
|
|
968
|
-
PAPER_FAMILIES.map((family) => /* @__PURE__ */
|
|
969
|
-
/* @__PURE__ */
|
|
970
|
-
/* @__PURE__ */
|
|
1056
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paper-panel", children: [
|
|
1057
|
+
PAPER_FAMILIES.map((family) => /* @__PURE__ */ jsxs8("div", { children: [
|
|
1058
|
+
/* @__PURE__ */ jsx9("div", { className: "mb-0.5 text-[10px] uppercase tracking-wide text-slate-500", children: family }),
|
|
1059
|
+
/* @__PURE__ */ jsx9("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": `${family} papers`, children: PAPER_LIBRARY.filter((p) => p.family === family).map((p) => /* @__PURE__ */ jsx9(
|
|
971
1060
|
"button",
|
|
972
1061
|
{
|
|
973
1062
|
type: "button",
|
|
@@ -976,32 +1065,32 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
976
1065
|
title: p.name,
|
|
977
1066
|
className: `rounded p-0.5 ${paper.preset === p.preset ? "ring-2 ring-indigo-500" : "ring-1 ring-slate-700 hover:ring-slate-500"}`,
|
|
978
1067
|
onClick: () => attempt(() => controller.setPaper({ preset: p.preset })),
|
|
979
|
-
children: /* @__PURE__ */
|
|
1068
|
+
children: /* @__PURE__ */ jsx9(PixelCanvas, { pixels: previews.get(p.preset) ?? null, label: p.name, style: { width: 48, height: 30 } })
|
|
980
1069
|
},
|
|
981
1070
|
p.preset
|
|
982
1071
|
)) })
|
|
983
1072
|
] }, family)),
|
|
984
|
-
/* @__PURE__ */
|
|
985
|
-
/* @__PURE__ */
|
|
986
|
-
/* @__PURE__ */
|
|
987
|
-
/* @__PURE__ */
|
|
1073
|
+
/* @__PURE__ */ jsx9("div", { className: "text-slate-300", children: paper.name }),
|
|
1074
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Colour" }),
|
|
1076
|
+
/* @__PURE__ */ jsx9(CommitColorInput, { label: "Paper colour", value: paper.color, onCommit: (v) => attempt(() => controller.setPaper({ color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
988
1077
|
] }),
|
|
989
|
-
PAPER_SLIDERS.map((c) => /* @__PURE__ */
|
|
990
|
-
/* @__PURE__ */
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
1078
|
+
PAPER_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath4(paper, c.path), onCommit: (v) => attempt(() => controller.setPaper(patchPath(paper, c.path, v))) }, c.path)),
|
|
1079
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center justify-between", children: [
|
|
1080
|
+
/* @__PURE__ */ jsx9("span", { className: "text-slate-400", children: "Backlight colour" }),
|
|
1081
|
+
/* @__PURE__ */ jsx9(CommitColorInput, { label: "Backlight colour", value: paper.backlightColor ?? DEFAULT_BACKLIGHT_COLOR, onCommit: (v) => attempt(() => controller.setPaper({ backlightColor: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
993
1082
|
] }),
|
|
994
|
-
/* @__PURE__ */
|
|
995
|
-
/* @__PURE__ */
|
|
1083
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1084
|
+
/* @__PURE__ */ jsx9("input", { type: "checkbox", checked: paper.tiling === "mirror", onChange: (e) => attempt(() => controller.setPaper({ tiling: e.target.checked ? "mirror" : "repeat" })) }),
|
|
996
1085
|
" Mirror tiling"
|
|
997
1086
|
] }),
|
|
998
|
-
/* @__PURE__ */
|
|
999
|
-
/* @__PURE__ */
|
|
1000
|
-
/* @__PURE__ */
|
|
1001
|
-
LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1002
|
-
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */
|
|
1004
|
-
/* @__PURE__ */
|
|
1087
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.setPaper({ seed: paper.seed + 1 })), children: "New sheet" }),
|
|
1088
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "light-panel", children: [
|
|
1089
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "Light (thick paint, iridescence, metallic paper)" }),
|
|
1090
|
+
LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath4(controller.getLighting(), c.path), onChange: (v) => attempt(() => controller.setLighting({ [c.path]: v })) }, c.path)),
|
|
1091
|
+
VIEW_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath4(state.viewTilt, c.path), onChange: (v) => attempt(() => controller.setViewTilt({ [c.path]: v })) }, c.path)),
|
|
1092
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1093
|
+
/* @__PURE__ */ jsx9(
|
|
1005
1094
|
"button",
|
|
1006
1095
|
{
|
|
1007
1096
|
type: "button",
|
|
@@ -1014,28 +1103,29 @@ var PaperPanel = ({ controller, className }) => {
|
|
|
1014
1103
|
children: "Device tilt"
|
|
1015
1104
|
}
|
|
1016
1105
|
),
|
|
1017
|
-
/* @__PURE__ */
|
|
1106
|
+
/* @__PURE__ */ jsx9("button", { type: "button", className: "self-start px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700", onClick: () => attempt(() => controller.flattenRelief()), children: "Flatten relief" })
|
|
1018
1107
|
] })
|
|
1019
1108
|
] }),
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
/* @__PURE__ */
|
|
1022
|
-
/* @__PURE__ */
|
|
1023
|
-
/* @__PURE__ */
|
|
1109
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-1.5", "data-testid": "uv-heat-panel", children: [
|
|
1110
|
+
/* @__PURE__ */ jsx9("span", { className: "font-medium text-slate-300", children: "UV blacklight & heat" }),
|
|
1111
|
+
/* @__PURE__ */ jsxs8("label", { className: "flex items-center gap-2", children: [
|
|
1112
|
+
/* @__PURE__ */ jsx9("input", { type: "checkbox", checked: state.uvLight.on, onChange: (e) => attempt(() => controller.setUvLight({ on: e.target.checked })) }),
|
|
1024
1113
|
" UV blacklight"
|
|
1025
1114
|
] }),
|
|
1026
|
-
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1027
|
-
/* @__PURE__ */
|
|
1028
|
-
/* @__PURE__ */
|
|
1029
|
-
/* @__PURE__ */
|
|
1030
|
-
state.heat.hotCells > 0 && /* @__PURE__ */
|
|
1115
|
+
UV_LIGHT_SLIDERS.map((c) => /* @__PURE__ */ jsx9(PaintSlider, { control: c, value: readPath4(state.uvLight, c.path), onChange: (v) => attempt(() => controller.setUvLight({ [c.path]: v })) }, c.path)),
|
|
1116
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-1.5", children: [
|
|
1117
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1118
|
+
/* @__PURE__ */ jsx9("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" }),
|
|
1119
|
+
state.heat.hotCells > 0 && /* @__PURE__ */ jsxs8("span", { className: "text-[11px] text-amber-400", children: [
|
|
1031
1120
|
Math.round(state.heat.max * 100),
|
|
1032
1121
|
"% warm"
|
|
1033
1122
|
] })
|
|
1034
1123
|
] })
|
|
1035
1124
|
] }),
|
|
1036
|
-
/* @__PURE__ */
|
|
1037
|
-
/* @__PURE__ */
|
|
1038
|
-
/* @__PURE__ */
|
|
1125
|
+
/* @__PURE__ */ jsx9(FerroPanel, { controller }),
|
|
1126
|
+
/* @__PURE__ */ jsx9(TimeMachinePanel, { controller }),
|
|
1127
|
+
/* @__PURE__ */ jsx9(CulturePanel, { controller }),
|
|
1128
|
+
/* @__PURE__ */ jsx9(ErrorLine, { error })
|
|
1039
1129
|
] });
|
|
1040
1130
|
};
|
|
1041
1131
|
|
|
@@ -1057,7 +1147,7 @@ import {
|
|
|
1057
1147
|
wheelPoint
|
|
1058
1148
|
} from "@pixerate/editor/paint-editor";
|
|
1059
1149
|
import { DEFAULT_PAINT_GRADIENT as DEFAULT_PAINT_GRADIENT2, paintSourceCss } from "@pixerate/editor/paint-editor";
|
|
1060
|
-
import { jsx as
|
|
1150
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1061
1151
|
var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className }) => {
|
|
1062
1152
|
const state = usePaintEditorState(controller);
|
|
1063
1153
|
const [error, attempt] = useAttempt();
|
|
@@ -1086,9 +1176,9 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1086
1176
|
const y = Math.min(MIXING_PAD_HEIGHT, Math.max(0, (e.clientY - rect.top) * ky));
|
|
1087
1177
|
return e.pointerType === "pen" && e.pressure > 0 ? { x, y, pressure: e.pressure } : { x, y };
|
|
1088
1178
|
};
|
|
1089
|
-
return /* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
/* @__PURE__ */
|
|
1179
|
+
return /* @__PURE__ */ jsxs9("div", { className: `${panel} ${className ?? ""}`, "data-testid": "color-panel", children: [
|
|
1180
|
+
/* @__PURE__ */ jsxs9("div", { className: "relative self-center", style: { width: wheelSize, height: wheelSize }, children: [
|
|
1181
|
+
/* @__PURE__ */ jsx10(
|
|
1092
1182
|
"div",
|
|
1093
1183
|
{
|
|
1094
1184
|
role: "slider",
|
|
@@ -1102,20 +1192,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1102
1192
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
1103
1193
|
controller.setColor(wheelPick(e.clientX - rect.left - R, e.clientY - rect.top - R, wheel, color));
|
|
1104
1194
|
},
|
|
1105
|
-
children: /* @__PURE__ */
|
|
1195
|
+
children: /* @__PURE__ */ jsx10(PixelCanvas, { pixels: ring, label: "Colour wheel", style: { width: wheelSize, height: wheelSize } })
|
|
1106
1196
|
}
|
|
1107
1197
|
),
|
|
1108
|
-
/* @__PURE__ */
|
|
1198
|
+
/* @__PURE__ */ jsx10("svg", { className: "pointer-events-none absolute inset-0", width: wheelSize, height: wheelSize, "aria-hidden": "true", children: harmony.map((h, i) => {
|
|
1109
1199
|
const p = wheelPoint(h.angle, mid);
|
|
1110
|
-
return /* @__PURE__ */
|
|
1200
|
+
return /* @__PURE__ */ jsx10("circle", { cx: R + p.x, cy: R + p.y, r: i === 0 ? 7 : 5, fill: h.color, stroke: "#fff", strokeWidth: i === 0 ? 2 : 1 }, i);
|
|
1111
1201
|
}) }),
|
|
1112
|
-
/* @__PURE__ */
|
|
1202
|
+
/* @__PURE__ */ jsx10("div", { className: "absolute rounded-full border border-slate-700", style: { left: R - R * 0.45, top: R - R * 0.45, width: R * 0.9, height: R * 0.9, background: color } })
|
|
1113
1203
|
] }),
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1116
|
-
/* @__PURE__ */
|
|
1117
|
-
/* @__PURE__ */
|
|
1118
|
-
/* @__PURE__ */
|
|
1204
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
|
|
1205
|
+
/* @__PURE__ */ jsx10("input", { type: "color", "aria-label": "Paint colour", value: color, onChange: (e) => controller.setColor(e.target.value), className: "h-7 w-9 rounded bg-transparent" }),
|
|
1206
|
+
/* @__PURE__ */ jsx10("input", { type: "color", "aria-label": "Second colour", value: state.secondaryColor, onChange: (e) => controller.setSecondaryColor(e.target.value), className: "h-5 w-7 rounded bg-transparent" }),
|
|
1207
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, title: "Swap colours (X)", onClick: () => controller.swapColors(), children: "Swap" }),
|
|
1208
|
+
/* @__PURE__ */ jsx10(
|
|
1119
1209
|
"input",
|
|
1120
1210
|
{
|
|
1121
1211
|
"aria-label": "Hex colour",
|
|
@@ -1126,8 +1216,8 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1126
1216
|
color
|
|
1127
1217
|
)
|
|
1128
1218
|
] }),
|
|
1129
|
-
/* @__PURE__ */
|
|
1130
|
-
/* @__PURE__ */
|
|
1219
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", "data-testid": "paint-source", children: [
|
|
1220
|
+
/* @__PURE__ */ jsx10(
|
|
1131
1221
|
"span",
|
|
1132
1222
|
{
|
|
1133
1223
|
className: "h-5 flex-1 rounded ring-1 ring-slate-700",
|
|
@@ -1137,7 +1227,7 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1137
1227
|
style: { background: effectWell ? `center / cover no-repeat url("${effectWell}")` : paintSourceCss(state.paint, { paint: color, secondary: state.secondaryColor }) }
|
|
1138
1228
|
}
|
|
1139
1229
|
),
|
|
1140
|
-
/* @__PURE__ */
|
|
1230
|
+
/* @__PURE__ */ jsx10(
|
|
1141
1231
|
"button",
|
|
1142
1232
|
{
|
|
1143
1233
|
type: "button",
|
|
@@ -1149,26 +1239,26 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1149
1239
|
}
|
|
1150
1240
|
)
|
|
1151
1241
|
] }),
|
|
1152
|
-
state.paint.type === "gradient" && /* @__PURE__ */
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
/* @__PURE__ */
|
|
1155
|
-
/* @__PURE__ */
|
|
1242
|
+
state.paint.type === "gradient" && /* @__PURE__ */ jsx10(PaintGradientEditor, { value: state.paint, colors: { paint: color, secondary: state.secondaryColor }, onChange: (g2) => attempt(() => controller.setPaint(g2)) }),
|
|
1243
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
1244
|
+
/* @__PURE__ */ jsx10("span", { className: "w-16 text-slate-400", children: "Saturation" }),
|
|
1245
|
+
/* @__PURE__ */ jsx10("input", { type: "range", "aria-label": "Saturation", min: 0, max: 1, step: 0.01, value: hsv.s, onChange: (e) => setHsv(Number(e.target.value), hsv.v), className: "flex-1 accent-indigo-500" })
|
|
1156
1246
|
] }),
|
|
1157
|
-
/* @__PURE__ */
|
|
1158
|
-
/* @__PURE__ */
|
|
1159
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-2", children: [
|
|
1248
|
+
/* @__PURE__ */ jsx10("span", { className: "w-16 text-slate-400", children: "Value" }),
|
|
1249
|
+
/* @__PURE__ */ jsx10("input", { type: "range", "aria-label": "Value", min: 0, max: 1, step: 0.01, value: hsv.v, onChange: (e) => setHsv(hsv.s, Number(e.target.value)), className: "flex-1 accent-indigo-500" })
|
|
1160
1250
|
] }),
|
|
1161
|
-
/* @__PURE__ */
|
|
1162
|
-
/* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */
|
|
1164
|
-
/* @__PURE__ */
|
|
1251
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1", children: [
|
|
1252
|
+
/* @__PURE__ */ jsx10("select", { "aria-label": "Harmony", value: kind, onChange: (e) => setKind(e.target.value), className: "rounded bg-slate-800 px-1 py-0.5", children: HARMONY_KINDS.map((k) => /* @__PURE__ */ jsx10("option", { value: k, children: k }, k)) }),
|
|
1253
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wheel === "ryb"), "aria-pressed": wheel === "ryb", onClick: () => setWheel("ryb"), children: "RYB" }),
|
|
1254
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: chip(wheel === "rgb"), "aria-pressed": wheel === "rgb", onClick: () => setWheel("rgb"), children: "RGB" })
|
|
1165
1255
|
] }),
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
harmony.map((h, i) => /* @__PURE__ */
|
|
1168
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", "aria-label": "Harmony colours", children: [
|
|
1257
|
+
harmony.map((h, i) => /* @__PURE__ */ jsx10("button", { type: "button", "aria-label": `Use ${h.color}`, title: h.color, className: "h-6 w-6 rounded ring-1 ring-slate-700", style: { background: h.color }, onClick: () => controller.setColor(h.color) }, i)),
|
|
1258
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => harmony.forEach((h) => controller.addSwatch(h.color)), children: "+ swatches" })
|
|
1169
1259
|
] }),
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
state.swatches.map((s, i) => /* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap gap-1", role: "listbox", "aria-label": "Swatches", children: [
|
|
1261
|
+
state.swatches.map((s, i) => /* @__PURE__ */ jsx10(
|
|
1172
1262
|
"button",
|
|
1173
1263
|
{
|
|
1174
1264
|
type: "button",
|
|
@@ -1186,15 +1276,15 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1186
1276
|
},
|
|
1187
1277
|
i
|
|
1188
1278
|
)),
|
|
1189
|
-
/* @__PURE__ */
|
|
1279
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, "aria-label": "Add swatch", onClick: () => attempt(() => controller.addSwatch(state.paint)), children: "+" })
|
|
1190
1280
|
] }),
|
|
1191
|
-
mixingPad && /* @__PURE__ */
|
|
1192
|
-
/* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */
|
|
1194
|
-
["paint", "knife", "pick"].map((t) => /* @__PURE__ */
|
|
1195
|
-
/* @__PURE__ */
|
|
1281
|
+
mixingPad && /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-1", "data-testid": "mixing-pad", children: [
|
|
1282
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1", children: [
|
|
1283
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Mixing pad" }),
|
|
1284
|
+
["paint", "knife", "pick"].map((t) => /* @__PURE__ */ jsx10("button", { type: "button", "aria-pressed": padTool === t, className: chip(padTool === t), onClick: () => setPadTool(t), children: t === "paint" ? "Paint" : t === "knife" ? "Knife" : "Pick" }, t)),
|
|
1285
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => controller.clearMixingPad(), children: "Clear" })
|
|
1196
1286
|
] }),
|
|
1197
|
-
/* @__PURE__ */
|
|
1287
|
+
/* @__PURE__ */ jsx10(
|
|
1198
1288
|
"div",
|
|
1199
1289
|
{
|
|
1200
1290
|
role: "application",
|
|
@@ -1215,20 +1305,20 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1215
1305
|
padPoints.current = null;
|
|
1216
1306
|
if (pts?.length) attempt(() => controller.mixingPadStroke(pts, { tool: padTool === "knife" ? "knife" : "paint" }));
|
|
1217
1307
|
},
|
|
1218
|
-
children: /* @__PURE__ */
|
|
1308
|
+
children: /* @__PURE__ */ jsx10(PixelCanvas, { pixels: pad, label: "Mixing pad pixels", className: "w-full rounded", style: { aspectRatio: `${MIXING_PAD_WIDTH} / ${MIXING_PAD_HEIGHT}` } })
|
|
1219
1309
|
}
|
|
1220
1310
|
),
|
|
1221
|
-
/* @__PURE__ */
|
|
1222
|
-
/* @__PURE__ */
|
|
1223
|
-
/* @__PURE__ */
|
|
1311
|
+
/* @__PURE__ */ jsx10("div", { className: "flex flex-wrap items-center gap-1", children: /* @__PURE__ */ jsxs9("label", { className: "flex items-center gap-1", children: [
|
|
1312
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-400", children: "Sample" }),
|
|
1313
|
+
/* @__PURE__ */ jsx10("select", { "aria-label": "Pick sample size", value: sample, onChange: (e) => setSample(Number(e.target.value)), className: "rounded bg-slate-800 px-1 py-0.5", children: PAD_SAMPLE_SIZES.map((n) => /* @__PURE__ */ jsx10("option", { value: n, children: n === 1 ? "1 px" : `${n}\xD7${n}` }, n)) })
|
|
1224
1314
|
] }) }),
|
|
1225
|
-
/* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
/* @__PURE__ */
|
|
1228
|
-
/* @__PURE__ */
|
|
1229
|
-
/* @__PURE__ */
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1315
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1316
|
+
/* @__PURE__ */ jsx10("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: color } }),
|
|
1317
|
+
/* @__PURE__ */ jsx10("input", { type: "number", "aria-label": "Paint colour parts", min: 0, max: 20, value: parts[0], onChange: (e) => setParts([Number(e.target.value), parts[1]]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
1318
|
+
/* @__PURE__ */ jsx10("span", { className: "text-slate-500", children: ":" }),
|
|
1319
|
+
/* @__PURE__ */ jsx10("input", { type: "number", "aria-label": "Second colour parts", min: 0, max: 20, value: parts[1], onChange: (e) => setParts([parts[0], Number(e.target.value)]), className: "w-10 rounded bg-slate-800 px-1 py-0.5" }),
|
|
1320
|
+
/* @__PURE__ */ jsx10("span", { className: "h-4 w-4 rounded ring-1 ring-slate-700", style: { background: state.secondaryColor } }),
|
|
1321
|
+
/* @__PURE__ */ jsx10(
|
|
1232
1322
|
"button",
|
|
1233
1323
|
{
|
|
1234
1324
|
type: "button",
|
|
@@ -1247,23 +1337,23 @@ var ColorPanel = ({ controller, wheelSize = 168, mixingPad = true, className })
|
|
|
1247
1337
|
}
|
|
1248
1338
|
)
|
|
1249
1339
|
] }),
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
/* @__PURE__ */
|
|
1340
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
1341
|
+
/* @__PURE__ */ jsx10("input", { value: padName, placeholder: "Pad name", "aria-label": "Pad name", onChange: (e) => setPadName(e.target.value), className: "w-24 rounded bg-slate-800 px-1.5 py-0.5" }),
|
|
1342
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, onClick: () => attempt(() => (controller.saveMixingPad(padName || void 0), setPadName(""))), children: "Keep pad" })
|
|
1253
1343
|
] }),
|
|
1254
|
-
state.savedMixingPads.length > 0 && /* @__PURE__ */
|
|
1255
|
-
/* @__PURE__ */
|
|
1256
|
-
/* @__PURE__ */
|
|
1344
|
+
state.savedMixingPads.length > 0 && /* @__PURE__ */ jsx10("ul", { className: "flex flex-col gap-0.5", "aria-label": "Kept pads", children: state.savedMixingPads.map((p) => /* @__PURE__ */ jsxs9("li", { className: "flex items-center gap-1", children: [
|
|
1345
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: `${button} flex-1 text-left`, onClick: () => attempt(() => controller.loadMixingPad(p.id)), children: p.name }),
|
|
1346
|
+
/* @__PURE__ */ jsx10("button", { type: "button", className: button, "aria-label": `Remove ${p.name}`, onClick: () => attempt(() => controller.removeMixingPad(p.id)), children: "\xD7" })
|
|
1257
1347
|
] }, p.id)) })
|
|
1258
1348
|
] }),
|
|
1259
|
-
/* @__PURE__ */
|
|
1349
|
+
/* @__PURE__ */ jsx10(ErrorLine, { error })
|
|
1260
1350
|
] });
|
|
1261
1351
|
};
|
|
1262
1352
|
|
|
1263
1353
|
// src/paint-editor/PaintLayersPanel.tsx
|
|
1264
1354
|
import { useState as useState7 } from "react";
|
|
1265
1355
|
import { BLEND_MENU_GROUPS } from "@pixerate/editor/paint-editor";
|
|
1266
|
-
import { jsx as
|
|
1356
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1267
1357
|
function siblingIndex(layers, l) {
|
|
1268
1358
|
const sibs = layers.filter((x) => x.parentId === l.parentId).reverse();
|
|
1269
1359
|
return { index: sibs.findIndex((x) => x.id === l.id), count: sibs.length };
|
|
@@ -1281,18 +1371,18 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1281
1371
|
const to = Math.min(count - 1, Math.max(0, index + delta));
|
|
1282
1372
|
if (to !== index) attempt(() => controller.moveLayer(active.id, to));
|
|
1283
1373
|
};
|
|
1284
|
-
return /* @__PURE__ */
|
|
1285
|
-
/* @__PURE__ */
|
|
1286
|
-
/* @__PURE__ */
|
|
1287
|
-
/* @__PURE__ */
|
|
1288
|
-
/* @__PURE__ */
|
|
1289
|
-
/* @__PURE__ */
|
|
1290
|
-
/* @__PURE__ */
|
|
1291
|
-
/* @__PURE__ */
|
|
1292
|
-
/* @__PURE__ */
|
|
1293
|
-
/* @__PURE__ */
|
|
1374
|
+
return /* @__PURE__ */ jsxs10("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-layers-panel", children: [
|
|
1375
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex flex-wrap gap-1", children: [
|
|
1376
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer()), children: "New layer" }),
|
|
1377
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.addLayer({ type: "group" })), children: "New group" }),
|
|
1378
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, title: "A layer whose strokes stay editable", onClick: () => attempt(() => controller.addLayer({ type: "strokes" })), children: "New stroke layer" }),
|
|
1379
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.duplicateLayer(active.id)), children: "Duplicate" }),
|
|
1380
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer up", onClick: () => move(1), children: "\u2191" }),
|
|
1381
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, "aria-label": "Move layer down", onClick: () => move(-1), children: "\u2193" }),
|
|
1382
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active, onClick: () => active && attempt(() => controller.mergeDown(active.id)), children: "Merge down" }),
|
|
1383
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, disabled: !active || layers.length < 2, onClick: () => active && attempt(() => controller.removeLayer(active.id)), children: "Delete" })
|
|
1294
1384
|
] }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1385
|
+
/* @__PURE__ */ jsx11("ul", { role: "tree", "aria-label": "Layers", className: "flex flex-col gap-0.5", children: layers.map((l) => /* @__PURE__ */ jsxs10(
|
|
1296
1386
|
"li",
|
|
1297
1387
|
{
|
|
1298
1388
|
role: "treeitem",
|
|
@@ -1301,7 +1391,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1301
1391
|
style: { paddingLeft: 6 + l.depth * 12 },
|
|
1302
1392
|
onClick: () => controller.setActiveLayer(l.id),
|
|
1303
1393
|
children: [
|
|
1304
|
-
/* @__PURE__ */
|
|
1394
|
+
/* @__PURE__ */ jsx11(
|
|
1305
1395
|
"button",
|
|
1306
1396
|
{
|
|
1307
1397
|
type: "button",
|
|
@@ -1314,7 +1404,7 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1314
1404
|
children: l.visible ? "\u25CF" : "\u25CB"
|
|
1315
1405
|
}
|
|
1316
1406
|
),
|
|
1317
|
-
renaming === l.id ? /* @__PURE__ */
|
|
1407
|
+
renaming === l.id ? /* @__PURE__ */ jsx11(
|
|
1318
1408
|
"input",
|
|
1319
1409
|
{
|
|
1320
1410
|
autoFocus: true,
|
|
@@ -1331,23 +1421,23 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1331
1421
|
if (e.key === "Escape") setRenaming(null);
|
|
1332
1422
|
}
|
|
1333
1423
|
}
|
|
1334
|
-
) : /* @__PURE__ */
|
|
1424
|
+
) : /* @__PURE__ */ jsxs10("span", { className: "flex-1 truncate", onDoubleClick: () => setRenaming(l.id), children: [
|
|
1335
1425
|
l.type === "group" ? "\u25B8 " : "",
|
|
1336
|
-
l.liveStrokes !== void 0 && /* @__PURE__ */
|
|
1426
|
+
l.liveStrokes !== void 0 && /* @__PURE__ */ jsxs10("span", { "aria-label": "Stroke layer", title: `Stroke layer: ${l.liveStrokes} editable strokes`, children: [
|
|
1337
1427
|
"\u270E",
|
|
1338
1428
|
" "
|
|
1339
1429
|
] }),
|
|
1340
1430
|
l.name
|
|
1341
1431
|
] }),
|
|
1342
|
-
l.locks.pixels || l.locks.all ? /* @__PURE__ */
|
|
1432
|
+
l.locks.pixels || l.locks.all ? /* @__PURE__ */ jsx11("span", { title: "Locked", children: "\u{1F512}" }) : null
|
|
1343
1433
|
]
|
|
1344
1434
|
},
|
|
1345
1435
|
l.id
|
|
1346
1436
|
)) }),
|
|
1347
|
-
active && /* @__PURE__ */
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
/* @__PURE__ */
|
|
1350
|
-
/* @__PURE__ */
|
|
1437
|
+
active && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5", children: [
|
|
1438
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1439
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Opacity" }),
|
|
1440
|
+
/* @__PURE__ */ jsx11(
|
|
1351
1441
|
"input",
|
|
1352
1442
|
{
|
|
1353
1443
|
type: "range",
|
|
@@ -1361,40 +1451,40 @@ var PaintLayersPanel = ({ controller, className }) => {
|
|
|
1361
1451
|
}
|
|
1362
1452
|
)
|
|
1363
1453
|
] }),
|
|
1364
|
-
/* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */
|
|
1366
|
-
/* @__PURE__ */
|
|
1367
|
-
active.type === "group" && /* @__PURE__ */
|
|
1368
|
-
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */
|
|
1454
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1455
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Blend" }),
|
|
1456
|
+
/* @__PURE__ */ jsxs10("select", { "aria-label": "Layer blend", value: active.blend, onChange: (e) => attempt(() => controller.updateLayer(active.id, { blend: e.target.value })), className: "flex-1 rounded bg-slate-800 px-1 py-0.5", children: [
|
|
1457
|
+
active.type === "group" && /* @__PURE__ */ jsx11("option", { value: "pass-through", children: "Pass through" }),
|
|
1458
|
+
BLEND_MENU_GROUPS.map((g) => /* @__PURE__ */ jsx11("optgroup", { label: g.label, children: g.modes.map((m) => /* @__PURE__ */ jsx11("option", { value: m.id, title: m.description, children: m.label }, m.id)) }, g.label))
|
|
1369
1459
|
] })
|
|
1370
1460
|
] }),
|
|
1371
|
-
/* @__PURE__ */
|
|
1372
|
-
["pixels", "transparency"].map((k) => /* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1461
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex gap-1", children: [
|
|
1462
|
+
["pixels", "transparency"].map((k) => /* @__PURE__ */ jsx11("button", { type: "button", "aria-pressed": Boolean(active.locks[k]), className: chip(Boolean(active.locks[k])), onClick: () => attempt(() => controller.updateLayer(active.id, { locks: { [k]: !active.locks[k] } })), children: k === "pixels" ? "Lock pixels" : "Lock transparency" }, k)),
|
|
1463
|
+
/* @__PURE__ */ jsx11("button", { type: "button", "aria-pressed": active.clipped, className: chip(active.clipped), onClick: () => attempt(() => controller.updateLayer(active.id, { clipped: !active.clipped })), children: "Clip" })
|
|
1374
1464
|
] }),
|
|
1375
|
-
light?.hasLight && /* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
/* @__PURE__ */
|
|
1378
|
-
/* @__PURE__ */
|
|
1465
|
+
light?.hasLight && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-1.5 border-t border-slate-800 pt-1.5", "data-testid": "layer-light", children: [
|
|
1466
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-between", children: [
|
|
1467
|
+
/* @__PURE__ */ jsx11("span", { className: "font-medium text-slate-300", title: "This layer's paint gives off light", children: "Light" }),
|
|
1468
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: button, onClick: () => attempt(() => controller.clearLight(active.id)), children: "Clear light" })
|
|
1379
1469
|
] }),
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
/* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1470
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", title: "How far the light spills onto the paint and paper around it (0 turns it off)", children: [
|
|
1471
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Spill" }),
|
|
1472
|
+
/* @__PURE__ */ jsx11("input", { type: "range", "aria-label": "Light spill radius", min: 0, max: 120, step: 1, value: light.spill.radius, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { radius: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1383
1473
|
] }),
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1386
|
-
/* @__PURE__ */
|
|
1474
|
+
/* @__PURE__ */ jsxs10("label", { className: "flex items-center gap-2", children: [
|
|
1475
|
+
/* @__PURE__ */ jsx11("span", { className: "w-14 text-slate-400", children: "Strength" }),
|
|
1476
|
+
/* @__PURE__ */ jsx11("input", { type: "range", "aria-label": "Light spill strength", min: 0, max: 2, step: 0.05, value: light.spill.strength, onChange: (e) => attempt(() => controller.setLightSpill(active.id, { strength: Number(e.target.value) })), className: "flex-1 accent-indigo-500" })
|
|
1387
1477
|
] })
|
|
1388
1478
|
] }),
|
|
1389
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ jsx11("div", { className: "border-t border-slate-800 pt-1.5", "data-testid": "paint-layer-effects", title: "Live layer styles drawn from this layer's paint: glows, shadows, strokes", children: /* @__PURE__ */ jsx11(LayerEffectsPanel, { controller, layerId: active.id }) })
|
|
1390
1480
|
] }),
|
|
1391
|
-
/* @__PURE__ */
|
|
1481
|
+
/* @__PURE__ */ jsx11(ErrorLine, { error })
|
|
1392
1482
|
] });
|
|
1393
1483
|
};
|
|
1394
1484
|
|
|
1395
1485
|
// src/paint-editor/WetPanel.tsx
|
|
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
|
|
1397
|
-
import { jsx as
|
|
1486
|
+
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 readPath5, wetEngineSummary } from "@pixerate/editor/paint-editor";
|
|
1487
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1398
1488
|
var FLOW_LABELS = { none: "None", linear: "One way", swirl: "Swirl", radial: "Outwards", turbulent: "Eddies" };
|
|
1399
1489
|
var WetPanel = ({ controller, className }) => {
|
|
1400
1490
|
const state = usePaintEditorState(controller);
|
|
@@ -1404,31 +1494,31 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1404
1494
|
const info = layerId ? controller.wetLayerInfo(layerId) : null;
|
|
1405
1495
|
const livePattern = layerId ? controller.getLivePatterns(layerId).layers[0] ?? null : null;
|
|
1406
1496
|
const backend = controller.wetState();
|
|
1407
|
-
return /* @__PURE__ */
|
|
1408
|
-
/* @__PURE__ */
|
|
1409
|
-
/* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1497
|
+
return /* @__PURE__ */ jsxs11("div", { className: `${panel} ${className ?? ""}`, "data-testid": "wet-panel", children: [
|
|
1498
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
|
|
1499
|
+
/* @__PURE__ */ jsx12("span", { className: wet.wet ? "text-sky-300" : "text-slate-400", "data-testid": "wet-status", children: wet.wet ? wet.paused ? "Wet (paused)" : "Wet" : "Dry" }),
|
|
1500
|
+
/* @__PURE__ */ jsxs11("span", { className: "text-[10px] text-slate-500", children: [
|
|
1411
1501
|
"step ",
|
|
1412
1502
|
wet.clock
|
|
1413
1503
|
] })
|
|
1414
1504
|
] }),
|
|
1415
|
-
/* @__PURE__ */
|
|
1416
|
-
/* @__PURE__ */
|
|
1417
|
-
/* @__PURE__ */
|
|
1418
|
-
/* @__PURE__ */
|
|
1419
|
-
/* @__PURE__ */
|
|
1420
|
-
/* @__PURE__ */
|
|
1505
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-wrap gap-1", children: [
|
|
1506
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !wet.layerIds.length, onClick: () => attempt(async () => (await controller.wetIdle(), controller.dryPaint())), children: "Dry now" }),
|
|
1507
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: chip(wet.paused), "aria-pressed": wet.paused, onClick: () => controller.setWetPaused(!wet.paused), children: wet.paused ? "Resume" : "Pause" }),
|
|
1508
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: chip(wet.overlay), "aria-pressed": wet.overlay, onClick: () => controller.setWaterOverlay(!wet.overlay), children: "Water" }),
|
|
1509
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: chip(wet.instantDry), "aria-pressed": wet.instantDry, title: "Each wet stroke dries as soon as it ends", onClick: () => controller.setInstantDry(!wet.instantDry), children: "Instant dry" }),
|
|
1510
|
+
/* @__PURE__ */ jsx12("button", { type: "button", className: button, disabled: !layerId, onClick: () => attempt(async () => (await controller.wetIdle(), controller.wetPaper({}))), children: "Wet paper" })
|
|
1421
1511
|
] }),
|
|
1422
|
-
/* @__PURE__ */
|
|
1423
|
-
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */
|
|
1424
|
-
info && /* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1428
|
-
/* @__PURE__ */
|
|
1429
|
-
/* @__PURE__ */
|
|
1512
|
+
/* @__PURE__ */ jsx12(PaintSlider, { control: WET_SPEED_SLIDER, value: wet.speed, onChange: (v) => controller.setWetSpeed(v) }),
|
|
1513
|
+
WET_TILT_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath5(wet.tilt, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setCanvasTilt({ [c.path]: v }))) }, c.path)),
|
|
1514
|
+
info && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-layer", children: [
|
|
1515
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "This layer" }),
|
|
1516
|
+
WET_PARAM_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath5(info.params, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setWetParams(layerId, { [c.path]: v }))) }, c.path)),
|
|
1517
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1518
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Flow map" }),
|
|
1519
|
+
/* @__PURE__ */ jsx12("select", { "aria-label": "Flow map", value: info.flow.kind, onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setFlowMap(layerId, { kind: e.target.value }))), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_FLOW_KINDS.map((k) => /* @__PURE__ */ jsx12("option", { value: k, children: FLOW_LABELS[k] }, k)) })
|
|
1430
1520
|
] }),
|
|
1431
|
-
info.flow.kind !== "none" && /* @__PURE__ */
|
|
1521
|
+
info.flow.kind !== "none" && /* @__PURE__ */ jsx12(
|
|
1432
1522
|
PaintSlider,
|
|
1433
1523
|
{
|
|
1434
1524
|
control: { path: "strength", label: "Flow strength", min: 0, max: 1, step: 0.01 },
|
|
@@ -1437,10 +1527,10 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1437
1527
|
}
|
|
1438
1528
|
)
|
|
1439
1529
|
] }),
|
|
1440
|
-
livePattern && layerId && /* @__PURE__ */
|
|
1441
|
-
/* @__PURE__ */
|
|
1442
|
-
/* @__PURE__ */
|
|
1443
|
-
/* @__PURE__ */
|
|
1530
|
+
livePattern && layerId && /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", "data-testid": "wet-live-patterns", children: [
|
|
1531
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between", children: [
|
|
1532
|
+
/* @__PURE__ */ jsx12("span", { className: "font-medium text-slate-300", children: "Live patterns" }),
|
|
1533
|
+
/* @__PURE__ */ jsx12(
|
|
1444
1534
|
"button",
|
|
1445
1535
|
{
|
|
1446
1536
|
type: "button",
|
|
@@ -1455,35 +1545,35 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1455
1545
|
}
|
|
1456
1546
|
)
|
|
1457
1547
|
] }),
|
|
1458
|
-
/* @__PURE__ */
|
|
1459
|
-
/* @__PURE__ */
|
|
1460
|
-
/* @__PURE__ */
|
|
1548
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1549
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Pattern" }),
|
|
1550
|
+
/* @__PURE__ */ jsx12(
|
|
1461
1551
|
"select",
|
|
1462
1552
|
{
|
|
1463
1553
|
"aria-label": "Live pattern",
|
|
1464
1554
|
value: livePattern.settings.pattern,
|
|
1465
1555
|
onChange: (e) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { pattern: e.target.value }))),
|
|
1466
1556
|
className: "rounded bg-slate-800 px-1 py-0.5",
|
|
1467
|
-
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */
|
|
1557
|
+
children: LIVE_PATTERN_KINDS.map((k) => /* @__PURE__ */ jsx12("option", { value: k, children: LIVE_PATTERN_LABELS[k] }, k))
|
|
1468
1558
|
}
|
|
1469
1559
|
)
|
|
1470
1560
|
] }),
|
|
1471
|
-
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */
|
|
1561
|
+
LIVE_PATTERN_SLIDERS.map((c) => /* @__PURE__ */ jsx12(PaintSlider, { control: c, value: readPath5(livePattern.settings, c.path), onCommit: (v) => attempt(async () => (await controller.wetIdle(), controller.setLivePatterns(layerId, { [c.path]: v }))) }, c.path))
|
|
1472
1562
|
] }),
|
|
1473
|
-
backend.message && /* @__PURE__ */
|
|
1474
|
-
backend.backend && /* @__PURE__ */
|
|
1475
|
-
/* @__PURE__ */
|
|
1476
|
-
/* @__PURE__ */
|
|
1477
|
-
/* @__PURE__ */
|
|
1563
|
+
backend.message && /* @__PURE__ */ jsx12("p", { className: "text-[10px] text-amber-300", "data-testid": "wet-message", children: backend.message }),
|
|
1564
|
+
backend.backend && /* @__PURE__ */ jsx12("p", { className: "text-[10px] text-slate-500", children: backend.backend.kind === "wasm-threads" ? `WebAssembly, ${backend.backend.threads} threads` : backend.backend.kind === "wasm" ? "WebAssembly, one thread" : "JavaScript" }),
|
|
1565
|
+
/* @__PURE__ */ jsxs11("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1566
|
+
/* @__PURE__ */ jsx12("span", { className: "text-slate-400", children: "Engine" }),
|
|
1567
|
+
/* @__PURE__ */ jsx12("select", { "aria-label": "Wet engine", value: wet.gpu, onChange: (e) => attempt(() => controller.setWetEngine({ gpu: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: WET_GPU_OPTIONS.map((o) => /* @__PURE__ */ jsx12("option", { value: o.value, children: o.label }, o.value)) })
|
|
1478
1568
|
] }),
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
/* @__PURE__ */
|
|
1569
|
+
/* @__PURE__ */ jsx12("p", { className: `text-[10px] ${backend.engine.state === "active" ? "text-emerald-300" : "text-slate-500"}`, "data-testid": "wet-engine", children: wetEngineSummary(backend.engine) }),
|
|
1570
|
+
/* @__PURE__ */ jsx12(ErrorLine, { error })
|
|
1481
1571
|
] });
|
|
1482
1572
|
};
|
|
1483
1573
|
|
|
1484
1574
|
// src/paint-editor/StickerPanel.tsx
|
|
1485
|
-
import { STICKER_SLIDERS, readPath as
|
|
1486
|
-
import { jsx as
|
|
1575
|
+
import { STICKER_SLIDERS, readPath as readPath6, stickerRefLabel } from "@pixerate/editor/paint-editor";
|
|
1576
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1487
1577
|
var StickerPanel = ({ controller, className }) => {
|
|
1488
1578
|
const state = usePaintEditorState(controller);
|
|
1489
1579
|
const [error, attempt] = useAttempt();
|
|
@@ -1493,16 +1583,16 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1493
1583
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1494
1584
|
if (!stickers.length) return null;
|
|
1495
1585
|
const sel = stickers.find((s) => s.id === picked) ?? null;
|
|
1496
|
-
return /* @__PURE__ */
|
|
1497
|
-
/* @__PURE__ */
|
|
1586
|
+
return /* @__PURE__ */ jsxs12("div", { className: `${panel} ${className ?? ""}`, "data-testid": "sticker-panel", children: [
|
|
1587
|
+
/* @__PURE__ */ jsxs12("span", { className: "font-medium text-slate-300", children: [
|
|
1498
1588
|
"Stickers (",
|
|
1499
1589
|
stickers.length,
|
|
1500
1590
|
")"
|
|
1501
1591
|
] }),
|
|
1502
|
-
/* @__PURE__ */
|
|
1503
|
-
sel && /* @__PURE__ */
|
|
1504
|
-
/* @__PURE__ */
|
|
1505
|
-
/* @__PURE__ */
|
|
1592
|
+
/* @__PURE__ */ jsx13("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Stickers", children: stickers.map((s) => /* @__PURE__ */ jsx13("button", { type: "button", role: "option", "aria-selected": s.id === picked, title: `${stickerRefLabel(s.ref)} ${s.id}`, className: `h-5 w-5 rounded ring-1 ${s.id === picked ? "ring-indigo-400" : "ring-slate-700"}`, style: { background: s.color }, onClick: () => setPicked(s.id) }, s.id)) }),
|
|
1593
|
+
sel && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-1.5", "data-testid": "sticker-edit", children: [
|
|
1594
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Sticker" }),
|
|
1595
|
+
/* @__PURE__ */ jsx13(
|
|
1506
1596
|
StickerPicker,
|
|
1507
1597
|
{
|
|
1508
1598
|
controller,
|
|
@@ -1516,9 +1606,9 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1516
1606
|
)
|
|
1517
1607
|
}
|
|
1518
1608
|
),
|
|
1519
|
-
/* @__PURE__ */
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
1609
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1610
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Position" }),
|
|
1611
|
+
/* @__PURE__ */ jsx13("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ jsx13(
|
|
1522
1612
|
"input",
|
|
1523
1613
|
{
|
|
1524
1614
|
type: "number",
|
|
@@ -1532,24 +1622,24 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1532
1622
|
`${sel.id}-${k}-${sel[k]}`
|
|
1533
1623
|
)) })
|
|
1534
1624
|
] }),
|
|
1535
|
-
STICKER_SLIDERS.map((c) => /* @__PURE__ */
|
|
1536
|
-
/* @__PURE__ */
|
|
1537
|
-
/* @__PURE__ */
|
|
1538
|
-
/* @__PURE__ */
|
|
1625
|
+
STICKER_SLIDERS.map((c) => /* @__PURE__ */ jsx13(PaintSlider, { control: c, value: readPath6(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1626
|
+
/* @__PURE__ */ jsxs12("label", { className: "flex items-center justify-between", children: [
|
|
1627
|
+
/* @__PURE__ */ jsx13("span", { className: "text-slate-400", children: "Colour" }),
|
|
1628
|
+
/* @__PURE__ */ jsx13(CommitColorInput, { label: "Sticker colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1539
1629
|
] }),
|
|
1540
|
-
/* @__PURE__ */
|
|
1541
|
-
/* @__PURE__ */
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
/* @__PURE__ */
|
|
1630
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-1", children: [
|
|
1631
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "front")), children: "To front" }),
|
|
1632
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => controller.arrangeStickers(layerId, [sel.id], "back")), children: "To back" }),
|
|
1633
|
+
/* @__PURE__ */ jsx13("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStickers(layerId, [sel.id]), setPicked(null))), children: "Delete" })
|
|
1544
1634
|
] })
|
|
1545
1635
|
] }),
|
|
1546
|
-
/* @__PURE__ */
|
|
1636
|
+
/* @__PURE__ */ jsx13(ErrorLine, { error })
|
|
1547
1637
|
] });
|
|
1548
1638
|
};
|
|
1549
1639
|
|
|
1550
1640
|
// src/paint-editor/StrokePanel.tsx
|
|
1551
|
-
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as
|
|
1552
|
-
import { jsx as
|
|
1641
|
+
import { STROKE_SLIDERS, liveStrokeRefusal, readPath as readPath7 } from "@pixerate/editor/paint-editor";
|
|
1642
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1553
1643
|
var StrokePanel = ({ controller, className }) => {
|
|
1554
1644
|
const state = usePaintEditorState(controller);
|
|
1555
1645
|
const [error, attempt] = useAttempt();
|
|
@@ -1559,16 +1649,16 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1559
1649
|
const index = strokes.findIndex((s) => s.id === state.selectedStroke);
|
|
1560
1650
|
const sel = index >= 0 ? strokes[index] : null;
|
|
1561
1651
|
const brushes = state.brushes.filter((b) => !liveStrokeRefusal(b));
|
|
1562
|
-
return /* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
/* @__PURE__ */
|
|
1652
|
+
return /* @__PURE__ */ jsxs13("div", { className: `${panel} ${className ?? ""}`, "data-testid": "stroke-panel", children: [
|
|
1653
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center justify-between", children: [
|
|
1654
|
+
/* @__PURE__ */ jsxs13("span", { className: "font-medium text-slate-300", children: [
|
|
1565
1655
|
"Strokes (",
|
|
1566
1656
|
strokes.length,
|
|
1567
1657
|
")"
|
|
1568
1658
|
] }),
|
|
1569
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => controller.rasterizeLiveStrokes(layerId)), children: "Rasterize" })
|
|
1570
1660
|
] }),
|
|
1571
|
-
/* @__PURE__ */
|
|
1661
|
+
/* @__PURE__ */ jsx14("div", { className: "flex max-h-24 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Strokes", children: strokes.map((s, i) => /* @__PURE__ */ jsx14(
|
|
1572
1662
|
"button",
|
|
1573
1663
|
{
|
|
1574
1664
|
type: "button",
|
|
@@ -1581,10 +1671,10 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1581
1671
|
},
|
|
1582
1672
|
s.id
|
|
1583
1673
|
)) }),
|
|
1584
|
-
sel && /* @__PURE__ */
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1674
|
+
sel && /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1.5", "data-testid": "stroke-edit", children: [
|
|
1675
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center justify-between gap-2", children: [
|
|
1676
|
+
/* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Brush" }),
|
|
1677
|
+
/* @__PURE__ */ jsxs13(
|
|
1588
1678
|
"select",
|
|
1589
1679
|
{
|
|
1590
1680
|
"aria-label": "Stroke brush",
|
|
@@ -1592,41 +1682,41 @@ var StrokePanel = ({ controller, className }) => {
|
|
|
1592
1682
|
onChange: (e) => e.target.value && attempt(() => controller.updateStroke(sel.id, { brushId: e.target.value })),
|
|
1593
1683
|
className: "max-w-[10rem] rounded bg-slate-800 px-1 py-0.5",
|
|
1594
1684
|
children: [
|
|
1595
|
-
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */
|
|
1596
|
-
brushes.map((b) => /* @__PURE__ */
|
|
1685
|
+
!brushes.some((b) => b.id === sel.brush.id) && /* @__PURE__ */ jsx14("option", { value: "", children: sel.brush.name }),
|
|
1686
|
+
brushes.map((b) => /* @__PURE__ */ jsx14("option", { value: b.id, children: b.name }, b.id))
|
|
1597
1687
|
]
|
|
1598
1688
|
}
|
|
1599
1689
|
)
|
|
1600
1690
|
] }),
|
|
1601
|
-
STROKE_SLIDERS.map((c) => /* @__PURE__ */
|
|
1602
|
-
/* @__PURE__ */
|
|
1603
|
-
/* @__PURE__ */
|
|
1604
|
-
/* @__PURE__ */
|
|
1691
|
+
STROKE_SLIDERS.map((c) => /* @__PURE__ */ jsx14(PaintSlider, { control: c, value: readPath7(sel.brush, c.path), onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { brush: { tip: { [c.path.split(".")[1]]: v } } })) }, c.path)),
|
|
1692
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center justify-between", children: [
|
|
1693
|
+
/* @__PURE__ */ jsx14("span", { className: "text-slate-400", children: "Colour" }),
|
|
1694
|
+
/* @__PURE__ */ jsx14(CommitColorInput, { label: "Stroke colour", value: sel.color, onCommit: (v) => attempt(() => controller.updateStroke(sel.id, { color: v })), className: "h-6 w-10 rounded bg-transparent" })
|
|
1605
1695
|
] }),
|
|
1606
|
-
/* @__PURE__ */
|
|
1607
|
-
/* @__PURE__ */
|
|
1608
|
-
/* @__PURE__ */
|
|
1609
|
-
/* @__PURE__ */
|
|
1610
|
-
/* @__PURE__ */
|
|
1696
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-wrap gap-1", children: [
|
|
1697
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => controller.updateStroke(sel.id, { seed: (sel.seed + 1) % 2147483647 })), children: "New seed" }),
|
|
1698
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: index === strokes.length - 1, "aria-label": "Move stroke up", onClick: () => attempt(() => controller.reorderStroke(sel.id, index + 1)), children: "\u2191" }),
|
|
1699
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, disabled: index === 0, "aria-label": "Move stroke down", onClick: () => attempt(() => controller.reorderStroke(sel.id, index - 1)), children: "\u2193" }),
|
|
1700
|
+
/* @__PURE__ */ jsx14("button", { type: "button", className: button, onClick: () => attempt(() => (controller.removeStrokes([sel.id]), controller.selectStroke(null))), children: "Delete" })
|
|
1611
1701
|
] })
|
|
1612
1702
|
] }),
|
|
1613
|
-
/* @__PURE__ */
|
|
1703
|
+
/* @__PURE__ */ jsx14(ErrorLine, { error })
|
|
1614
1704
|
] });
|
|
1615
1705
|
};
|
|
1616
1706
|
|
|
1617
1707
|
// src/paint-editor/PathStrokePanel.tsx
|
|
1618
1708
|
import { useState as useState8 } from "react";
|
|
1619
1709
|
import { PATH_STROKE_TAPERS } from "@pixerate/editor/paint-editor";
|
|
1620
|
-
import { jsx as
|
|
1710
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1621
1711
|
var PathStrokePanel = ({ controller, className }) => {
|
|
1622
1712
|
const state = usePaintEditorState(controller);
|
|
1623
1713
|
const [error, attempt] = useAttempt();
|
|
1624
1714
|
const [path, setPath] = useState8("");
|
|
1625
1715
|
const [taper, setTaper] = useState8(PATH_STROKE_TAPERS[0].id);
|
|
1626
1716
|
const pressure = PATH_STROKE_TAPERS.find((t) => t.id === taper)?.pressure;
|
|
1627
|
-
return /* @__PURE__ */
|
|
1628
|
-
/* @__PURE__ */
|
|
1629
|
-
/* @__PURE__ */
|
|
1717
|
+
return /* @__PURE__ */ jsxs14("div", { className: `${panel} ${className ?? ""}`, "data-testid": "path-stroke-panel", children: [
|
|
1718
|
+
/* @__PURE__ */ jsx15("span", { className: "font-medium text-slate-300", children: "Brush a path" }),
|
|
1719
|
+
/* @__PURE__ */ jsx15(
|
|
1630
1720
|
"textarea",
|
|
1631
1721
|
{
|
|
1632
1722
|
"aria-label": "SVG path data",
|
|
@@ -1637,11 +1727,11 @@ var PathStrokePanel = ({ controller, className }) => {
|
|
|
1637
1727
|
className: "w-full resize-y rounded bg-slate-800 px-1 py-0.5 font-mono text-[11px]"
|
|
1638
1728
|
}
|
|
1639
1729
|
),
|
|
1640
|
-
/* @__PURE__ */
|
|
1641
|
-
/* @__PURE__ */
|
|
1642
|
-
/* @__PURE__ */
|
|
1730
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-2", children: [
|
|
1731
|
+
/* @__PURE__ */ jsx15("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__ */ jsx15("option", { value: t.id, children: t.label }, t.id)) }),
|
|
1732
|
+
/* @__PURE__ */ jsx15("button", { type: "button", className: button, disabled: !path.trim() || state.stroking, onClick: () => attempt(() => controller.strokePath({ path, ...pressure ? { pressure } : {} })), children: "Brush path" })
|
|
1643
1733
|
] }),
|
|
1644
|
-
/* @__PURE__ */
|
|
1734
|
+
/* @__PURE__ */ jsx15(ErrorLine, { error })
|
|
1645
1735
|
] });
|
|
1646
1736
|
};
|
|
1647
1737
|
|
|
@@ -1655,7 +1745,7 @@ import {
|
|
|
1655
1745
|
paintProposalGhost as paintProposalGhost2,
|
|
1656
1746
|
proposalGenomeStrokes
|
|
1657
1747
|
} from "@pixerate/editor/paint-editor";
|
|
1658
|
-
import { jsx as
|
|
1748
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1659
1749
|
var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
1660
1750
|
const state = usePaintEditorState(controller);
|
|
1661
1751
|
const store = proposals ?? controller.proposals;
|
|
@@ -1678,16 +1768,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1678
1768
|
const toggleProposal = (id) => {
|
|
1679
1769
|
setSelectedProposals((prev) => prev.includes(id) ? prev.filter((x) => x !== id) : [...prev.slice(-1), id]);
|
|
1680
1770
|
};
|
|
1681
|
-
return /* @__PURE__ */
|
|
1682
|
-
/* @__PURE__ */
|
|
1683
|
-
/* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ jsxs15("div", { className: `${panel} ${className ?? ""}`, "data-testid": "evolution-panel", children: [
|
|
1772
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center justify-between", children: [
|
|
1773
|
+
/* @__PURE__ */ jsxs15("span", { className: "font-medium text-slate-300", children: [
|
|
1684
1774
|
"Evolution (",
|
|
1685
1775
|
eligibleStrokes.length,
|
|
1686
1776
|
")"
|
|
1687
1777
|
] }),
|
|
1688
|
-
/* @__PURE__ */
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
1778
|
+
/* @__PURE__ */ jsx16("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs15("label", { className: "flex items-center gap-1 text-[11px] text-slate-400", children: [
|
|
1779
|
+
/* @__PURE__ */ jsx16("span", { children: "Count" }),
|
|
1780
|
+
/* @__PURE__ */ jsx16(
|
|
1691
1781
|
"input",
|
|
1692
1782
|
{
|
|
1693
1783
|
type: "number",
|
|
@@ -1701,9 +1791,9 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1701
1791
|
)
|
|
1702
1792
|
] }) })
|
|
1703
1793
|
] }),
|
|
1704
|
-
eligibleStrokes.length > 0 && /* @__PURE__ */
|
|
1794
|
+
eligibleStrokes.length > 0 && /* @__PURE__ */ jsx16("div", { className: "flex max-h-20 flex-wrap gap-1 overflow-y-auto", role: "listbox", "aria-label": "Parent strokes", children: eligibleStrokes.map((s, i) => {
|
|
1705
1795
|
const on = effectiveStrokeIds.includes(s.id);
|
|
1706
|
-
return /* @__PURE__ */
|
|
1796
|
+
return /* @__PURE__ */ jsx16(
|
|
1707
1797
|
"button",
|
|
1708
1798
|
{
|
|
1709
1799
|
type: "button",
|
|
@@ -1719,7 +1809,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1719
1809
|
}) }),
|
|
1720
1810
|
EVOLUTION_SLIDERS.map((c) => {
|
|
1721
1811
|
const key = c.path;
|
|
1722
|
-
return /* @__PURE__ */
|
|
1812
|
+
return /* @__PURE__ */ jsx16(
|
|
1723
1813
|
PaintSlider,
|
|
1724
1814
|
{
|
|
1725
1815
|
control: c,
|
|
@@ -1729,8 +1819,8 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1729
1819
|
c.path
|
|
1730
1820
|
);
|
|
1731
1821
|
}),
|
|
1732
|
-
/* @__PURE__ */
|
|
1733
|
-
/* @__PURE__ */
|
|
1822
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap gap-1", children: [
|
|
1823
|
+
/* @__PURE__ */ jsx16(
|
|
1734
1824
|
"button",
|
|
1735
1825
|
{
|
|
1736
1826
|
type: "button",
|
|
@@ -1743,7 +1833,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1743
1833
|
children: "Breed strokes"
|
|
1744
1834
|
}
|
|
1745
1835
|
),
|
|
1746
|
-
activeProposalIds.length === 2 && /* @__PURE__ */
|
|
1836
|
+
activeProposalIds.length === 2 && /* @__PURE__ */ jsx16(
|
|
1747
1837
|
"button",
|
|
1748
1838
|
{
|
|
1749
1839
|
type: "button",
|
|
@@ -1756,7 +1846,7 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1756
1846
|
children: "Cross over (2)"
|
|
1757
1847
|
}
|
|
1758
1848
|
),
|
|
1759
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1849
|
+
variants.length > 0 && /* @__PURE__ */ jsx16(
|
|
1760
1850
|
"button",
|
|
1761
1851
|
{
|
|
1762
1852
|
type: "button",
|
|
@@ -1769,16 +1859,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1769
1859
|
}
|
|
1770
1860
|
)
|
|
1771
1861
|
] }),
|
|
1772
|
-
variants.length > 0 && /* @__PURE__ */
|
|
1862
|
+
variants.length > 0 && /* @__PURE__ */ jsx16("div", { className: "grid grid-cols-2 gap-1.5", "data-testid": "evolution-grid", children: variants.map((p) => {
|
|
1773
1863
|
const g = paintProposalGhost2(p);
|
|
1774
1864
|
const picked = activeProposalIds.includes(p.id);
|
|
1775
|
-
return /* @__PURE__ */
|
|
1865
|
+
return /* @__PURE__ */ jsxs15(
|
|
1776
1866
|
"div",
|
|
1777
1867
|
{
|
|
1778
1868
|
"data-testid": `evolution-variant-${p.id}`,
|
|
1779
1869
|
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"}`,
|
|
1780
1870
|
children: [
|
|
1781
|
-
/* @__PURE__ */
|
|
1871
|
+
/* @__PURE__ */ jsx16("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsx16(
|
|
1782
1872
|
"button",
|
|
1783
1873
|
{
|
|
1784
1874
|
type: "button",
|
|
@@ -1788,10 +1878,10 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1788
1878
|
children: p.title
|
|
1789
1879
|
}
|
|
1790
1880
|
) }),
|
|
1791
|
-
g && /* @__PURE__ */
|
|
1792
|
-
p.rationale && /* @__PURE__ */
|
|
1793
|
-
/* @__PURE__ */
|
|
1794
|
-
/* @__PURE__ */
|
|
1881
|
+
g && /* @__PURE__ */ jsx16("div", { className: "flex h-16 items-center justify-center overflow-hidden rounded bg-slate-900/80 p-1", children: /* @__PURE__ */ jsx16(PixelCanvas, { pixels: g, label: p.title, className: "max-h-full max-w-full object-contain" }) }),
|
|
1882
|
+
p.rationale && /* @__PURE__ */ jsx16("span", { className: "line-clamp-2 text-[10px] text-slate-400", title: p.rationale, children: p.rationale }),
|
|
1883
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-wrap gap-1", children: [
|
|
1884
|
+
/* @__PURE__ */ jsx16(
|
|
1795
1885
|
"button",
|
|
1796
1886
|
{
|
|
1797
1887
|
type: "button",
|
|
@@ -1804,16 +1894,16 @@ var EvolutionPanel = ({ controller, proposals, className }) => {
|
|
|
1804
1894
|
children: "Breed from"
|
|
1805
1895
|
}
|
|
1806
1896
|
),
|
|
1807
|
-
/* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */
|
|
1897
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, onClick: () => attempt(() => store.accept(p.id)), children: "Accept" }),
|
|
1898
|
+
/* @__PURE__ */ jsx16("button", { type: "button", className: button, onClick: () => attempt(() => store.reject(p.id)), children: "Dismiss" })
|
|
1809
1899
|
] })
|
|
1810
1900
|
]
|
|
1811
1901
|
},
|
|
1812
1902
|
p.id
|
|
1813
1903
|
);
|
|
1814
1904
|
}) }),
|
|
1815
|
-
contactSheetUrl && /* @__PURE__ */
|
|
1816
|
-
/* @__PURE__ */
|
|
1905
|
+
contactSheetUrl && /* @__PURE__ */ jsx16("img", { src: contactSheetUrl, alt: "Variant contact sheet", className: "w-full rounded border border-slate-800", "data-testid": "evolution-contact-sheet" }),
|
|
1906
|
+
/* @__PURE__ */ jsx16(ErrorLine, { error })
|
|
1817
1907
|
] });
|
|
1818
1908
|
};
|
|
1819
1909
|
|
|
@@ -1825,7 +1915,7 @@ import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2,
|
|
|
1825
1915
|
import { useEffect as useEffect5, useMemo as useMemo7, useRef as useRef6, useState as useState10 } from "react";
|
|
1826
1916
|
import { createPaintEffectsToolProvider, PAPER_EFFECT_BLENDS } from "@pixerate/editor/paint-editor";
|
|
1827
1917
|
import { pathControlsOf } from "@pixerate/editor/effects";
|
|
1828
|
-
import { jsx as
|
|
1918
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1829
1919
|
function usePaintEffectsProvider(controller) {
|
|
1830
1920
|
const [provider, setProvider] = useState10(controller.effectsProvider);
|
|
1831
1921
|
useEffect5(() => {
|
|
@@ -1844,19 +1934,19 @@ function usePaintEffectsTools(registry, controller, options = {}) {
|
|
|
1844
1934
|
function Controls({ provider, effect, name, values, apply }) {
|
|
1845
1935
|
const { description, error } = useEffectDescription(provider, effect);
|
|
1846
1936
|
const drags = useRef6(/* @__PURE__ */ new Set());
|
|
1847
|
-
if (!provider) return /* @__PURE__ */
|
|
1937
|
+
if (!provider) return /* @__PURE__ */ jsxs16("p", { className: "text-[11px] text-slate-400", children: [
|
|
1848
1938
|
'No effects provider: "',
|
|
1849
1939
|
name ?? effect,
|
|
1850
1940
|
'" is kept as it was drawn.'
|
|
1851
1941
|
] });
|
|
1852
|
-
if (error) return /* @__PURE__ */
|
|
1853
|
-
if (!description) return /* @__PURE__ */
|
|
1942
|
+
if (error) return /* @__PURE__ */ jsx17("p", { className: "text-[11px] text-amber-400", children: error });
|
|
1943
|
+
if (!description) return /* @__PURE__ */ jsx17("p", { className: "text-[11px] text-slate-400", children: "Loading\u2026" });
|
|
1854
1944
|
const commit = (gesture) => {
|
|
1855
1945
|
if (!gesture || drags.current.has(gesture)) return !gesture;
|
|
1856
1946
|
drags.current.add(gesture);
|
|
1857
1947
|
return true;
|
|
1858
1948
|
};
|
|
1859
|
-
return /* @__PURE__ */
|
|
1949
|
+
return /* @__PURE__ */ jsx17(
|
|
1860
1950
|
EffectParameters,
|
|
1861
1951
|
{
|
|
1862
1952
|
description,
|
|
@@ -1909,28 +1999,28 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1909
1999
|
};
|
|
1910
2000
|
const toggle = (b) => setBrowse(browse === b ? null : b);
|
|
1911
2001
|
const pixel = active?.type === "pixel";
|
|
1912
|
-
return /* @__PURE__ */
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
/* @__PURE__ */
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
1917
|
-
/* @__PURE__ */
|
|
1918
|
-
/* @__PURE__ */
|
|
1919
|
-
/* @__PURE__ */
|
|
2002
|
+
return /* @__PURE__ */ jsxs16("div", { className: `${panel} ${className ?? ""}`, "data-testid": "paint-effects-panel", "aria-busy": busy, children: [
|
|
2003
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
2004
|
+
/* @__PURE__ */ jsx17("span", { className: "flex-1 font-medium text-slate-300", children: "Effects" }),
|
|
2005
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "paper", onClick: () => toggle("paper"), children: "Paper\u2026" }),
|
|
2006
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, disabled: !provider, "aria-pressed": browse === "layer", onClick: () => toggle("layer"), children: "Layer\u2026" }),
|
|
2007
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, disabled: !provider || !pixel, "aria-pressed": browse === "fill", onClick: () => toggle("fill"), children: "Fill\u2026" }),
|
|
2008
|
+
/* @__PURE__ */ jsx17("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" }),
|
|
2009
|
+
/* @__PURE__ */ jsx17("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" })
|
|
1920
2010
|
] }),
|
|
1921
|
-
!provider && /* @__PURE__ */
|
|
1922
|
-
browse && /* @__PURE__ */
|
|
1923
|
-
paper && /* @__PURE__ */
|
|
1924
|
-
/* @__PURE__ */
|
|
1925
|
-
/* @__PURE__ */
|
|
2011
|
+
!provider && /* @__PURE__ */ jsx17("p", { className: "text-[11px] text-slate-400", children: "No effects provider is registered. Effects in the painting are kept." }),
|
|
2012
|
+
browse && /* @__PURE__ */ jsx17(EffectsBrowser, { provider, uses: BROWSERS[browse].uses, title: BROWSERS[browse].title, onPick: (e) => pick(e.id) }),
|
|
2013
|
+
paper && /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paper", children: [
|
|
2014
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1", children: [
|
|
2015
|
+
/* @__PURE__ */ jsxs16("span", { className: "flex-1 truncate", children: [
|
|
1926
2016
|
"Paper: ",
|
|
1927
2017
|
paper.name ?? paper.effect
|
|
1928
2018
|
] }),
|
|
1929
|
-
/* @__PURE__ */
|
|
2019
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, "aria-label": "Remove the effect paper", onClick: () => run(() => controller.setPaperEffect(null)), children: "\u2715" })
|
|
1930
2020
|
] }),
|
|
1931
|
-
/* @__PURE__ */
|
|
1932
|
-
/* @__PURE__ */
|
|
1933
|
-
/* @__PURE__ */
|
|
2021
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", children: [
|
|
2022
|
+
/* @__PURE__ */ jsx17("span", { className: "w-14 text-[11px] text-slate-400", children: "Opacity" }),
|
|
2023
|
+
/* @__PURE__ */ jsx17(
|
|
1934
2024
|
"input",
|
|
1935
2025
|
{
|
|
1936
2026
|
type: "range",
|
|
@@ -1952,43 +2042,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1952
2042
|
`o${paper.opacity}`
|
|
1953
2043
|
)
|
|
1954
2044
|
] }),
|
|
1955
|
-
/* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
1957
|
-
/* @__PURE__ */
|
|
2045
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", children: [
|
|
2046
|
+
/* @__PURE__ */ jsx17("span", { className: "w-14 text-[11px] text-slate-400", children: "Blend" }),
|
|
2047
|
+
/* @__PURE__ */ jsx17("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) => {
|
|
1958
2048
|
const blend = e.currentTarget.value;
|
|
1959
2049
|
run(() => controller.updatePaperEffect({ blend }));
|
|
1960
|
-
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */
|
|
2050
|
+
}, children: PAPER_EFFECT_BLENDS.map((b) => /* @__PURE__ */ jsx17("option", { value: b, children: b }, b)) })
|
|
1961
2051
|
] }),
|
|
1962
|
-
/* @__PURE__ */
|
|
2052
|
+
/* @__PURE__ */ jsx17(Controls, { provider, effect: paper.effect, name: paper.name, values: paper.values, apply: (values, commit) => run(() => controller.updatePaperEffect({ values }, commit)) })
|
|
1963
2053
|
] }),
|
|
1964
|
-
effectPaint && /* @__PURE__ */
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
thumbnail ? /* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
2054
|
+
effectPaint && /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "paint", children: [
|
|
2055
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1", children: [
|
|
2056
|
+
thumbnail ? /* @__PURE__ */ jsx17("img", { src: thumbnail, alt: "", className: "h-5 w-8 rounded object-cover ring-1 ring-slate-700", "data-testid": "effect-paint-thumbnail" }) : null,
|
|
2057
|
+
/* @__PURE__ */ jsxs16("span", { className: "flex-1 truncate", children: [
|
|
1968
2058
|
"Paint: ",
|
|
1969
2059
|
effectPaint.effect,
|
|
1970
2060
|
state.effectPaintRendering ? " (rendering\u2026)" : ""
|
|
1971
2061
|
] }),
|
|
1972
|
-
/* @__PURE__ */
|
|
2062
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, "aria-label": "Stop painting with the effect", onClick: () => attempt(() => controller.setColor(state.color)), children: "\u2715" })
|
|
1973
2063
|
] }),
|
|
1974
|
-
/* @__PURE__ */
|
|
1975
|
-
/* @__PURE__ */
|
|
1976
|
-
/* @__PURE__ */
|
|
2064
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex flex-wrap items-center gap-2", "data-testid": "effect-paint-placement", children: [
|
|
2065
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", title: "Lay the effect along each stroke instead of fixing it to the canvas", children: [
|
|
2066
|
+
/* @__PURE__ */ jsx17("input", { type: "checkbox", checked: effectPaint.map?.by === "stroke", onChange: (e) => repaint({ map: e.target.checked ? { by: "stroke", length: 300, repeat: "repeat" } : { by: "canvas" } }) }),
|
|
1977
2067
|
"Along the stroke"
|
|
1978
2068
|
] }),
|
|
1979
|
-
hasPathControl && /* @__PURE__ */
|
|
1980
|
-
/* @__PURE__ */
|
|
2069
|
+
hasPathControl && /* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", title: "Pass each stroke's centreline to the effect's own path control", children: [
|
|
2070
|
+
/* @__PURE__ */ jsx17("input", { type: "checkbox", checked: effectPaint.map?.by === "path", onChange: (e) => repaint({ map: e.target.checked ? { by: "path" } : { by: "canvas" } }) }),
|
|
1981
2071
|
"Along the stroke (native)"
|
|
1982
2072
|
] }),
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
2073
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", title: "Strokes on a stroke layer keep playing the effect", children: [
|
|
2074
|
+
/* @__PURE__ */ jsx17("input", { type: "checkbox", checked: Boolean(effectPaint.live), onChange: (e) => repaint({ live: e.target.checked }) }),
|
|
1985
2075
|
"Live"
|
|
1986
2076
|
] })
|
|
1987
2077
|
] }),
|
|
1988
|
-
effectPaint.map?.by === "stroke" && /* @__PURE__ */
|
|
1989
|
-
/* @__PURE__ */
|
|
1990
|
-
/* @__PURE__ */
|
|
1991
|
-
/* @__PURE__ */
|
|
2078
|
+
effectPaint.map?.by === "stroke" && /* @__PURE__ */ jsxs16("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
2079
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", children: [
|
|
2080
|
+
/* @__PURE__ */ jsx17("span", { className: "text-slate-400", children: "Length" }),
|
|
2081
|
+
/* @__PURE__ */ jsx17(
|
|
1992
2082
|
"input",
|
|
1993
2083
|
{
|
|
1994
2084
|
type: "number",
|
|
@@ -2002,43 +2092,43 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
2002
2092
|
effectPaint.map.length
|
|
2003
2093
|
)
|
|
2004
2094
|
] }),
|
|
2005
|
-
/* @__PURE__ */
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
/* @__PURE__ */
|
|
2008
|
-
/* @__PURE__ */
|
|
2095
|
+
/* @__PURE__ */ jsxs16("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: [
|
|
2096
|
+
/* @__PURE__ */ jsx17("option", { value: "repeat", children: "Repeat" }),
|
|
2097
|
+
/* @__PURE__ */ jsx17("option", { value: "mirror", children: "Mirror" }),
|
|
2098
|
+
/* @__PURE__ */ jsx17("option", { value: "clamp", children: "Clamp" })
|
|
2009
2099
|
] })
|
|
2010
2100
|
] }),
|
|
2011
|
-
/* @__PURE__ */
|
|
2101
|
+
/* @__PURE__ */ jsx17(Controls, { provider, effect: effectPaint.effect, values: effectPaint.values, apply: (values) => repaint({ values: { ...effectPaint.values, ...values } }) })
|
|
2012
2102
|
] }),
|
|
2013
|
-
animation && /* @__PURE__ */
|
|
2014
|
-
/* @__PURE__ */
|
|
2103
|
+
animation && /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2 rounded border border-slate-700 p-1", "data-effect-part": "playback", children: [
|
|
2104
|
+
/* @__PURE__ */ jsxs16("span", { className: "flex-1 truncate", children: [
|
|
2015
2105
|
"Live paint: ",
|
|
2016
2106
|
animation.strokes,
|
|
2017
2107
|
" ",
|
|
2018
2108
|
animation.strokes === 1 ? "stroke" : "strokes"
|
|
2019
2109
|
] }),
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
/* @__PURE__ */
|
|
2110
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, "aria-pressed": playback.playing, onClick: () => attempt(() => controller.setEffectPlayback({ playing: !playback.playing })), children: playback.playing ? "Pause" : "Play" }),
|
|
2111
|
+
/* @__PURE__ */ jsxs16("label", { className: "flex items-center gap-1", children: [
|
|
2112
|
+
/* @__PURE__ */ jsx17("span", { className: "text-slate-400", children: "fps" }),
|
|
2113
|
+
/* @__PURE__ */ jsx17("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" })
|
|
2024
2114
|
] })
|
|
2025
2115
|
] }),
|
|
2026
|
-
layerEffect && activeId && /* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2028
|
-
/* @__PURE__ */
|
|
2116
|
+
layerEffect && activeId && /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-1 rounded border border-slate-700 p-1", "data-effect-part": "layer", children: [
|
|
2117
|
+
/* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1", children: [
|
|
2118
|
+
/* @__PURE__ */ jsxs16("span", { className: "flex-1 truncate", children: [
|
|
2029
2119
|
"Layer: ",
|
|
2030
2120
|
layerEffect.name ?? layerEffect.effect
|
|
2031
2121
|
] }),
|
|
2032
|
-
/* @__PURE__ */
|
|
2122
|
+
/* @__PURE__ */ jsx17("button", { type: "button", className: button, title: "Keep the pixels as a plain layer", onClick: () => attempt(() => controller.rasterizeEffectLayer(activeId)), children: "Rasterize" })
|
|
2033
2123
|
] }),
|
|
2034
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ jsx17(Controls, { provider, effect: layerEffect.effect, name: layerEffect.name, values: layerEffect.values, apply: (values, commit) => run(() => controller.updateEffectLayer(activeId, { values }, commit)) })
|
|
2035
2125
|
] }),
|
|
2036
|
-
/* @__PURE__ */
|
|
2126
|
+
/* @__PURE__ */ jsx17(ErrorLine, { error })
|
|
2037
2127
|
] });
|
|
2038
2128
|
};
|
|
2039
2129
|
|
|
2040
2130
|
// src/paint-editor/PaintEditor.tsx
|
|
2041
|
-
import { jsx as
|
|
2131
|
+
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2042
2132
|
var PAINT_CONTROLS = {
|
|
2043
2133
|
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
2044
2134
|
lighting: '[data-testid="light-panel"]',
|
|
@@ -2110,27 +2200,27 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, proposals, ag
|
|
|
2110
2200
|
const [error, setError] = useState11(null);
|
|
2111
2201
|
const effects = usePaintEffectsProvider(controller);
|
|
2112
2202
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
2113
|
-
return /* @__PURE__ */
|
|
2114
|
-
playing && /* @__PURE__ */
|
|
2115
|
-
/* @__PURE__ */
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
/* @__PURE__ */
|
|
2118
|
-
/* @__PURE__ */
|
|
2119
|
-
/* @__PURE__ */
|
|
2120
|
-
error && /* @__PURE__ */
|
|
2203
|
+
return /* @__PURE__ */ jsxs17("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: [
|
|
2204
|
+
playing && /* @__PURE__ */ jsx18(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
2205
|
+
/* @__PURE__ */ jsx18(PaintToolbar, { controller, tool, onToolChange: setTool, fillOptions, onFillOptionsChange: setFillOptions, fileName }),
|
|
2206
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
2207
|
+
/* @__PURE__ */ jsx18(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
2208
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
2209
|
+
/* @__PURE__ */ jsx18(PaintCanvas, { controller, tool, fillOptions, onError: setError, presence: playing ? void 0 : presence, proposals, agentStrokes, deviceTilt, className: "flex-1 rounded-lg" }),
|
|
2210
|
+
error && /* @__PURE__ */ jsx18("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
2121
2211
|
] }),
|
|
2122
|
-
/* @__PURE__ */
|
|
2123
|
-
/* @__PURE__ */
|
|
2124
|
-
/* @__PURE__ */
|
|
2125
|
-
tab === "color" && /* @__PURE__ */
|
|
2126
|
-
tab === "wet" && /* @__PURE__ */
|
|
2127
|
-
tab === "paper" && /* @__PURE__ */
|
|
2128
|
-
tab === "layers" && /* @__PURE__ */
|
|
2129
|
-
tab === "layers" && /* @__PURE__ */
|
|
2130
|
-
tab === "layers" && /* @__PURE__ */
|
|
2131
|
-
tab === "layers" && /* @__PURE__ */
|
|
2132
|
-
tab === "layers" && /* @__PURE__ */
|
|
2133
|
-
tab === "effects" && effects && /* @__PURE__ */
|
|
2212
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
2213
|
+
/* @__PURE__ */ jsx18("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx18("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)) }),
|
|
2214
|
+
/* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
2215
|
+
tab === "color" && /* @__PURE__ */ jsx18(ColorPanel, { controller }),
|
|
2216
|
+
tab === "wet" && /* @__PURE__ */ jsx18(WetPanel, { controller }),
|
|
2217
|
+
tab === "paper" && /* @__PURE__ */ jsx18(PaperPanel, { controller }),
|
|
2218
|
+
tab === "layers" && /* @__PURE__ */ jsx18(PaintLayersPanel, { controller }),
|
|
2219
|
+
tab === "layers" && /* @__PURE__ */ jsx18(StrokePanel, { controller }),
|
|
2220
|
+
tab === "layers" && /* @__PURE__ */ jsx18(PathStrokePanel, { controller }),
|
|
2221
|
+
tab === "layers" && /* @__PURE__ */ jsx18(EvolutionPanel, { controller, proposals }),
|
|
2222
|
+
tab === "layers" && /* @__PURE__ */ jsx18(StickerPanel, { controller }),
|
|
2223
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx18(PaintEffectsPanel, { controller })
|
|
2134
2224
|
] })
|
|
2135
2225
|
] })
|
|
2136
2226
|
] })
|
|
@@ -2141,6 +2231,7 @@ export {
|
|
|
2141
2231
|
BrushLibraryBrowser,
|
|
2142
2232
|
BrushPanel,
|
|
2143
2233
|
ColorPanel,
|
|
2234
|
+
CulturePanel,
|
|
2144
2235
|
EvolutionPanel,
|
|
2145
2236
|
FerroPanel,
|
|
2146
2237
|
PaintCanvas,
|