mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-16 11:52:25 +02:00
feat(photo-editor): Ajax Image Editor client (Photoshop-parity tools)
Photoshop-parity editor client: layers, selection/masking, brushes,
smart filters, LUT import, Quick Edit, mobile gestures, workspaces,
batch operations, and the service-worker versioning (v978->v1006).
Source: vendor/photocraft (ad1cff44) photo-editor client files, merged
onto upstream/dev (a8c147b2). Conflict resolution documented in
pr_work/A_conflicts.md; editor files taken from vendor/photocraft
(upstream's editor is an earlier snapshot of the same feature).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c74f475679
commit
5fac693c1c
@@ -0,0 +1,63 @@
|
||||
// Quick Selection brush — drag to grow a wand-style selection.
|
||||
// Reuses the existing magic-wand flood fill by re-sampling along the
|
||||
// stroke; intermediate samples skip the undo snapshot (retune mode) so a
|
||||
// whole drag collapses to one history entry (taken on begin).
|
||||
|
||||
import { selectionModeForEvent } from '../selection-modifiers.js';
|
||||
|
||||
export function createQuickSelectTool({
|
||||
activeLayer,
|
||||
saveState,
|
||||
composite,
|
||||
runMagicWand,
|
||||
canvasCoords,
|
||||
brushSize,
|
||||
syncToolClearIndicators,
|
||||
}) {
|
||||
let painting = false;
|
||||
let last = null;
|
||||
|
||||
const modeFor = (event) => selectionModeForEvent(event, 'add');
|
||||
|
||||
const sample = (event) => {
|
||||
const coords = canvasCoords(event);
|
||||
if (!coords) return;
|
||||
runMagicWand(coords.x, coords.y, modeFor(event), { retune: true });
|
||||
};
|
||||
|
||||
const begin = (event) => {
|
||||
const layer = activeLayer();
|
||||
if (!layer) return;
|
||||
saveState();
|
||||
painting = true;
|
||||
last = null;
|
||||
sample(event);
|
||||
const coords = canvasCoords(event);
|
||||
if (coords) last = coords;
|
||||
};
|
||||
|
||||
const drag = (event) => {
|
||||
if (!painting) return;
|
||||
const coords = canvasCoords(event);
|
||||
if (!coords) return;
|
||||
const gap = Math.max(3, (brushSize?.() || 24) / 4);
|
||||
if (last && Math.hypot(coords.x - last.x, coords.y - last.y) < gap) return;
|
||||
sample(event);
|
||||
last = coords;
|
||||
};
|
||||
|
||||
const end = () => {
|
||||
if (!painting) return;
|
||||
painting = false;
|
||||
last = null;
|
||||
composite();
|
||||
syncToolClearIndicators?.();
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
painting = false;
|
||||
last = null;
|
||||
};
|
||||
|
||||
return { begin, drag, end, cancel };
|
||||
}
|
||||
Reference in New Issue
Block a user