Group local mask shapes into editable components.
A local adjustment is now a list of shapes composited in order (add, subtract, intersect) instead of a single shape, so dodging and burning can be built from several brushes, gradients and auto masks without spending layer channels. Existing edits migrate on load: the flat layer fields become components[0], keeping geometry, invert, feather and the layer's blend mode unchanged. The panel gains a shape list with active-shape editing, and the render gate now asserts a subtract shape clears the group while an intersect keeps it.
This commit is contained in:
+184
-70
@@ -2,8 +2,10 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
ASPECTS,
|
||||
defaultEdits,
|
||||
defaultLocalComponent,
|
||||
defaultLocalLayer,
|
||||
MAX_HEAL_SPOTS,
|
||||
MAX_LOCAL_COMPONENTS,
|
||||
MAX_LOCAL_LAYERS,
|
||||
} from '../lib/edits';
|
||||
import { subscribeClipPreview } from '../lib/clipPreview';
|
||||
@@ -35,6 +37,7 @@ import type {
|
||||
EventRecord,
|
||||
Flag,
|
||||
HealSpot,
|
||||
LocalComponent,
|
||||
LocalLayer,
|
||||
LocalMaskKind,
|
||||
LocalStroke,
|
||||
@@ -105,16 +108,21 @@ const EMPTY_GEO: Geometry = {
|
||||
function cloneLocalLayer(layer: LocalLayer): LocalLayer {
|
||||
return {
|
||||
...layer,
|
||||
brush: {
|
||||
strokes: layer.brush.strokes.map((stroke) => ({
|
||||
...stroke,
|
||||
points: stroke.points.map((point) => ({ ...point })),
|
||||
})),
|
||||
},
|
||||
linear: { ...layer.linear },
|
||||
radial: { ...layer.radial },
|
||||
components: layer.components.map((component) => ({
|
||||
...component,
|
||||
brush: {
|
||||
strokes: component.brush.strokes.map((stroke) => ({
|
||||
...stroke,
|
||||
points: stroke.points.map((point) => ({ ...point })),
|
||||
})),
|
||||
},
|
||||
linear: { ...component.linear },
|
||||
radial: { ...component.radial },
|
||||
...(component.raster ? { raster: { ...component.raster } } : {}),
|
||||
})),
|
||||
adjust: { ...layer.adjust },
|
||||
range: { ...layer.range },
|
||||
curve: layer.curve.map((point) => ({ ...point })),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -253,6 +261,7 @@ export default function Develop({
|
||||
const healDrag = useRef<{ index: number; mode: 'target' | 'source'; spot: HealSpot } | null>(null);
|
||||
|
||||
const [localSelected, setLocalSelected] = useState<string | null>(null);
|
||||
const [localComponentSelected, setLocalComponentSelected] = useState<string | null>(null);
|
||||
const [localMode, setLocalMode] = useState(false);
|
||||
const [autoMaskBusy, setAutoMaskBusy] = useState(false);
|
||||
const [localBrush, setLocalBrush] = useState(72);
|
||||
@@ -266,7 +275,8 @@ export default function Develop({
|
||||
error: null,
|
||||
});
|
||||
const localDrag = useRef<{
|
||||
id: string;
|
||||
layerId: string;
|
||||
componentId: string;
|
||||
mode: 'brush' | 'center' | 'edge' | 'edgeX' | 'edgeY' | 'start' | 'end';
|
||||
stroke: LocalStroke | null;
|
||||
} | null>(null);
|
||||
@@ -280,6 +290,10 @@ export default function Develop({
|
||||
[photos, photo.meta?.camera],
|
||||
);
|
||||
const activeLocal = (edits.local ?? []).find((layer) => layer.id === localSelected) ?? null;
|
||||
const activeComponent =
|
||||
activeLocal?.components.find((component) => component.id === localComponentSelected) ??
|
||||
activeLocal?.components[0] ??
|
||||
null;
|
||||
const zoomed = zoom.pct !== 'fit';
|
||||
|
||||
// The filmstrip has its own Lightroom-style cull filter so you can narrow the
|
||||
@@ -740,7 +754,7 @@ export default function Develop({
|
||||
if ((e.target as HTMLElement | null)?.closest('.loupe-adjust')) return;
|
||||
if (cropMode) return;
|
||||
// While painting a mask, the wheel sizes the brush instead of zooming.
|
||||
if (localMode && activeLocal?.kind === 'brush') {
|
||||
if (localMode && activeComponent?.kind === 'brush') {
|
||||
e.preventDefault();
|
||||
setLocalBrush((v) => clampNum(v * Math.exp(-e.deltaY * 0.0015), 8, 320));
|
||||
return;
|
||||
@@ -760,7 +774,7 @@ export default function Develop({
|
||||
};
|
||||
el.addEventListener('wheel', onWheel, { passive: false });
|
||||
return () => el.removeEventListener('wheel', onWheel);
|
||||
}, [cropMode, applyZoom, healMode, localMode, activeLocal]);
|
||||
}, [cropMode, applyZoom, healMode, localMode, activeComponent]);
|
||||
|
||||
const beginPan = (e: React.PointerEvent<HTMLCanvasElement>) => {
|
||||
if (picking || rangePicking || cropMode || healMode || localMode || !zoomed || e.button !== 0) return;
|
||||
@@ -1013,6 +1027,26 @@ export default function Develop({
|
||||
[commitLocal, photo.edits.local],
|
||||
);
|
||||
|
||||
/** Updates one shape inside a layer's mask group. */
|
||||
const patchComponent = useCallback(
|
||||
(layerId: string, componentId: string, patch: Partial<LocalComponent>, label = 'Local adjustment') => {
|
||||
commitLocal(
|
||||
(photo.edits.local ?? []).map((layer) =>
|
||||
layer.id === layerId
|
||||
? {
|
||||
...layer,
|
||||
components: layer.components.map((component) =>
|
||||
component.id === componentId ? { ...component, ...patch } : component,
|
||||
),
|
||||
}
|
||||
: layer,
|
||||
),
|
||||
label,
|
||||
);
|
||||
},
|
||||
[commitLocal, photo.edits.local],
|
||||
);
|
||||
|
||||
const addLocalLayer = useCallback(
|
||||
(kind: LocalMaskKind) => {
|
||||
const layers = edits.local ?? [];
|
||||
@@ -1020,6 +1054,7 @@ export default function Develop({
|
||||
const layer = defaultLocalLayer(kind, layers.length);
|
||||
commitLocal([...layers, layer], 'Add local adjustment');
|
||||
setLocalSelected(layer.id);
|
||||
setLocalComponentSelected(layer.components[0]?.id ?? null);
|
||||
setLocalMode(true);
|
||||
setCropMode(false);
|
||||
setHealMode(false);
|
||||
@@ -1037,10 +1072,14 @@ export default function Develop({
|
||||
const raster = await buildAutoMask(source, kind);
|
||||
const layer = defaultLocalLayer('raster', layers.length);
|
||||
layer.name = `Auto ${kind}`;
|
||||
layer.raster = raster;
|
||||
layer.feather = 30;
|
||||
const shape = layer.components[0];
|
||||
if (shape) {
|
||||
shape.raster = raster;
|
||||
shape.feather = 30;
|
||||
}
|
||||
commitLocal([...layers, layer], `Auto ${kind} mask`);
|
||||
setLocalSelected(layer.id);
|
||||
setLocalComponentSelected(layer.components[0]?.id ?? null);
|
||||
setLocalMode(false);
|
||||
setCropMode(false);
|
||||
setHealMode(false);
|
||||
@@ -1109,6 +1148,7 @@ export default function Develop({
|
||||
(id: string) => {
|
||||
commitLocal((edits.local ?? []).filter((layer) => layer.id !== id), 'Delete local adjustment');
|
||||
setLocalSelected(null);
|
||||
setLocalComponentSelected(null);
|
||||
setLocalMode(false);
|
||||
},
|
||||
[commitLocal, edits.local],
|
||||
@@ -1127,6 +1167,7 @@ export default function Develop({
|
||||
};
|
||||
commitLocal([...layers, copy], 'Duplicate local adjustment');
|
||||
setLocalSelected(copy.id);
|
||||
setLocalComponentSelected(copy.components[0]?.id ?? null);
|
||||
},
|
||||
[commitLocal, edits.local],
|
||||
);
|
||||
@@ -1146,11 +1187,39 @@ export default function Develop({
|
||||
};
|
||||
commitLocal([...layers, copy], 'Paste local adjustment');
|
||||
setLocalSelected(copy.id);
|
||||
setLocalComponentSelected(copy.components[0]?.id ?? null);
|
||||
setLocalMode(true);
|
||||
setCropMode(false);
|
||||
setHealMode(false);
|
||||
}, [commitLocal, edits.local, localClipboard]);
|
||||
|
||||
const addLocalComponent = useCallback(
|
||||
(kind: LocalMaskKind) => {
|
||||
if (!activeLocal) return;
|
||||
if (activeLocal.components.length >= MAX_LOCAL_COMPONENTS) return;
|
||||
const component = defaultLocalComponent(kind);
|
||||
patchLocal(activeLocal.id, { components: [...activeLocal.components, component] }, 'Add mask shape');
|
||||
setLocalComponentSelected(component.id);
|
||||
setLocalMode(true);
|
||||
setCropMode(false);
|
||||
setHealMode(false);
|
||||
setPicking(false);
|
||||
},
|
||||
[activeLocal, patchLocal],
|
||||
);
|
||||
|
||||
const deleteLocalComponent = useCallback(
|
||||
(componentId: string) => {
|
||||
// A layer is its group: removing the last shape would leave an adjustment
|
||||
// with no mask, so Delete layer is the way to remove it.
|
||||
if (!activeLocal || activeLocal.components.length <= 1) return;
|
||||
const remaining = activeLocal.components.filter((component) => component.id !== componentId);
|
||||
patchLocal(activeLocal.id, { components: remaining }, 'Delete mask shape');
|
||||
setLocalComponentSelected(remaining[0]?.id ?? null);
|
||||
},
|
||||
[activeLocal, patchLocal],
|
||||
);
|
||||
|
||||
const toggleLocalMode = useCallback(() => {
|
||||
if (!activeLocal) return;
|
||||
setLocalMode((v) => !v);
|
||||
@@ -1160,21 +1229,21 @@ export default function Develop({
|
||||
}, [activeLocal]);
|
||||
|
||||
const startLocalMask = (e: React.PointerEvent<HTMLCanvasElement>) => {
|
||||
if (!localMode || !activeLocal || !bitmap) return;
|
||||
if (!localMode || !activeLocal || !activeComponent || !bitmap) return;
|
||||
const p = sourcePointFromEvent(e);
|
||||
if (!p) return;
|
||||
e.preventDefault();
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
if (activeLocal.kind === 'brush') {
|
||||
if (activeComponent.kind === 'brush') {
|
||||
const stroke: LocalStroke = { points: [p], size: localRadius(), erase: e.altKey };
|
||||
localDrag.current = { id: activeLocal.id, mode: 'brush', stroke };
|
||||
localDrag.current = { layerId: activeLocal.id, componentId: activeComponent.id, mode: 'brush', stroke };
|
||||
setLocalDraft(stroke);
|
||||
return;
|
||||
}
|
||||
if (activeLocal.kind === 'radial') {
|
||||
if (activeComponent.kind === 'radial') {
|
||||
const aspect = bitmap.height / bitmap.width;
|
||||
const nx = (p.x - activeLocal.radial.cx) / Math.max(0.001, activeLocal.radial.rx);
|
||||
const ny = ((p.y - activeLocal.radial.cy) * aspect) / Math.max(0.001, activeLocal.radial.ry);
|
||||
const nx = (p.x - activeComponent.radial.cx) / Math.max(0.001, activeComponent.radial.rx);
|
||||
const ny = ((p.y - activeComponent.radial.cy) * aspect) / Math.max(0.001, activeComponent.radial.ry);
|
||||
const mode =
|
||||
Math.abs(nx) > 0.82 && Math.abs(ny) < 0.65
|
||||
? 'edgeX'
|
||||
@@ -1183,12 +1252,23 @@ export default function Develop({
|
||||
: Math.hypot(nx, ny) > 0.82
|
||||
? 'edge'
|
||||
: 'center';
|
||||
localDrag.current = { id: activeLocal.id, mode, stroke: null };
|
||||
localDrag.current = { layerId: activeLocal.id, componentId: activeComponent.id, mode, stroke: null };
|
||||
return;
|
||||
}
|
||||
const ds = Math.hypot(p.x - activeLocal.linear.x1, (p.y - activeLocal.linear.y1) * (bitmap.height / bitmap.width));
|
||||
const de = Math.hypot(p.x - activeLocal.linear.x2, (p.y - activeLocal.linear.y2) * (bitmap.height / bitmap.width));
|
||||
localDrag.current = { id: activeLocal.id, mode: ds <= de ? 'start' : 'end', stroke: null };
|
||||
const ds = Math.hypot(
|
||||
p.x - activeComponent.linear.x1,
|
||||
(p.y - activeComponent.linear.y1) * (bitmap.height / bitmap.width),
|
||||
);
|
||||
const de = Math.hypot(
|
||||
p.x - activeComponent.linear.x2,
|
||||
(p.y - activeComponent.linear.y2) * (bitmap.height / bitmap.width),
|
||||
);
|
||||
localDrag.current = {
|
||||
layerId: activeLocal.id,
|
||||
componentId: activeComponent.id,
|
||||
mode: ds <= de ? 'start' : 'end',
|
||||
stroke: null,
|
||||
};
|
||||
};
|
||||
|
||||
const moveLocalMask = (e: React.PointerEvent<HTMLCanvasElement>) => {
|
||||
@@ -1198,8 +1278,9 @@ export default function Develop({
|
||||
setLocalHover(p);
|
||||
const drag = localDrag.current;
|
||||
if (!drag) return;
|
||||
const layer = (photo.edits.local ?? []).find((item) => item.id === drag.id);
|
||||
if (!layer) return;
|
||||
const layer = (photo.edits.local ?? []).find((item) => item.id === drag.layerId);
|
||||
const shape = layer?.components.find((item) => item.id === drag.componentId);
|
||||
if (!layer || !shape) return;
|
||||
if (drag.mode === 'brush' && drag.stroke) {
|
||||
const last = drag.stroke.points[drag.stroke.points.length - 1];
|
||||
if (last && Math.hypot((p.x - last.x) * bitmap.width, (p.y - last.y) * bitmap.height) < 1.2) return;
|
||||
@@ -1209,46 +1290,51 @@ export default function Develop({
|
||||
return;
|
||||
}
|
||||
if (drag.mode === 'center') {
|
||||
patchLocal(layer.id, { radial: { ...layer.radial, cx: p.x, cy: p.y } }, 'Move local mask');
|
||||
patchComponent(layer.id, shape.id, { radial: { ...shape.radial, cx: p.x, cy: p.y } }, 'Move local mask');
|
||||
} else if (drag.mode === 'edgeX') {
|
||||
patchLocal(
|
||||
patchComponent(
|
||||
layer.id,
|
||||
{ radial: { ...layer.radial, rx: clampNum(Math.abs(p.x - layer.radial.cx), 0.01, 1.5) } },
|
||||
shape.id,
|
||||
{ radial: { ...shape.radial, rx: clampNum(Math.abs(p.x - shape.radial.cx), 0.01, 1.5) } },
|
||||
'Resize local mask',
|
||||
);
|
||||
} else if (drag.mode === 'edgeY') {
|
||||
patchLocal(
|
||||
patchComponent(
|
||||
layer.id,
|
||||
{ radial: { ...layer.radial, ry: clampNum(Math.abs(p.y - layer.radial.cy), 0.01, 1.5) } },
|
||||
shape.id,
|
||||
{ radial: { ...shape.radial, ry: clampNum(Math.abs(p.y - shape.radial.cy), 0.01, 1.5) } },
|
||||
'Resize local mask',
|
||||
);
|
||||
} else if (drag.mode === 'edge') {
|
||||
patchLocal(
|
||||
patchComponent(
|
||||
layer.id,
|
||||
shape.id,
|
||||
{
|
||||
radial: {
|
||||
...layer.radial,
|
||||
rx: clampNum(Math.abs(p.x - layer.radial.cx), 0.01, 1.5),
|
||||
ry: clampNum(Math.abs(p.y - layer.radial.cy), 0.01, 1.5),
|
||||
...shape.radial,
|
||||
rx: clampNum(Math.abs(p.x - shape.radial.cx), 0.01, 1.5),
|
||||
ry: clampNum(Math.abs(p.y - shape.radial.cy), 0.01, 1.5),
|
||||
},
|
||||
},
|
||||
'Resize local mask',
|
||||
);
|
||||
} else if (drag.mode === 'start') {
|
||||
patchLocal(layer.id, { linear: { ...layer.linear, x1: p.x, y1: p.y } }, 'Move local gradient');
|
||||
patchComponent(layer.id, shape.id, { linear: { ...shape.linear, x1: p.x, y1: p.y } }, 'Move local gradient');
|
||||
} else if (drag.mode === 'end') {
|
||||
patchLocal(layer.id, { linear: { ...layer.linear, x2: p.x, y2: p.y } }, 'Move local gradient');
|
||||
patchComponent(layer.id, shape.id, { linear: { ...shape.linear, x2: p.x, y2: p.y } }, 'Move local gradient');
|
||||
}
|
||||
};
|
||||
|
||||
const endLocalMask = (e: React.PointerEvent<HTMLCanvasElement>) => {
|
||||
const drag = localDrag.current;
|
||||
if (drag?.mode === 'brush' && drag.stroke?.points.length) {
|
||||
const layer = (photo.edits.local ?? []).find((item) => item.id === drag.id);
|
||||
if (layer) {
|
||||
patchLocal(
|
||||
const layer = (photo.edits.local ?? []).find((item) => item.id === drag.layerId);
|
||||
const shape = layer?.components.find((item) => item.id === drag.componentId);
|
||||
if (layer && shape) {
|
||||
patchComponent(
|
||||
layer.id,
|
||||
{ brush: { strokes: [...layer.brush.strokes, drag.stroke].slice(-300) } },
|
||||
shape.id,
|
||||
{ brush: { strokes: [...shape.brush.strokes, drag.stroke].slice(-300) } },
|
||||
drag.stroke.erase ? 'Erase local mask' : 'Paint local mask',
|
||||
);
|
||||
}
|
||||
@@ -1281,6 +1367,7 @@ export default function Develop({
|
||||
|
||||
useEffect(() => {
|
||||
setLocalSelected(null);
|
||||
setLocalComponentSelected(null);
|
||||
setLocalMode(false);
|
||||
setLocalDraft(null);
|
||||
localDrag.current = null;
|
||||
@@ -1289,10 +1376,19 @@ export default function Develop({
|
||||
useEffect(() => {
|
||||
if (!(edits.local ?? []).some((layer) => layer.id === localSelected)) {
|
||||
setLocalSelected(null);
|
||||
setLocalComponentSelected(null);
|
||||
setLocalMode(false);
|
||||
}
|
||||
}, [edits.local, localSelected]);
|
||||
|
||||
// Keep a shape selected, so Edit mask always has something to route the
|
||||
// pointer to after a layer switch or a shape delete.
|
||||
useEffect(() => {
|
||||
if (!activeLocal) return;
|
||||
if (activeLocal.components.some((component) => component.id === localComponentSelected)) return;
|
||||
setLocalComponentSelected(activeLocal.components[0]?.id ?? null);
|
||||
}, [activeLocal, localComponentSelected]);
|
||||
|
||||
// Escape cancels the picker without touching the edit.
|
||||
useEffect(() => {
|
||||
if (!picking) return;
|
||||
@@ -1528,6 +1624,10 @@ export default function Develop({
|
||||
set={setEdits}
|
||||
activeId={localSelected}
|
||||
onSelect={(id) => setLocalSelected(id)}
|
||||
componentId={localComponentSelected}
|
||||
onSelectComponent={setLocalComponentSelected}
|
||||
onAddComponent={addLocalComponent}
|
||||
onDeleteComponent={deleteLocalComponent}
|
||||
onAdd={addLocalLayer}
|
||||
onDelete={deleteLocalLayer}
|
||||
onDuplicate={duplicateLocalLayer}
|
||||
@@ -2074,7 +2174,7 @@ export default function Develop({
|
||||
</svg>
|
||||
);
|
||||
})()}
|
||||
{localMode && bitmap && activeLocal && (() => {
|
||||
{localMode && bitmap && activeComponent && (() => {
|
||||
const geo = geoRef.current;
|
||||
const view = geo.view;
|
||||
const marker = (p: { x: number; y: number }) => {
|
||||
@@ -2103,11 +2203,11 @@ export default function Develop({
|
||||
const canvasW = canvasEl?.clientWidth || 1;
|
||||
const canvasH = canvasEl?.clientHeight || 1;
|
||||
const strokes = localDraft
|
||||
? [...activeLocal.brush.strokes, localDraft]
|
||||
: activeLocal.brush.strokes;
|
||||
? [...activeComponent.brush.strokes, localDraft]
|
||||
: activeComponent.brush.strokes;
|
||||
return (
|
||||
<svg className="local-layer" viewBox="0 0 100 100" preserveAspectRatio="none">
|
||||
{activeLocal.kind === 'brush' &&
|
||||
{activeComponent.kind === 'brush' &&
|
||||
strokes.map((stroke, i) => {
|
||||
if (!stroke.points.length) return null;
|
||||
const points = stroke.points.map(marker).map((p) => `${p.x},${p.y}`).join(' ');
|
||||
@@ -2122,23 +2222,23 @@ export default function Develop({
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{activeLocal.kind === 'radial' && (() => {
|
||||
const c = marker({ x: activeLocal.radial.cx, y: activeLocal.radial.cy });
|
||||
{activeComponent.kind === 'radial' && (() => {
|
||||
const c = marker({ x: activeComponent.radial.cx, y: activeComponent.radial.cy });
|
||||
const edge = marker({
|
||||
x: activeLocal.radial.cx + activeLocal.radial.rx,
|
||||
y: activeLocal.radial.cy,
|
||||
x: activeComponent.radial.cx + activeComponent.radial.rx,
|
||||
y: activeComponent.radial.cy,
|
||||
});
|
||||
const edgeY = marker({
|
||||
x: activeLocal.radial.cx,
|
||||
y: activeLocal.radial.cy + activeLocal.radial.ry,
|
||||
x: activeComponent.radial.cx,
|
||||
y: activeComponent.radial.cy + activeComponent.radial.ry,
|
||||
});
|
||||
// Sample the perimeter so the guide follows the same warp
|
||||
// as the picture instead of staying a screen-space ellipse.
|
||||
const ring = Array.from({ length: 72 }, (_, i) => {
|
||||
const angle = (i / 72) * Math.PI * 2;
|
||||
const p = marker({
|
||||
x: activeLocal.radial.cx + Math.cos(angle) * activeLocal.radial.rx,
|
||||
y: activeLocal.radial.cy + Math.sin(angle) * activeLocal.radial.ry,
|
||||
x: activeComponent.radial.cx + Math.cos(angle) * activeComponent.radial.rx,
|
||||
y: activeComponent.radial.cy + Math.sin(angle) * activeComponent.radial.ry,
|
||||
});
|
||||
return `${p.x},${p.y}`;
|
||||
}).join(' ');
|
||||
@@ -2155,9 +2255,9 @@ export default function Develop({
|
||||
</g>
|
||||
);
|
||||
})()}
|
||||
{activeLocal.kind === 'linear' && (() => {
|
||||
const a = marker({ x: activeLocal.linear.x1, y: activeLocal.linear.y1 });
|
||||
const b = marker({ x: activeLocal.linear.x2, y: activeLocal.linear.y2 });
|
||||
{activeComponent.kind === 'linear' && (() => {
|
||||
const a = marker({ x: activeComponent.linear.x1, y: activeComponent.linear.y1 });
|
||||
const b = marker({ x: activeComponent.linear.x2, y: activeComponent.linear.y2 });
|
||||
return (
|
||||
<g>
|
||||
<line x1={a.x} y1={a.y} x2={b.x} y2={b.y} className="local-line" vectorEffect="non-scaling-stroke" />
|
||||
@@ -2166,7 +2266,7 @@ export default function Develop({
|
||||
</g>
|
||||
);
|
||||
})()}
|
||||
{activeLocal.kind === 'brush' && localHover && !localDrag.current && (
|
||||
{activeComponent.kind === 'brush' && localHover && !localDrag.current && (
|
||||
<ellipse
|
||||
cx={marker(localHover).x}
|
||||
cy={marker(localHover).y}
|
||||
@@ -2192,10 +2292,10 @@ export default function Develop({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{localMode && activeLocal && !error && (
|
||||
{localMode && activeLocal && activeComponent && !error && (
|
||||
<div className="heal-hud local-hud">
|
||||
<span className="heal-hud-title">Local · {activeLocal.kind}</span>
|
||||
{activeLocal.kind === 'brush' && (
|
||||
<span className="heal-hud-title">Local · {activeComponent.kind}</span>
|
||||
{activeComponent.kind === 'brush' && (
|
||||
<>
|
||||
<label className="heal-field">
|
||||
Size
|
||||
@@ -2211,7 +2311,7 @@ export default function Develop({
|
||||
<span className="heal-read">{Math.round(localBrush)}px</span>
|
||||
</>
|
||||
)}
|
||||
{activeLocal.kind !== 'linear' && (
|
||||
{activeComponent.kind !== 'linear' && (
|
||||
<>
|
||||
<label className="heal-field">
|
||||
Feather
|
||||
@@ -2220,27 +2320,41 @@ export default function Develop({
|
||||
min={0}
|
||||
max={100}
|
||||
step={1}
|
||||
value={activeLocal.feather}
|
||||
onChange={(e) => patchLocal(activeLocal.id, { feather: Number(e.target.value) }, 'Local feather')}
|
||||
value={activeComponent.feather}
|
||||
onChange={(e) =>
|
||||
patchComponent(
|
||||
activeLocal.id,
|
||||
activeComponent.id,
|
||||
{ feather: Number(e.target.value) },
|
||||
'Local feather',
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<span className="heal-read">{Math.round(activeLocal.feather)}%</span>
|
||||
<span className="heal-read">{Math.round(activeComponent.feather)}%</span>
|
||||
</>
|
||||
)}
|
||||
<button
|
||||
className="heal-act"
|
||||
onClick={() => {
|
||||
if (activeLocal.kind === 'brush') {
|
||||
patchLocal(activeLocal.id, { brush: { strokes: [] } }, 'Clear local mask');
|
||||
} else if (activeLocal.kind === 'radial') {
|
||||
patchLocal(
|
||||
if (activeComponent.kind === 'brush') {
|
||||
patchComponent(
|
||||
activeLocal.id,
|
||||
activeComponent.id,
|
||||
{ brush: { strokes: [] } },
|
||||
'Clear local mask',
|
||||
);
|
||||
} else if (activeComponent.kind === 'radial') {
|
||||
patchComponent(
|
||||
activeLocal.id,
|
||||
activeComponent.id,
|
||||
{ radial: { cx: 0.5, cy: 0.5, rx: 0.25, ry: 0.3 } },
|
||||
'Reset local mask',
|
||||
);
|
||||
} else {
|
||||
patchLocal(
|
||||
patchComponent(
|
||||
activeLocal.id,
|
||||
activeComponent.id,
|
||||
{ linear: { x1: 0.5, y1: 0.2, x2: 0.5, y2: 0.8 } },
|
||||
'Reset local mask',
|
||||
);
|
||||
@@ -2253,9 +2367,9 @@ export default function Develop({
|
||||
Done
|
||||
</button>
|
||||
<span className="heal-tip">
|
||||
{activeLocal.kind === 'brush'
|
||||
{activeComponent.kind === 'brush'
|
||||
? 'Paint the mask · Alt paints an erase stroke · wheel sizes the brush'
|
||||
: activeLocal.kind === 'radial'
|
||||
: activeComponent.kind === 'radial'
|
||||
? 'Drag the centre or the edge handle · wheel zooms'
|
||||
: 'Drag either end of the gradient'}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user