@sealpixel/ui 1.0.0-rc.2 → 1.0.0-rc.20
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/LICENSE.md +2 -2
- package/README.md +1 -1
- package/dist/components/sealpixel-button.d.ts +0 -1
- package/dist/components/sealpixel-button.js +1 -1
- package/dist/components/sealpixel-button.js.map +1 -1
- package/dist/components/sealpixel-editor.d.ts +71 -20
- package/dist/components/sealpixel-editor.js +265 -57
- package/dist/components/sealpixel-editor.js.map +1 -1
- package/dist/components/sealpixel-nav.d.ts +0 -1
- package/dist/components/sealpixel-nav.js +1 -1
- package/dist/components/sealpixel-nav.js.map +1 -1
- package/dist/components/sealpixel-slider.d.ts +12 -17
- package/dist/components/sealpixel-slider.js +64 -10
- package/dist/components/sealpixel-slider.js.map +1 -1
- package/dist/components/sealpixel-stage.d.ts +17 -1
- package/dist/components/sealpixel-stage.js +57 -6
- package/dist/components/sealpixel-stage.js.map +1 -1
- package/dist/components/sealpixel-stepper.d.ts +0 -1
- package/dist/components/sealpixel-stepper.js +4 -4
- package/dist/components/sealpixel-stepper.js.map +1 -1
- package/dist/components/sealpixel-toolbar.d.ts +6 -2
- package/dist/components/sealpixel-toolbar.js +71 -5
- package/dist/components/sealpixel-toolbar.js.map +1 -1
- package/dist/controllers/gesture-controller.d.ts +5 -1
- package/dist/controllers/gesture-controller.js +24 -4
- package/dist/controllers/gesture-controller.js.map +1 -1
- package/dist/controllers/session-controller.d.ts +0 -1
- package/dist/controllers/session-controller.js +2 -0
- package/dist/controllers/session-controller.js.map +1 -1
- package/dist/define.d.ts +0 -1
- package/dist/define.js.map +1 -1
- package/dist/i18n.d.ts +0 -1
- package/dist/i18n.js.map +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +1 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/locales/de.d.ts +0 -1
- package/dist/locales/de.js +22 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +0 -1
- package/dist/locales/en.js +22 -0
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.d.ts +0 -1
- package/dist/locales/es.js +22 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts +0 -1
- package/dist/locales/fr.js +22 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/index.d.ts +0 -1
- package/dist/locales/index.js.map +1 -1
- package/dist/locales/ja.d.ts +0 -1
- package/dist/locales/ja.js +22 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/pt.d.ts +0 -1
- package/dist/locales/pt.js +22 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/theme.d.ts +0 -1
- package/dist/theme.js.map +1 -1
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js.map +1 -1
- package/dist/tools/annotate.d.ts +0 -1
- package/dist/tools/annotate.js +277 -28
- package/dist/tools/annotate.js.map +1 -1
- package/dist/tools/assist.d.ts +103 -0
- package/dist/tools/assist.js +361 -0
- package/dist/tools/assist.js.map +1 -0
- package/dist/tools/crop-mask.d.ts +0 -1
- package/dist/tools/crop-mask.js.map +1 -1
- package/dist/tools/crop-rotation.d.ts +64 -0
- package/dist/tools/crop-rotation.js +172 -0
- package/dist/tools/crop-rotation.js.map +1 -0
- package/dist/tools/crop.d.ts +0 -1
- package/dist/tools/crop.js +99 -15
- package/dist/tools/crop.js.map +1 -1
- package/dist/tools/delete-handle.d.ts +0 -1
- package/dist/tools/delete-handle.js +6 -0
- package/dist/tools/delete-handle.js.map +1 -1
- package/dist/tools/filter.d.ts +0 -1
- package/dist/tools/filter.js.map +1 -1
- package/dist/tools/finetune.d.ts +0 -1
- package/dist/tools/finetune.js.map +1 -1
- package/dist/tools/frame.d.ts +0 -1
- package/dist/tools/frame.js.map +1 -1
- package/dist/tools/handles.d.ts +26 -0
- package/dist/tools/handles.js +51 -0
- package/dist/tools/handles.js.map +1 -0
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +3 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/keys.d.ts +59 -0
- package/dist/tools/keys.js +120 -0
- package/dist/tools/keys.js.map +1 -0
- package/dist/tools/redact.d.ts +10 -1
- package/dist/tools/redact.js +176 -12
- package/dist/tools/redact.js.map +1 -1
- package/dist/tools/region-transform.d.ts +69 -0
- package/dist/tools/region-transform.js +192 -0
- package/dist/tools/region-transform.js.map +1 -0
- package/dist/tools/resize.d.ts +0 -1
- package/dist/tools/resize.js +19 -6
- package/dist/tools/resize.js.map +1 -1
- package/dist/tools/sticker.d.ts +0 -1
- package/dist/tools/sticker.js +57 -2
- package/dist/tools/sticker.js.map +1 -1
- package/dist/tools/watermark.d.ts +0 -1
- package/dist/tools/watermark.js.map +1 -1
- package/dist/view-mapping.d.ts +1 -2
- package/dist/view-mapping.js +1 -1
- package/dist/view-mapping.js.map +1 -1
- package/package.json +8 -8
- package/dist/components/sealpixel-button.d.ts.map +0 -1
- package/dist/components/sealpixel-editor.d.ts.map +0 -1
- package/dist/components/sealpixel-nav.d.ts.map +0 -1
- package/dist/components/sealpixel-slider.d.ts.map +0 -1
- package/dist/components/sealpixel-stage.d.ts.map +0 -1
- package/dist/components/sealpixel-stepper.d.ts.map +0 -1
- package/dist/components/sealpixel-toolbar.d.ts.map +0 -1
- package/dist/controllers/gesture-controller.d.ts.map +0 -1
- package/dist/controllers/session-controller.d.ts.map +0 -1
- package/dist/define.d.ts.map +0 -1
- package/dist/i18n.d.ts.map +0 -1
- package/dist/icons.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/locales/de.d.ts.map +0 -1
- package/dist/locales/en.d.ts.map +0 -1
- package/dist/locales/es.d.ts.map +0 -1
- package/dist/locales/fr.d.ts.map +0 -1
- package/dist/locales/index.d.ts.map +0 -1
- package/dist/locales/ja.d.ts.map +0 -1
- package/dist/locales/pt.d.ts.map +0 -1
- package/dist/theme.d.ts.map +0 -1
- package/dist/tool.d.ts.map +0 -1
- package/dist/tools/annotate.d.ts.map +0 -1
- package/dist/tools/crop-mask.d.ts.map +0 -1
- package/dist/tools/crop.d.ts.map +0 -1
- package/dist/tools/delete-handle.d.ts.map +0 -1
- package/dist/tools/filter.d.ts.map +0 -1
- package/dist/tools/finetune.d.ts.map +0 -1
- package/dist/tools/frame.d.ts.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/redact.d.ts.map +0 -1
- package/dist/tools/resize.d.ts.map +0 -1
- package/dist/tools/sticker.d.ts.map +0 -1
- package/dist/tools/watermark.d.ts.map +0 -1
- package/dist/view-mapping.d.ts.map +0 -1
package/dist/tools/redact.js
CHANGED
|
@@ -4,6 +4,8 @@ import { icons } from '../icons.js';
|
|
|
4
4
|
import { cropClipPath } from './crop-mask.js';
|
|
5
5
|
import { deleteHandle, pointsBox, toPx } from './delete-handle.js';
|
|
6
6
|
import { opId } from './finetune.js';
|
|
7
|
+
import { elementKeys, focusEditor, focusWhen } from './keys.js';
|
|
8
|
+
import { corners, describe, resize, slide, snapAngle, transformRegion, } from './region-transform.js';
|
|
7
9
|
/** Redact coordinates live in image space: show the image before crop and resize. */
|
|
8
10
|
function beforeCrop(log) {
|
|
9
11
|
return {
|
|
@@ -23,8 +25,10 @@ const state = {
|
|
|
23
25
|
selected: null,
|
|
24
26
|
drawing: null,
|
|
25
27
|
drag: null,
|
|
28
|
+
transform: null,
|
|
29
|
+
focusPending: null,
|
|
26
30
|
};
|
|
27
|
-
function translateRegion(region, dx, dy) {
|
|
31
|
+
export function translateRegion(region, dx, dy) {
|
|
28
32
|
if (region.kind === 'rect') {
|
|
29
33
|
const q = region.rect;
|
|
30
34
|
return {
|
|
@@ -36,10 +40,9 @@ function translateRegion(region, dx, dy) {
|
|
|
36
40
|
},
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
+
// A path moves as one body: the move stops at the edge instead of pinning
|
|
44
|
+
// the points that reach it, which would change the shape.
|
|
45
|
+
return { kind: 'path', points: slide(region.points, dx, dy) };
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Keeps the preview clipped to what the crop keeps. Called on activate and on
|
|
@@ -61,7 +64,9 @@ export const redactTool = {
|
|
|
61
64
|
deactivate: (ctx) => {
|
|
62
65
|
state.drawing = null;
|
|
63
66
|
state.drag = null;
|
|
67
|
+
state.transform = null;
|
|
64
68
|
state.selected = null;
|
|
69
|
+
state.focusPending = null;
|
|
65
70
|
ctx.clipPreview(null);
|
|
66
71
|
ctx.session.setPreviewTransform(null);
|
|
67
72
|
},
|
|
@@ -134,10 +139,22 @@ export const redactTool = {
|
|
|
134
139
|
state.drawing.points.push(q);
|
|
135
140
|
ctx.refresh();
|
|
136
141
|
};
|
|
137
|
-
const
|
|
142
|
+
const cleanup = () => {
|
|
138
143
|
window.removeEventListener('pointermove', move);
|
|
139
144
|
window.removeEventListener('pointerup', up);
|
|
140
145
|
window.removeEventListener('pointercancel', up);
|
|
146
|
+
window.removeEventListener('keydown', cancel);
|
|
147
|
+
};
|
|
148
|
+
// Escape while drawing drops the shape: nothing reaches the log.
|
|
149
|
+
const cancel = (ev) => {
|
|
150
|
+
if (ev.key !== 'Escape')
|
|
151
|
+
return;
|
|
152
|
+
state.drawing = null;
|
|
153
|
+
cleanup();
|
|
154
|
+
ctx.refresh();
|
|
155
|
+
};
|
|
156
|
+
const up = () => {
|
|
157
|
+
cleanup();
|
|
141
158
|
const d = state.drawing;
|
|
142
159
|
state.drawing = null;
|
|
143
160
|
if (!d)
|
|
@@ -159,17 +176,25 @@ export const redactTool = {
|
|
|
159
176
|
const amount = ctx.options('redact')?.defaultAmount ?? state.amount;
|
|
160
177
|
ctx.dispatch({ type: 'redact.add', id, region, mode: state.mode, amount });
|
|
161
178
|
state.selected = id;
|
|
179
|
+
state.focusPending = id;
|
|
162
180
|
}
|
|
163
181
|
ctx.refresh();
|
|
164
182
|
};
|
|
165
183
|
window.addEventListener('pointermove', move);
|
|
166
184
|
window.addEventListener('pointerup', up);
|
|
167
185
|
window.addEventListener('pointercancel', up);
|
|
186
|
+
window.addEventListener('keydown', cancel);
|
|
168
187
|
};
|
|
169
|
-
const
|
|
188
|
+
const options = ctx.options('redact') ?? REDACT_DEFAULT_OPTIONS;
|
|
189
|
+
const shown = (r) => state.transform?.id === r.id
|
|
190
|
+
? state.transform.region
|
|
191
|
+
: state.drag?.id === r.id
|
|
192
|
+
? state.drag.region
|
|
193
|
+
: r.region;
|
|
194
|
+
const shape = (r, i) => {
|
|
170
195
|
const selected = state.selected === r.id;
|
|
171
|
-
const dragging = state.drag?.id === r.id;
|
|
172
|
-
const region =
|
|
196
|
+
const dragging = state.drag?.id === r.id || state.transform?.id === r.id;
|
|
197
|
+
const region = shown(r);
|
|
173
198
|
const stroke = selected ? 'var(--sealpixel-color-accent)' : 'rgba(255,255,255,0.9)';
|
|
174
199
|
const fill = dragging ? 'rgba(91,141,239,0.25)' : 'rgba(255,255,255,0.08)';
|
|
175
200
|
// Press selects; moving the pointer drags the region and commits one update on release.
|
|
@@ -177,6 +202,8 @@ export const redactTool = {
|
|
|
177
202
|
e.stopPropagation();
|
|
178
203
|
e.preventDefault();
|
|
179
204
|
state.selected = r.id;
|
|
205
|
+
// preventDefault above keeps the browser from focusing the region.
|
|
206
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
180
207
|
const start = toN(e);
|
|
181
208
|
state.drag = { id: r.id, region: r.region, start };
|
|
182
209
|
const move = (ev) => {
|
|
@@ -201,20 +228,156 @@ export const redactTool = {
|
|
|
201
228
|
window.addEventListener('pointerup', up);
|
|
202
229
|
window.addEventListener('pointercancel', up);
|
|
203
230
|
};
|
|
231
|
+
// The keyboard moves the region through the same transient drag as the
|
|
232
|
+
// pointer and commits one update when the key is released.
|
|
233
|
+
const commit = () => {
|
|
234
|
+
const d = state.drag;
|
|
235
|
+
if (!d?.keys || d.id !== r.id)
|
|
236
|
+
return;
|
|
237
|
+
state.drag = null;
|
|
238
|
+
if (JSON.stringify(d.region) !== JSON.stringify(r.region)) {
|
|
239
|
+
ctx.dispatch({ type: 'redact.update', id: opId(), regionId: r.id, region: d.region });
|
|
240
|
+
}
|
|
241
|
+
ctx.refresh();
|
|
242
|
+
};
|
|
243
|
+
const keys = elementKeys(ctx.stage, {
|
|
244
|
+
select: () => {
|
|
245
|
+
if (state.selected === r.id)
|
|
246
|
+
return;
|
|
247
|
+
state.selected = r.id;
|
|
248
|
+
ctx.refresh();
|
|
249
|
+
},
|
|
250
|
+
move: (dx, dy) => {
|
|
251
|
+
if (state.drawing || state.transform || (state.drag && !state.drag.keys))
|
|
252
|
+
return;
|
|
253
|
+
const base = state.drag?.id === r.id ? state.drag.region : r.region;
|
|
254
|
+
state.drag = {
|
|
255
|
+
id: r.id,
|
|
256
|
+
region: translateRegion(base, dx, dy),
|
|
257
|
+
start: [0, 0],
|
|
258
|
+
keys: true,
|
|
259
|
+
};
|
|
260
|
+
ctx.refresh();
|
|
261
|
+
},
|
|
262
|
+
commit,
|
|
263
|
+
remove: (el) => {
|
|
264
|
+
commit();
|
|
265
|
+
// Focus moves on before the region goes, so Tab stays in the editor.
|
|
266
|
+
const next = doc.regions[i + 1] ?? doc.regions[i - 1] ?? null;
|
|
267
|
+
state.selected = next?.id ?? null;
|
|
268
|
+
state.focusPending = next?.id ?? null;
|
|
269
|
+
if (!next)
|
|
270
|
+
focusEditor(el);
|
|
271
|
+
ctx.dispatch({ type: 'redact.remove', id: opId(), regionId: r.id });
|
|
272
|
+
},
|
|
273
|
+
escape: () => {
|
|
274
|
+
// Mid-drawing the key belongs to the drawing: the canvas listener drops it.
|
|
275
|
+
if (state.drawing)
|
|
276
|
+
return false;
|
|
277
|
+
const open = state.selected !== null || !!state.drag?.keys;
|
|
278
|
+
if (state.drag?.keys)
|
|
279
|
+
state.drag = null;
|
|
280
|
+
state.selected = null;
|
|
281
|
+
ctx.refresh();
|
|
282
|
+
return open;
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
const label = ctx.t('redact.region', { n: i + 1 });
|
|
204
286
|
if (region.kind === 'rect') {
|
|
205
287
|
const q = region.rect;
|
|
206
|
-
return svg `<rect data-interactive data-region=${r.id} x=${q.x * W} y=${q.y * H} width=${q.width * W} height=${q.height * H} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style="cursor:move" @pointerdown=${pick} />`;
|
|
288
|
+
return svg `<rect data-interactive data-region=${r.id} tabindex="0" role="button" aria-pressed=${selected ? 'true' : 'false'} aria-label=${label} ${focusWhen(state, r.id)} x=${q.x * W} y=${q.y * H} width=${q.width * W} height=${q.height * H} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style="cursor:move" @pointerdown=${pick} @focus=${keys.focus} @blur=${keys.blur} @keydown=${keys.keydown} @keyup=${keys.keyup} />`;
|
|
207
289
|
}
|
|
208
290
|
const d = region.points
|
|
209
291
|
.map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0] * W} ${p[1] * H}`)
|
|
210
292
|
.join(' ');
|
|
211
|
-
return svg `<path data-interactive data-region=${r.id} d=${`${d} Z`} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style="cursor:move" @pointerdown=${pick} />`;
|
|
293
|
+
return svg `<path data-interactive data-region=${r.id} tabindex="0" role="button" aria-pressed=${selected ? 'true' : 'false'} aria-label=${label} ${focusWhen(state, r.id)} d=${`${d} Z`} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style="cursor:move" @pointerdown=${pick} @focus=${keys.focus} @blur=${keys.blur} @keydown=${keys.keydown} @keyup=${keys.keyup} />`;
|
|
212
294
|
};
|
|
213
295
|
const selectedRegion = doc.regions.find((r) => r.id === state.selected) ?? null;
|
|
214
296
|
const regionBox = (r) => {
|
|
215
|
-
const region =
|
|
297
|
+
const region = shown(r);
|
|
216
298
|
return region.kind === 'rect' ? region.rect : pointsBox(region.points);
|
|
217
299
|
};
|
|
300
|
+
// Handles on the selected region: eight to resize, one below to turn. A
|
|
301
|
+
// drag maps the pointer through the region's frame and commits one
|
|
302
|
+
// update on release; see region-transform.ts for what the log gets.
|
|
303
|
+
const transformHandles = (r) => {
|
|
304
|
+
const frame = describe(shown(r), W, H);
|
|
305
|
+
const c = corners(frame);
|
|
306
|
+
const mid = (a, b) => [
|
|
307
|
+
(a[0] + b[0]) / 2,
|
|
308
|
+
(a[1] + b[1]) / 2,
|
|
309
|
+
];
|
|
310
|
+
const at = [
|
|
311
|
+
['nw', c[0]],
|
|
312
|
+
['n', mid(c[0], c[1])],
|
|
313
|
+
['ne', c[1]],
|
|
314
|
+
['e', mid(c[1], c[2])],
|
|
315
|
+
['se', c[2]],
|
|
316
|
+
['s', mid(c[2], c[3])],
|
|
317
|
+
['sw', c[3]],
|
|
318
|
+
['w', mid(c[3], c[0])],
|
|
319
|
+
];
|
|
320
|
+
const cos = Math.cos(frame.rotation);
|
|
321
|
+
const sin = Math.sin(frame.rotation);
|
|
322
|
+
const stem = 28 / zoom;
|
|
323
|
+
const bottom = mid(c[2], c[3]);
|
|
324
|
+
const knob = [bottom[0] - sin * stem, bottom[1] + cos * stem];
|
|
325
|
+
const degrees = Math.round((frame.rotation * 180) / Math.PI);
|
|
326
|
+
const hr = 7 / zoom;
|
|
327
|
+
const begin = (handle) => (e) => {
|
|
328
|
+
e.stopPropagation();
|
|
329
|
+
e.preventDefault();
|
|
330
|
+
const start = ctx.stage.toImage(e.clientX, e.clientY);
|
|
331
|
+
const origin = r.region;
|
|
332
|
+
const from = describe(origin, W, H);
|
|
333
|
+
const startAngle = Math.atan2(start.y - from.cy, start.x - from.cx);
|
|
334
|
+
state.transform = { id: r.id, origin, from, region: origin };
|
|
335
|
+
const move = (ev) => {
|
|
336
|
+
if (!state.transform)
|
|
337
|
+
return;
|
|
338
|
+
const q = ctx.stage.toImage(ev.clientX, ev.clientY);
|
|
339
|
+
const next = handle === 'rotate'
|
|
340
|
+
? {
|
|
341
|
+
...from,
|
|
342
|
+
rotation: snapAngle(from.rotation + Math.atan2(q.y - from.cy, q.x - from.cx) - startAngle),
|
|
343
|
+
}
|
|
344
|
+
: resize(from, handle, q.x - start.x, q.y - start.y, 6 / zoom);
|
|
345
|
+
const region = transformRegion(origin, from, next, W, H);
|
|
346
|
+
if (region)
|
|
347
|
+
state.transform.region = region;
|
|
348
|
+
ctx.refresh();
|
|
349
|
+
};
|
|
350
|
+
const up = () => {
|
|
351
|
+
window.removeEventListener('pointermove', move);
|
|
352
|
+
window.removeEventListener('pointerup', up);
|
|
353
|
+
window.removeEventListener('pointercancel', up);
|
|
354
|
+
const t = state.transform;
|
|
355
|
+
state.transform = null;
|
|
356
|
+
if (t && JSON.stringify(t.region) !== JSON.stringify(origin)) {
|
|
357
|
+
ctx.dispatch({ type: 'redact.update', id: opId(), regionId: r.id, region: t.region });
|
|
358
|
+
}
|
|
359
|
+
ctx.refresh();
|
|
360
|
+
};
|
|
361
|
+
window.addEventListener('pointermove', move);
|
|
362
|
+
window.addEventListener('pointerup', up);
|
|
363
|
+
window.addEventListener('pointercancel', up);
|
|
364
|
+
};
|
|
365
|
+
const cursor = {
|
|
366
|
+
nw: 'nwse-resize',
|
|
367
|
+
se: 'nwse-resize',
|
|
368
|
+
ne: 'nesw-resize',
|
|
369
|
+
sw: 'nesw-resize',
|
|
370
|
+
n: 'ns-resize',
|
|
371
|
+
s: 'ns-resize',
|
|
372
|
+
e: 'ew-resize',
|
|
373
|
+
w: 'ew-resize',
|
|
374
|
+
};
|
|
375
|
+
return svg `
|
|
376
|
+
<line x1=${bottom[0]} y1=${bottom[1]} x2=${knob[0]} y2=${knob[1]} stroke="var(--sealpixel-color-accent)" stroke-width=${sw} pointer-events="none" />
|
|
377
|
+
${at.map(([id, p]) => svg `<circle data-interactive data-handle=${id} cx=${p[0]} cy=${p[1]} r=${hr} fill="white" stroke="var(--sealpixel-color-accent)" stroke-width=${sw} style=${`cursor:${cursor[id]}`} @pointerdown=${begin(id)} />`)}
|
|
378
|
+
<circle data-interactive data-handle="rotate" role="slider" aria-label=${ctx.t('redact.rotate')} aria-valuemin="-180" aria-valuemax="180" aria-valuenow=${degrees} aria-valuetext=${`${degrees}°`} cx=${knob[0]} cy=${knob[1]} r=${hr * 1.15} fill="var(--sealpixel-color-accent)" stroke="white" stroke-width=${sw} style="cursor:grab" @pointerdown=${begin('rotate')} />
|
|
379
|
+
`;
|
|
380
|
+
};
|
|
218
381
|
const drawing = state.drawing;
|
|
219
382
|
let live = svg ``;
|
|
220
383
|
if (drawing) {
|
|
@@ -233,6 +396,7 @@ export const redactTool = {
|
|
|
233
396
|
return svg `
|
|
234
397
|
<rect data-interactive data-canvas x="0" y="0" width=${W} height=${H} fill="transparent" style="cursor:crosshair" @pointerdown=${down} />
|
|
235
398
|
${doc.regions.map(shape)}
|
|
399
|
+
${selectedRegion && options.transform ? transformHandles(selectedRegion) : nothing}
|
|
236
400
|
${selectedRegion
|
|
237
401
|
? deleteHandle(toPx(regionBox(selectedRegion), W, H), ctx.stage, ctx.t('redact.remove'), () => {
|
|
238
402
|
state.selected = null;
|
package/dist/tools/redact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/tools/redact.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAsB,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAiB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,IAAI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I,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO;QAEhF,cAAc;YACZ,CAAC,CAAC,YAAY,CACV,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,GAAG,CAAC,KAAK,EACT,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,EACtB,GAAG,EAAE;gBACH,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACtB,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;YACnF,CAAC,CACF;YACH,CAAC,CAAC,OACN;QACE,IAAI;KACP,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACxB,CAAC;AACD,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { EditLog, Rect } from '@sealpixel/core';\nimport { REDACT_DEFAULT_OPTIONS, type RedactMode, type RedactOptions } from '@sealpixel/plugins';\nimport { html, nothing, svg } from 'lit';\nimport { icons } from '../icons.js';\nimport type { UiTool, UiToolContext } from '../tool.js';\nimport { type CropLike, cropClipPath } from './crop-mask.js';\nimport { deleteHandle, pointsBox, toPx } from './delete-handle.js';\nimport { opId } from './finetune.js';\nimport { elementKeys, focusEditor, focusWhen } from './keys.js';\nimport {\n corners,\n describe,\n type Frame,\n type ResizeHandle,\n resize,\n slide,\n snapAngle,\n transformRegion,\n} from './region-transform.js';\n\ntype Region = { kind: 'rect'; rect: Rect } | { kind: 'path'; points: [number, number][] };\ninterface Redaction {\n id: string;\n region: Region;\n mode: RedactMode;\n amount: number;\n}\ninterface RedactDoc {\n regions: Redaction[];\n}\n\n/** Redact coordinates live in image space: show the image before crop and resize. */\nfunction beforeCrop(log: EditLog): EditLog {\n return {\n ...log,\n ops: [\n ...log.ops,\n { type: 'crop.reset', id: '__sealpixel_preview_crop__' },\n { type: 'resize.clear', id: '__sealpixel_preview_resize__' },\n ],\n };\n}\n\n/** Transient tool state: draw mode, defaults for new regions, in-progress shape. */\nconst state: {\n shape: 'rect' | 'path';\n mode: RedactMode;\n amount: number;\n selected: string | null;\n drawing: {\n start: [number, number];\n current: [number, number];\n points: [number, number][];\n } | null;\n /** A move in progress; `keys` when the arrow keys drive it, so a pointer drag is told apart. */\n drag: { id: string; region: Region; start: [number, number]; keys?: true } | null;\n /** A handle drag on the selected region: the frame it started from and the region it stands for now. */\n transform: { id: string; origin: Region; from: Frame; region: Region } | null;\n /** The region that takes keyboard focus on the next render: just added, or next after a deletion. */\n focusPending: string | null;\n} = {\n shape: 'rect',\n mode: 'pixelate',\n amount: 12,\n selected: null,\n drawing: null,\n drag: null,\n transform: null,\n focusPending: null,\n};\n\nexport function translateRegion(region: Region, dx: number, dy: number): Region {\n if (region.kind === 'rect') {\n const q = region.rect;\n return {\n kind: 'rect',\n rect: {\n ...q,\n x: clamp(q.x + dx, 0, 1 - q.width),\n y: clamp(q.y + dy, 0, 1 - q.height),\n },\n };\n }\n // A path moves as one body: the move stops at the edge instead of pinning\n // the points that reach it, which would change the shape.\n return { kind: 'path', points: slide(region.points, dx, dy) };\n}\n\n/**\n * Keeps the preview clipped to what the crop keeps. Called on activate and on\n * every panel render, so an undo that changes the crop is picked up too.\n */\nfunction clipToCrop(ctx: UiToolContext): void {\n const crop = (ctx.session.getDocument() as unknown as { crop?: CropLike }).crop;\n const preview = ctx.state.preview;\n ctx.clipPreview(preview ? cropClipPath(crop, preview.image.width, preview.image.height) : null);\n}\n\nexport const redactTool: UiTool = {\n id: 'redact',\n icon: icons.redact,\n label: 'tool.redact',\n activate: (ctx) => {\n clipToCrop(ctx);\n ctx.session.setPreviewTransform(beforeCrop);\n },\n deactivate: (ctx) => {\n state.drawing = null;\n state.drag = null;\n state.transform = null;\n state.selected = null;\n state.focusPending = null;\n ctx.clipPreview(null);\n ctx.session.setPreviewTransform(null);\n },\n panel: (ctx: UiToolContext) => {\n clipToCrop(ctx);\n const doc = (ctx.document as unknown as { redact: RedactDoc }).redact;\n const options = ctx.options<RedactOptions>('redact') ?? REDACT_DEFAULT_OPTIONS;\n if (!options.modes.includes(state.mode)) state.mode = options.defaultMode;\n if (!options.shapes.includes(state.shape)) state.shape = options.shapes[0] ?? 'rect';\n // The amount is configuration (`defaultAmount`), not a control.\n state.amount = options.defaultAmount;\n const selected = doc.regions.find((r) => r.id === state.selected) ?? null;\n const target = selected ?? null;\n const mode = target?.mode ?? state.mode;\n const setMode = (m: RedactMode) => {\n state.mode = m;\n if (target) ctx.dispatch({ type: 'redact.update', id: opId(), regionId: target.id, mode: m });\n else ctx.refresh();\n };\n // The mode is a setting of the shape, so it sits above it; the shape is the\n // choice and takes the bottom row with the other tools' choosers.\n return html`\n ${\n options.modes.length > 1\n ? html`<div class=\"row\" role=\"group\" aria-label=${ctx.t('redact.mode')}>\n <div class=\"group\">\n ${options.modes.map(\n (m) =>\n html`<sealpixel-button data-mode=${m} ?pressed=${mode === m} @click=${() => setMode(m)}>${ctx.t(`redact.mode.${m}`)}</sealpixel-button>`,\n )}\n </div>\n </div>`\n : nothing\n }\n ${\n options.shapes.length > 1\n ? html`<div class=\"row choice\" role=\"group\" aria-label=${ctx.t('redact.shape')}>\n <div class=\"group\">\n ${options.shapes.map(\n (shape) =>\n html`<sealpixel-button data-shape=${shape} ?pressed=${state.shape === shape} @click=${() => {\n state.shape = shape;\n ctx.refresh();\n }}>${ctx.t(`redact.shape.${shape}`)}</sealpixel-button>`,\n )}\n </div>\n </div>`\n : nothing\n }\n `;\n },\n overlay: (ctx: UiToolContext) => {\n const doc = (ctx.document as unknown as { redact: RedactDoc }).redact;\n const { width: W, height: H, zoom } = ctx.stage;\n if (!W || !H) return svg``;\n const sw = 1.5 / zoom;\n const toN = (e: PointerEvent): [number, number] => {\n const p = ctx.stage.toImage(e.clientX, e.clientY);\n return [clamp01(p.x / W), clamp01(p.y / H)];\n };\n const down = (e: PointerEvent) => {\n if ((e.target as Element).hasAttribute('data-region')) return;\n e.stopPropagation();\n e.preventDefault();\n const p = toN(e);\n state.drawing = { start: p, current: p, points: [p] };\n const move = (ev: PointerEvent) => {\n if (!state.drawing) return;\n const q = toN(ev);\n state.drawing.current = q;\n const last = state.drawing.points[state.drawing.points.length - 1] as [number, number];\n if (Math.hypot(q[0] - last[0], q[1] - last[1]) > 0.004) state.drawing.points.push(q);\n ctx.refresh();\n };\n const cleanup = () => {\n window.removeEventListener('pointermove', move);\n window.removeEventListener('pointerup', up);\n window.removeEventListener('pointercancel', up);\n window.removeEventListener('keydown', cancel);\n };\n // Escape while drawing drops the shape: nothing reaches the log.\n const cancel = (ev: KeyboardEvent) => {\n if (ev.key !== 'Escape') return;\n state.drawing = null;\n cleanup();\n ctx.refresh();\n };\n const up = () => {\n cleanup();\n const d = state.drawing;\n state.drawing = null;\n if (!d) return;\n let region: Region | null = null;\n if (state.shape === 'rect') {\n const x = Math.min(d.start[0], d.current[0]);\n const y = Math.min(d.start[1], d.current[1]);\n const width = Math.abs(d.current[0] - d.start[0]);\n const height = Math.abs(d.current[1] - d.start[1]);\n if (width > 0.01 && height > 0.01)\n region = { kind: 'rect', rect: { x, y, width, height } };\n } else if (d.points.length >= 3) {\n region = { kind: 'path', points: d.points };\n }\n if (region) {\n const id = opId();\n const amount = ctx.options<RedactOptions>('redact')?.defaultAmount ?? state.amount;\n ctx.dispatch({ type: 'redact.add', id, region, mode: state.mode, amount });\n state.selected = id;\n state.focusPending = id;\n }\n ctx.refresh();\n };\n window.addEventListener('pointermove', move);\n window.addEventListener('pointerup', up);\n window.addEventListener('pointercancel', up);\n window.addEventListener('keydown', cancel);\n };\n const options = ctx.options<RedactOptions>('redact') ?? REDACT_DEFAULT_OPTIONS;\n const shown = (r: Redaction): Region =>\n state.transform?.id === r.id\n ? state.transform.region\n : state.drag?.id === r.id\n ? (state.drag.region as Region)\n : r.region;\n const shape = (r: Redaction, i: number) => {\n const selected = state.selected === r.id;\n const dragging = state.drag?.id === r.id || state.transform?.id === r.id;\n const region = shown(r);\n const stroke = selected ? 'var(--sealpixel-color-accent)' : 'rgba(255,255,255,0.9)';\n const fill = dragging ? 'rgba(91,141,239,0.25)' : 'rgba(255,255,255,0.08)';\n // Press selects; moving the pointer drags the region and commits one update on release.\n const pick = (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n state.selected = r.id;\n // preventDefault above keeps the browser from focusing the region.\n (e.currentTarget as SVGElement).focus({ preventScroll: true });\n const start = toN(e);\n state.drag = { id: r.id, region: r.region, start };\n const move = (ev: PointerEvent) => {\n if (!state.drag) return;\n const q = toN(ev);\n state.drag.region = translateRegion(r.region, q[0] - start[0], q[1] - start[1]);\n ctx.refresh();\n };\n const up = () => {\n window.removeEventListener('pointermove', move);\n window.removeEventListener('pointerup', up);\n window.removeEventListener('pointercancel', up);\n const d = state.drag;\n state.drag = null;\n if (d && JSON.stringify(d.region) !== JSON.stringify(r.region)) {\n ctx.dispatch({ type: 'redact.update', id: opId(), regionId: r.id, region: d.region });\n }\n ctx.refresh();\n };\n window.addEventListener('pointermove', move);\n window.addEventListener('pointerup', up);\n window.addEventListener('pointercancel', up);\n };\n // The keyboard moves the region through the same transient drag as the\n // pointer and commits one update when the key is released.\n const commit = () => {\n const d = state.drag;\n if (!d?.keys || d.id !== r.id) return;\n state.drag = null;\n if (JSON.stringify(d.region) !== JSON.stringify(r.region)) {\n ctx.dispatch({ type: 'redact.update', id: opId(), regionId: r.id, region: d.region });\n }\n ctx.refresh();\n };\n const keys = elementKeys(ctx.stage, {\n select: () => {\n if (state.selected === r.id) return;\n state.selected = r.id;\n ctx.refresh();\n },\n move: (dx, dy) => {\n if (state.drawing || state.transform || (state.drag && !state.drag.keys)) return;\n const base = state.drag?.id === r.id ? state.drag.region : r.region;\n state.drag = {\n id: r.id,\n region: translateRegion(base, dx, dy),\n start: [0, 0],\n keys: true,\n };\n ctx.refresh();\n },\n commit,\n remove: (el) => {\n commit();\n // Focus moves on before the region goes, so Tab stays in the editor.\n const next = doc.regions[i + 1] ?? doc.regions[i - 1] ?? null;\n state.selected = next?.id ?? null;\n state.focusPending = next?.id ?? null;\n if (!next) focusEditor(el);\n ctx.dispatch({ type: 'redact.remove', id: opId(), regionId: r.id });\n },\n escape: () => {\n // Mid-drawing the key belongs to the drawing: the canvas listener drops it.\n if (state.drawing) return false;\n const open = state.selected !== null || !!state.drag?.keys;\n if (state.drag?.keys) state.drag = null;\n state.selected = null;\n ctx.refresh();\n return open;\n },\n });\n const label = ctx.t('redact.region', { n: i + 1 });\n if (region.kind === 'rect') {\n const q = region.rect;\n return svg`<rect data-interactive data-region=${r.id} tabindex=\"0\" role=\"button\" aria-pressed=${selected ? 'true' : 'false'} aria-label=${label} ${focusWhen(state, r.id)} x=${q.x * W} y=${q.y * H} width=${q.width * W} height=${q.height * H} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style=\"cursor:move\" @pointerdown=${pick} @focus=${keys.focus} @blur=${keys.blur} @keydown=${keys.keydown} @keyup=${keys.keyup} />`;\n }\n const d = region.points\n .map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0] * W} ${p[1] * H}`)\n .join(' ');\n return svg`<path data-interactive data-region=${r.id} tabindex=\"0\" role=\"button\" aria-pressed=${selected ? 'true' : 'false'} aria-label=${label} ${focusWhen(state, r.id)} d=${`${d} Z`} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${`${4 / zoom} ${3 / zoom}`} style=\"cursor:move\" @pointerdown=${pick} @focus=${keys.focus} @blur=${keys.blur} @keydown=${keys.keydown} @keyup=${keys.keyup} />`;\n };\n const selectedRegion = doc.regions.find((r) => r.id === state.selected) ?? null;\n const regionBox = (r: Redaction): Rect => {\n const region = shown(r);\n return region.kind === 'rect' ? region.rect : pointsBox(region.points);\n };\n // Handles on the selected region: eight to resize, one below to turn. A\n // drag maps the pointer through the region's frame and commits one\n // update on release; see region-transform.ts for what the log gets.\n const transformHandles = (r: Redaction) => {\n const frame = describe(shown(r), W, H);\n const c = corners(frame);\n const mid = (a: [number, number], b: [number, number]): [number, number] => [\n (a[0] + b[0]) / 2,\n (a[1] + b[1]) / 2,\n ];\n const at: [ResizeHandle, [number, number]][] = [\n ['nw', c[0] as [number, number]],\n ['n', mid(c[0] as [number, number], c[1] as [number, number])],\n ['ne', c[1] as [number, number]],\n ['e', mid(c[1] as [number, number], c[2] as [number, number])],\n ['se', c[2] as [number, number]],\n ['s', mid(c[2] as [number, number], c[3] as [number, number])],\n ['sw', c[3] as [number, number]],\n ['w', mid(c[3] as [number, number], c[0] as [number, number])],\n ];\n const cos = Math.cos(frame.rotation);\n const sin = Math.sin(frame.rotation);\n const stem = 28 / zoom;\n const bottom = mid(c[2] as [number, number], c[3] as [number, number]);\n const knob: [number, number] = [bottom[0] - sin * stem, bottom[1] + cos * stem];\n const degrees = Math.round((frame.rotation * 180) / Math.PI);\n const hr = 7 / zoom;\n const begin = (handle: ResizeHandle | 'rotate') => (e: PointerEvent) => {\n e.stopPropagation();\n e.preventDefault();\n const start = ctx.stage.toImage(e.clientX, e.clientY);\n const origin = r.region;\n const from = describe(origin, W, H);\n const startAngle = Math.atan2(start.y - from.cy, start.x - from.cx);\n state.transform = { id: r.id, origin, from, region: origin };\n const move = (ev: PointerEvent) => {\n if (!state.transform) return;\n const q = ctx.stage.toImage(ev.clientX, ev.clientY);\n const next =\n handle === 'rotate'\n ? {\n ...from,\n rotation: snapAngle(\n from.rotation + Math.atan2(q.y - from.cy, q.x - from.cx) - startAngle,\n ),\n }\n : resize(from, handle, q.x - start.x, q.y - start.y, 6 / zoom);\n const region = transformRegion(origin, from, next, W, H);\n if (region) state.transform.region = region;\n ctx.refresh();\n };\n const up = () => {\n window.removeEventListener('pointermove', move);\n window.removeEventListener('pointerup', up);\n window.removeEventListener('pointercancel', up);\n const t = state.transform;\n state.transform = null;\n if (t && JSON.stringify(t.region) !== JSON.stringify(origin)) {\n ctx.dispatch({ type: 'redact.update', id: opId(), regionId: r.id, region: t.region });\n }\n ctx.refresh();\n };\n window.addEventListener('pointermove', move);\n window.addEventListener('pointerup', up);\n window.addEventListener('pointercancel', up);\n };\n const cursor: Record<ResizeHandle, string> = {\n nw: 'nwse-resize',\n se: 'nwse-resize',\n ne: 'nesw-resize',\n sw: 'nesw-resize',\n n: 'ns-resize',\n s: 'ns-resize',\n e: 'ew-resize',\n w: 'ew-resize',\n };\n return svg`\n <line x1=${bottom[0]} y1=${bottom[1]} x2=${knob[0]} y2=${knob[1]} stroke=\"var(--sealpixel-color-accent)\" stroke-width=${sw} pointer-events=\"none\" />\n ${at.map(\n ([id, p]) =>\n svg`<circle data-interactive data-handle=${id} cx=${p[0]} cy=${p[1]} r=${hr} fill=\"white\" stroke=\"var(--sealpixel-color-accent)\" stroke-width=${sw} style=${`cursor:${cursor[id]}`} @pointerdown=${begin(id)} />`,\n )}\n <circle data-interactive data-handle=\"rotate\" role=\"slider\" aria-label=${ctx.t('redact.rotate')} aria-valuemin=\"-180\" aria-valuemax=\"180\" aria-valuenow=${degrees} aria-valuetext=${`${degrees}°`} cx=${knob[0]} cy=${knob[1]} r=${hr * 1.15} fill=\"var(--sealpixel-color-accent)\" stroke=\"white\" stroke-width=${sw} style=\"cursor:grab\" @pointerdown=${begin('rotate')} />\n `;\n };\n const drawing = state.drawing;\n let live = svg``;\n if (drawing) {\n if (state.shape === 'rect') {\n const x = Math.min(drawing.start[0], drawing.current[0]) * W;\n const y = Math.min(drawing.start[1], drawing.current[1]) * H;\n live = svg`<rect x=${x} y=${y} width=${Math.abs(drawing.current[0] - drawing.start[0]) * W} height=${Math.abs(drawing.current[1] - drawing.start[1]) * H} fill=\"rgba(91,141,239,0.2)\" stroke=\"var(--sealpixel-color-accent)\" stroke-width=${sw} />`;\n } else {\n const d = drawing.points\n .map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0] * W} ${p[1] * H}`)\n .join(' ');\n live = svg`<path d=${d} fill=\"rgba(91,141,239,0.2)\" stroke=\"var(--sealpixel-color-accent)\" stroke-width=${sw} />`;\n }\n }\n return svg`\n <rect data-interactive data-canvas x=\"0\" y=\"0\" width=${W} height=${H} fill=\"transparent\" style=\"cursor:crosshair\" @pointerdown=${down} />\n ${doc.regions.map(shape)}\n ${selectedRegion && options.transform ? transformHandles(selectedRegion) : nothing}\n ${\n selectedRegion\n ? deleteHandle(\n toPx(regionBox(selectedRegion), W, H),\n ctx.stage,\n ctx.t('redact.remove'),\n () => {\n state.selected = null;\n ctx.dispatch({ type: 'redact.remove', id: opId(), regionId: selectedRegion.id });\n },\n )\n : nothing\n }\n ${live}\n `;\n },\n};\n\nfunction clamp01(v: number): number {\n return clamp(v, 0, 1);\n}\nfunction clamp(v: number, lo: number, hi: number): number {\n return v < lo ? lo : v > hi ? hi : v;\n}\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resizing and turning a redaction region after it is drawn.
|
|
3
|
+
*
|
|
4
|
+
* A region is a rectangle or a path in normalised image space. Both are
|
|
5
|
+
* handled through one frame: centre, size and rotation about the centre, in
|
|
6
|
+
* preview pixels, because a turn is only a turn in a space with square
|
|
7
|
+
* pixels. A rectangle is a frame with no rotation; a path of four points that
|
|
8
|
+
* form a rectangle is a frame with one; any other path is its bounding box.
|
|
9
|
+
*
|
|
10
|
+
* What goes back into the log needs no new operation: a resized rectangle
|
|
11
|
+
* stays a `rect`, a turned one becomes a `path` with its four corners, and a
|
|
12
|
+
* freeform path keeps its points, mapped through the frame. A turn that lands
|
|
13
|
+
* on a quarter is a rectangle again.
|
|
14
|
+
*/
|
|
15
|
+
import type { Rect } from '@sealpixel/core';
|
|
16
|
+
export type Region = {
|
|
17
|
+
kind: 'rect';
|
|
18
|
+
rect: Rect;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'path';
|
|
21
|
+
points: [number, number][];
|
|
22
|
+
};
|
|
23
|
+
export type ResizeHandle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w';
|
|
24
|
+
/** A region's frame in preview pixels. `rotation` is radians, clockwise on screen. */
|
|
25
|
+
export interface Frame {
|
|
26
|
+
cx: number;
|
|
27
|
+
cy: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
rotation: number;
|
|
31
|
+
}
|
|
32
|
+
type Px = [number, number];
|
|
33
|
+
/** The frame of a region on a preview of `W` by `H` pixels. */
|
|
34
|
+
export declare function describe(region: Region, W: number, H: number): Frame;
|
|
35
|
+
/**
|
|
36
|
+
* The frame of four points that form a rectangle — equal opposite sides and a
|
|
37
|
+
* right angle, within a thousandth — or null. The first edge sets the rotation.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rectangleFrame(pts: readonly Px[]): Frame | null;
|
|
40
|
+
/** The frame's corners in preview pixels: north-west, north-east, south-east, south-west. */
|
|
41
|
+
export declare function corners(f: Frame): Px[];
|
|
42
|
+
/**
|
|
43
|
+
* A handle dragged by `dx`, `dy` preview pixels. The delta is taken in the
|
|
44
|
+
* frame's own axes, so a corner of a turned box follows the pointer along its
|
|
45
|
+
* turned edges; the opposite edge stays; neither side shrinks below `min`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resize(f: Frame, handle: ResizeHandle, dx: number, dy: number, min?: number): Frame;
|
|
48
|
+
/** A rotation within `tolerance` of a quarter turn snaps to it, so a box can become a plain rectangle again. */
|
|
49
|
+
export declare function snapAngle(rotation: number, tolerance?: number): number;
|
|
50
|
+
/** True when the rotation is a multiple of a quarter turn: the box is axis-aligned. */
|
|
51
|
+
export declare function isAxisAligned(rotation: number): boolean;
|
|
52
|
+
/** Points in preview pixels, mapped from one frame into another: scaled along the old axes, turned to the new ones. */
|
|
53
|
+
export declare function mapPoints(pts: readonly Px[], from: Frame, to: Frame): Px[];
|
|
54
|
+
/**
|
|
55
|
+
* Points moved by `dx`, `dy` in unit space, the move shortened so that no
|
|
56
|
+
* point leaves the unit square. Every point moves by the same amount: the
|
|
57
|
+
* shape is kept and stops at the edge. A point already outside pins its axis.
|
|
58
|
+
*/
|
|
59
|
+
export declare function slide(pts: readonly Px[], dx: number, dy: number): Px[];
|
|
60
|
+
/**
|
|
61
|
+
* The region a frame stands for, in normalised image space, given the region
|
|
62
|
+
* it was made from and that region's frame. A rectangle or a rectangular path
|
|
63
|
+
* becomes the frame's four corners — a `rect` when the frame is axis-aligned,
|
|
64
|
+
* a `path` otherwise. A freeform path keeps its points, mapped from the old
|
|
65
|
+
* frame into the new one. Null when a point would leave the image: the caller
|
|
66
|
+
* keeps the last region that fit.
|
|
67
|
+
*/
|
|
68
|
+
export declare function transformRegion(origin: Region, from: Frame, to: Frame, W: number, H: number): Region | null;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
const RIGHT_ANGLE = Math.PI / 2;
|
|
2
|
+
/** The frame of a region on a preview of `W` by `H` pixels. */
|
|
3
|
+
export function describe(region, W, H) {
|
|
4
|
+
if (region.kind === 'rect') {
|
|
5
|
+
const r = region.rect;
|
|
6
|
+
return {
|
|
7
|
+
cx: (r.x + r.width / 2) * W,
|
|
8
|
+
cy: (r.y + r.height / 2) * H,
|
|
9
|
+
width: r.width * W,
|
|
10
|
+
height: r.height * H,
|
|
11
|
+
rotation: 0,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const pts = region.points.map((p) => [p[0] * W, p[1] * H]);
|
|
15
|
+
const rect = rectangleFrame(pts);
|
|
16
|
+
if (rect)
|
|
17
|
+
return rect;
|
|
18
|
+
let x0 = Number.POSITIVE_INFINITY;
|
|
19
|
+
let y0 = Number.POSITIVE_INFINITY;
|
|
20
|
+
let x1 = Number.NEGATIVE_INFINITY;
|
|
21
|
+
let y1 = Number.NEGATIVE_INFINITY;
|
|
22
|
+
for (const [x, y] of pts) {
|
|
23
|
+
x0 = Math.min(x0, x);
|
|
24
|
+
y0 = Math.min(y0, y);
|
|
25
|
+
x1 = Math.max(x1, x);
|
|
26
|
+
y1 = Math.max(y1, y);
|
|
27
|
+
}
|
|
28
|
+
return { cx: (x0 + x1) / 2, cy: (y0 + y1) / 2, width: x1 - x0, height: y1 - y0, rotation: 0 };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The frame of four points that form a rectangle — equal opposite sides and a
|
|
32
|
+
* right angle, within a thousandth — or null. The first edge sets the rotation.
|
|
33
|
+
*/
|
|
34
|
+
export function rectangleFrame(pts) {
|
|
35
|
+
if (pts.length !== 4)
|
|
36
|
+
return null;
|
|
37
|
+
const edge = (i) => {
|
|
38
|
+
const a = pts[i];
|
|
39
|
+
const b = pts[(i + 1) % 4];
|
|
40
|
+
return [b[0] - a[0], b[1] - a[1]];
|
|
41
|
+
};
|
|
42
|
+
const e = [edge(0), edge(1), edge(2), edge(3)];
|
|
43
|
+
const len = e.map((v) => Math.hypot(v[0], v[1]));
|
|
44
|
+
const size = Math.max(len[0], len[1], 1);
|
|
45
|
+
const tol = 1e-3 * size;
|
|
46
|
+
if (Math.abs(len[0] - len[2]) > tol)
|
|
47
|
+
return null;
|
|
48
|
+
if (Math.abs(len[1] - len[3]) > tol)
|
|
49
|
+
return null;
|
|
50
|
+
const dot = e[0][0] * e[1][0] + e[0][1] * e[1][1];
|
|
51
|
+
if (Math.abs(dot) > tol * size)
|
|
52
|
+
return null;
|
|
53
|
+
if (len[0] < 1e-9 || len[1] < 1e-9)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
cx: pts.reduce((s, p) => s + p[0], 0) / 4,
|
|
57
|
+
cy: pts.reduce((s, p) => s + p[1], 0) / 4,
|
|
58
|
+
width: len[0],
|
|
59
|
+
height: len[1],
|
|
60
|
+
rotation: Math.atan2(e[0][1], e[0][0]),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** The frame's corners in preview pixels: north-west, north-east, south-east, south-west. */
|
|
64
|
+
export function corners(f) {
|
|
65
|
+
const cos = Math.cos(f.rotation);
|
|
66
|
+
const sin = Math.sin(f.rotation);
|
|
67
|
+
const hw = f.width / 2;
|
|
68
|
+
const hh = f.height / 2;
|
|
69
|
+
return [
|
|
70
|
+
[-hw, -hh],
|
|
71
|
+
[hw, -hh],
|
|
72
|
+
[hw, hh],
|
|
73
|
+
[-hw, hh],
|
|
74
|
+
].map(([x, y]) => [f.cx + x * cos - y * sin, f.cy + x * sin + y * cos]);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A handle dragged by `dx`, `dy` preview pixels. The delta is taken in the
|
|
78
|
+
* frame's own axes, so a corner of a turned box follows the pointer along its
|
|
79
|
+
* turned edges; the opposite edge stays; neither side shrinks below `min`.
|
|
80
|
+
*/
|
|
81
|
+
export function resize(f, handle, dx, dy, min = 6) {
|
|
82
|
+
const cos = Math.cos(f.rotation);
|
|
83
|
+
const sin = Math.sin(f.rotation);
|
|
84
|
+
const lx = dx * cos + dy * sin;
|
|
85
|
+
const ly = -dx * sin + dy * cos;
|
|
86
|
+
let left = -f.width / 2;
|
|
87
|
+
let right = f.width / 2;
|
|
88
|
+
let top = -f.height / 2;
|
|
89
|
+
let bottom = f.height / 2;
|
|
90
|
+
if (handle.includes('w'))
|
|
91
|
+
left = Math.min(left + lx, right - min);
|
|
92
|
+
if (handle.includes('e'))
|
|
93
|
+
right = Math.max(right + lx, left + min);
|
|
94
|
+
if (handle.includes('n'))
|
|
95
|
+
top = Math.min(top + ly, bottom - min);
|
|
96
|
+
if (handle.includes('s'))
|
|
97
|
+
bottom = Math.max(bottom + ly, top + min);
|
|
98
|
+
const mx = (left + right) / 2;
|
|
99
|
+
const my = (top + bottom) / 2;
|
|
100
|
+
return {
|
|
101
|
+
cx: f.cx + mx * cos - my * sin,
|
|
102
|
+
cy: f.cy + mx * sin + my * cos,
|
|
103
|
+
width: right - left,
|
|
104
|
+
height: bottom - top,
|
|
105
|
+
rotation: f.rotation,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** A rotation within `tolerance` of a quarter turn snaps to it, so a box can become a plain rectangle again. */
|
|
109
|
+
export function snapAngle(rotation, tolerance = (2 * Math.PI) / 180) {
|
|
110
|
+
const quarter = Math.round(rotation / RIGHT_ANGLE) * RIGHT_ANGLE;
|
|
111
|
+
return Math.abs(rotation - quarter) <= tolerance ? quarter : rotation;
|
|
112
|
+
}
|
|
113
|
+
/** True when the rotation is a multiple of a quarter turn: the box is axis-aligned. */
|
|
114
|
+
export function isAxisAligned(rotation) {
|
|
115
|
+
const r = rotation / RIGHT_ANGLE;
|
|
116
|
+
return Math.abs(r - Math.round(r)) < 1e-9;
|
|
117
|
+
}
|
|
118
|
+
/** Points in preview pixels, mapped from one frame into another: scaled along the old axes, turned to the new ones. */
|
|
119
|
+
export function mapPoints(pts, from, to) {
|
|
120
|
+
const cos0 = Math.cos(from.rotation);
|
|
121
|
+
const sin0 = Math.sin(from.rotation);
|
|
122
|
+
const cos1 = Math.cos(to.rotation);
|
|
123
|
+
const sin1 = Math.sin(to.rotation);
|
|
124
|
+
const sx = from.width > 0 ? to.width / from.width : 1;
|
|
125
|
+
const sy = from.height > 0 ? to.height / from.height : 1;
|
|
126
|
+
return pts.map((p) => {
|
|
127
|
+
const x = p[0] - from.cx;
|
|
128
|
+
const y = p[1] - from.cy;
|
|
129
|
+
const lx = (x * cos0 + y * sin0) * sx;
|
|
130
|
+
const ly = (-x * sin0 + y * cos0) * sy;
|
|
131
|
+
return [to.cx + lx * cos1 - ly * sin1, to.cy + lx * sin1 + ly * cos1];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Points moved by `dx`, `dy` in unit space, the move shortened so that no
|
|
136
|
+
* point leaves the unit square. Every point moves by the same amount: the
|
|
137
|
+
* shape is kept and stops at the edge. A point already outside pins its axis.
|
|
138
|
+
*/
|
|
139
|
+
export function slide(pts, dx, dy) {
|
|
140
|
+
const xs = pts.map((p) => p[0]);
|
|
141
|
+
const ys = pts.map((p) => p[1]);
|
|
142
|
+
const within = (d, lo, hi) => lo > hi ? 0 : Math.min(hi, Math.max(lo, d));
|
|
143
|
+
const mx = within(dx, -Math.min(...xs), 1 - Math.max(...xs));
|
|
144
|
+
const my = within(dy, -Math.min(...ys), 1 - Math.max(...ys));
|
|
145
|
+
return pts.map((p) => [p[0] + mx, p[1] + my]);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The region a frame stands for, in normalised image space, given the region
|
|
149
|
+
* it was made from and that region's frame. A rectangle or a rectangular path
|
|
150
|
+
* becomes the frame's four corners — a `rect` when the frame is axis-aligned,
|
|
151
|
+
* a `path` otherwise. A freeform path keeps its points, mapped from the old
|
|
152
|
+
* frame into the new one. Null when a point would leave the image: the caller
|
|
153
|
+
* keeps the last region that fit.
|
|
154
|
+
*/
|
|
155
|
+
export function transformRegion(origin, from, to, W, H) {
|
|
156
|
+
const rectangular = origin.kind === 'rect' ||
|
|
157
|
+
rectangleFrame(origin.points.map((p) => [p[0] * W, p[1] * H])) !== null;
|
|
158
|
+
let pts;
|
|
159
|
+
if (rectangular) {
|
|
160
|
+
pts = corners(to);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
pts = mapPoints(origin.points.map((p) => [
|
|
164
|
+
p[0] * W,
|
|
165
|
+
p[1] * H,
|
|
166
|
+
]), from, to);
|
|
167
|
+
}
|
|
168
|
+
const eps = 1e-9;
|
|
169
|
+
const norm = [];
|
|
170
|
+
for (const [x, y] of pts) {
|
|
171
|
+
const u = x / W;
|
|
172
|
+
const v = y / H;
|
|
173
|
+
if (u < -eps || u > 1 + eps || v < -eps || v > 1 + eps)
|
|
174
|
+
return null;
|
|
175
|
+
norm.push([clamp01(u), clamp01(v)]);
|
|
176
|
+
}
|
|
177
|
+
if (rectangular && isAxisAligned(to.rotation)) {
|
|
178
|
+
const xs = norm.map((p) => p[0]);
|
|
179
|
+
const ys = norm.map((p) => p[1]);
|
|
180
|
+
const x = Math.min(...xs);
|
|
181
|
+
const y = Math.min(...ys);
|
|
182
|
+
return {
|
|
183
|
+
kind: 'rect',
|
|
184
|
+
rect: { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y },
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return { kind: 'path', points: norm };
|
|
188
|
+
}
|
|
189
|
+
function clamp01(v) {
|
|
190
|
+
return v < 0 ? 0 : v > 1 ? 1 : v;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=region-transform.js.map
|