@sealpixel/ui 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +59 -0
- package/README.md +10 -0
- package/dist/components/lumbra-button.d.ts +28 -0
- package/dist/components/lumbra-button.d.ts.map +1 -0
- package/dist/components/lumbra-button.js +87 -0
- package/dist/components/lumbra-button.js.map +1 -0
- package/dist/components/lumbra-editor.d.ts +226 -0
- package/dist/components/lumbra-editor.d.ts.map +1 -0
- package/dist/components/lumbra-editor.js +873 -0
- package/dist/components/lumbra-editor.js.map +1 -0
- package/dist/components/lumbra-nav.d.ts +48 -0
- package/dist/components/lumbra-nav.d.ts.map +1 -0
- package/dist/components/lumbra-nav.js +159 -0
- package/dist/components/lumbra-nav.js.map +1 -0
- package/dist/components/lumbra-slider.d.ts +48 -0
- package/dist/components/lumbra-slider.d.ts.map +1 -0
- package/dist/components/lumbra-slider.js +168 -0
- package/dist/components/lumbra-slider.js.map +1 -0
- package/dist/components/lumbra-stage.d.ts +92 -0
- package/dist/components/lumbra-stage.d.ts.map +1 -0
- package/dist/components/lumbra-stage.js +344 -0
- package/dist/components/lumbra-stage.js.map +1 -0
- package/dist/components/lumbra-toolbar.d.ts +30 -0
- package/dist/components/lumbra-toolbar.d.ts.map +1 -0
- package/dist/components/lumbra-toolbar.js +127 -0
- package/dist/components/lumbra-toolbar.js.map +1 -0
- package/dist/components/pincel-button.d.ts +28 -0
- package/dist/components/pincel-button.d.ts.map +1 -0
- package/dist/components/pincel-button.js +87 -0
- package/dist/components/pincel-button.js.map +1 -0
- package/dist/components/pincel-editor.d.ts +195 -0
- package/dist/components/pincel-editor.d.ts.map +1 -0
- package/dist/components/pincel-editor.js +794 -0
- package/dist/components/pincel-editor.js.map +1 -0
- package/dist/components/pincel-nav.d.ts +33 -0
- package/dist/components/pincel-nav.d.ts.map +1 -0
- package/dist/components/pincel-nav.js +147 -0
- package/dist/components/pincel-nav.js.map +1 -0
- package/dist/components/pincel-slider.d.ts +48 -0
- package/dist/components/pincel-slider.d.ts.map +1 -0
- package/dist/components/pincel-slider.js +168 -0
- package/dist/components/pincel-slider.js.map +1 -0
- package/dist/components/pincel-stage.d.ts +66 -0
- package/dist/components/pincel-stage.d.ts.map +1 -0
- package/dist/components/pincel-stage.js +233 -0
- package/dist/components/pincel-stage.js.map +1 -0
- package/dist/components/pincel-toolbar.d.ts +30 -0
- package/dist/components/pincel-toolbar.d.ts.map +1 -0
- package/dist/components/pincel-toolbar.js +127 -0
- package/dist/components/pincel-toolbar.js.map +1 -0
- package/dist/components/sealpixel-button.d.ts +28 -0
- package/dist/components/sealpixel-button.d.ts.map +1 -0
- package/dist/components/sealpixel-button.js +117 -0
- package/dist/components/sealpixel-button.js.map +1 -0
- package/dist/components/sealpixel-editor.d.ts +226 -0
- package/dist/components/sealpixel-editor.d.ts.map +1 -0
- package/dist/components/sealpixel-editor.js +1245 -0
- package/dist/components/sealpixel-editor.js.map +1 -0
- package/dist/components/sealpixel-nav.d.ts +48 -0
- package/dist/components/sealpixel-nav.d.ts.map +1 -0
- package/dist/components/sealpixel-nav.js +159 -0
- package/dist/components/sealpixel-nav.js.map +1 -0
- package/dist/components/sealpixel-slider.d.ts +75 -0
- package/dist/components/sealpixel-slider.d.ts.map +1 -0
- package/dist/components/sealpixel-slider.js +269 -0
- package/dist/components/sealpixel-slider.js.map +1 -0
- package/dist/components/sealpixel-stage.d.ts +118 -0
- package/dist/components/sealpixel-stage.d.ts.map +1 -0
- package/dist/components/sealpixel-stage.js +409 -0
- package/dist/components/sealpixel-stage.js.map +1 -0
- package/dist/components/sealpixel-stepper.d.ts +69 -0
- package/dist/components/sealpixel-stepper.d.ts.map +1 -0
- package/dist/components/sealpixel-stepper.js +248 -0
- package/dist/components/sealpixel-stepper.js.map +1 -0
- package/dist/components/sealpixel-toolbar.d.ts +30 -0
- package/dist/components/sealpixel-toolbar.d.ts.map +1 -0
- package/dist/components/sealpixel-toolbar.js +149 -0
- package/dist/components/sealpixel-toolbar.js.map +1 -0
- package/dist/controllers/gesture-controller.d.ts +65 -0
- package/dist/controllers/gesture-controller.d.ts.map +1 -0
- package/dist/controllers/gesture-controller.js +125 -0
- package/dist/controllers/gesture-controller.js.map +1 -0
- package/dist/controllers/session-controller.d.ts +15 -0
- package/dist/controllers/session-controller.d.ts.map +1 -0
- package/dist/controllers/session-controller.js +37 -0
- package/dist/controllers/session-controller.js.map +1 -0
- package/dist/define.d.ts +21 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +27 -0
- package/dist/define.js.map +1 -0
- package/dist/i18n.d.ts +11 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +27 -0
- package/dist/i18n.js.map +1 -0
- package/dist/icons.d.ts +32 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +45 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/de.d.ts +3 -0
- package/dist/locales/de.d.ts.map +1 -0
- package/dist/locales/de.js +132 -0
- package/dist/locales/de.js.map +1 -0
- package/dist/locales/en.d.ts +3 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/en.js +132 -0
- package/dist/locales/en.js.map +1 -0
- package/dist/locales/es.d.ts +3 -0
- package/dist/locales/es.d.ts.map +1 -0
- package/dist/locales/es.js +132 -0
- package/dist/locales/es.js.map +1 -0
- package/dist/locales/fr.d.ts +3 -0
- package/dist/locales/fr.d.ts.map +1 -0
- package/dist/locales/fr.js +132 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/index.d.ts +6 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +13 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/locales/ja.d.ts +3 -0
- package/dist/locales/ja.d.ts.map +1 -0
- package/dist/locales/ja.js +132 -0
- package/dist/locales/ja.js.map +1 -0
- package/dist/locales/pt.d.ts +3 -0
- package/dist/locales/pt.d.ts.map +1 -0
- package/dist/locales/pt.js +132 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/theme.d.ts +19 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +150 -0
- package/dist/theme.js.map +1 -0
- package/dist/tool.d.ts +70 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +2 -0
- package/dist/tool.js.map +1 -0
- package/dist/tools/annotate.d.ts +3 -0
- package/dist/tools/annotate.d.ts.map +1 -0
- package/dist/tools/annotate.js +436 -0
- package/dist/tools/annotate.js.map +1 -0
- package/dist/tools/crop-mask.d.ts +29 -0
- package/dist/tools/crop-mask.d.ts.map +1 -0
- package/dist/tools/crop-mask.js +75 -0
- package/dist/tools/crop-mask.js.map +1 -0
- package/dist/tools/crop.d.ts +11 -0
- package/dist/tools/crop.d.ts.map +1 -0
- package/dist/tools/crop.js +361 -0
- package/dist/tools/crop.js.map +1 -0
- package/dist/tools/delete-handle.d.ts +18 -0
- package/dist/tools/delete-handle.d.ts.map +1 -0
- package/dist/tools/delete-handle.js +61 -0
- package/dist/tools/delete-handle.js.map +1 -0
- package/dist/tools/filter.d.ts +3 -0
- package/dist/tools/filter.d.ts.map +1 -0
- package/dist/tools/filter.js +174 -0
- package/dist/tools/filter.js.map +1 -0
- package/dist/tools/finetune.d.ts +11 -0
- package/dist/tools/finetune.d.ts.map +1 -0
- package/dist/tools/finetune.js +98 -0
- package/dist/tools/finetune.js.map +1 -0
- package/dist/tools/frame.d.ts +3 -0
- package/dist/tools/frame.d.ts.map +1 -0
- package/dist/tools/frame.js +57 -0
- package/dist/tools/frame.js.map +1 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +41 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/redact.d.ts +3 -0
- package/dist/tools/redact.d.ts.map +1 -0
- package/dist/tools/redact.js +252 -0
- package/dist/tools/redact.js.map +1 -0
- package/dist/tools/resize.d.ts +3 -0
- package/dist/tools/resize.d.ts.map +1 -0
- package/dist/tools/resize.js +91 -0
- package/dist/tools/resize.js.map +1 -0
- package/dist/tools/sticker.d.ts +8 -0
- package/dist/tools/sticker.d.ts.map +1 -0
- package/dist/tools/sticker.js +156 -0
- package/dist/tools/sticker.js.map +1 -0
- package/dist/tools/watermark.d.ts +3 -0
- package/dist/tools/watermark.d.ts.map +1 -0
- package/dist/tools/watermark.js +102 -0
- package/dist/tools/watermark.js.map +1 -0
- package/dist/view-mapping.d.ts +23 -0
- package/dist/view-mapping.d.ts.map +1 -0
- package/dist/view-mapping.js +72 -0
- package/dist/view-mapping.js.map +1 -0
- package/package.json +55 -0
- package/themes/default.css +23 -0
- package/themes/high-contrast.css +30 -0
- package/themes/minimal.css +32 -0
- package/themes/nocturne.css +21 -0
- package/themes/studio.css +23 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { ANNOTATE_DEFAULT_OPTIONS, colorFromHex } from '@sealpixel/plugins';
|
|
2
|
+
import { html, nothing, svg } from 'lit';
|
|
3
|
+
import { icons } from '../icons.js';
|
|
4
|
+
import { cropClipPath } from './crop-mask.js';
|
|
5
|
+
import { deleteHandle, pointsBox, toPx } from './delete-handle.js';
|
|
6
|
+
import { opId } from './finetune.js';
|
|
7
|
+
const KINDS = ['rect', 'ellipse', 'line', 'arrow', 'path', 'text'];
|
|
8
|
+
/** Annotate coordinates live in image space: show the image before crop and resize. */
|
|
9
|
+
function beforeCrop(log) {
|
|
10
|
+
return {
|
|
11
|
+
...log,
|
|
12
|
+
ops: [
|
|
13
|
+
...log.ops,
|
|
14
|
+
{ type: 'crop.reset', id: '__sealpixel_preview_crop__' },
|
|
15
|
+
{ type: 'resize.clear', id: '__sealpixel_preview_resize__' },
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const state = {
|
|
20
|
+
kind: 'rect',
|
|
21
|
+
stroke: [1, 0.2, 0.2, 1],
|
|
22
|
+
width: 4,
|
|
23
|
+
fill: null,
|
|
24
|
+
strokeTouched: false,
|
|
25
|
+
selected: null,
|
|
26
|
+
drawing: null,
|
|
27
|
+
drag: null,
|
|
28
|
+
editingText: null,
|
|
29
|
+
};
|
|
30
|
+
const hex = (c) => `#${[c[0], c[1], c[2]]
|
|
31
|
+
.map((v) => Math.round(v * 255)
|
|
32
|
+
.toString(16)
|
|
33
|
+
.padStart(2, '0'))
|
|
34
|
+
.join('')}`;
|
|
35
|
+
const fromHex = (h, alpha = 1) => [
|
|
36
|
+
Number.parseInt(h.slice(1, 3), 16) / 255,
|
|
37
|
+
Number.parseInt(h.slice(3, 5), 16) / 255,
|
|
38
|
+
Number.parseInt(h.slice(5, 7), 16) / 255,
|
|
39
|
+
alpha,
|
|
40
|
+
];
|
|
41
|
+
/** Three rules, weighted to the edge they align to. */
|
|
42
|
+
const ALIGN_ICON = {
|
|
43
|
+
left: icons.alignLeft,
|
|
44
|
+
center: icons.alignCenter,
|
|
45
|
+
right: icons.alignRight,
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Keeps the preview clipped to what the crop keeps. Called on activate and on
|
|
49
|
+
* every panel render, so an undo that changes the crop is picked up too.
|
|
50
|
+
*/
|
|
51
|
+
function clipToCrop(ctx) {
|
|
52
|
+
const crop = ctx.session.getDocument().crop;
|
|
53
|
+
const preview = ctx.state.preview;
|
|
54
|
+
ctx.clipPreview(preview ? cropClipPath(crop, preview.image.width, preview.image.height) : null);
|
|
55
|
+
}
|
|
56
|
+
export const annotateTool = {
|
|
57
|
+
id: 'annotate',
|
|
58
|
+
icon: icons.annotate,
|
|
59
|
+
label: 'tool.annotate',
|
|
60
|
+
activate: (ctx) => {
|
|
61
|
+
clipToCrop(ctx);
|
|
62
|
+
ctx.session.setPreviewTransform(beforeCrop);
|
|
63
|
+
},
|
|
64
|
+
deactivate: (ctx) => {
|
|
65
|
+
state.drawing = null;
|
|
66
|
+
state.drag = null;
|
|
67
|
+
state.selected = null;
|
|
68
|
+
state.editingText = null;
|
|
69
|
+
ctx.clipPreview(null);
|
|
70
|
+
ctx.session.setPreviewTransform(null);
|
|
71
|
+
},
|
|
72
|
+
panel: (ctx) => {
|
|
73
|
+
clipToCrop(ctx);
|
|
74
|
+
const doc = ctx.document.annotate;
|
|
75
|
+
const options = ctx.options('annotate') ?? ANNOTATE_DEFAULT_OPTIONS;
|
|
76
|
+
if (!options.shapes.includes(state.kind))
|
|
77
|
+
state.kind = options.shapes[0] ?? 'rect';
|
|
78
|
+
if (!state.strokeTouched) {
|
|
79
|
+
state.stroke = colorFromHex(options.defaultStroke.color);
|
|
80
|
+
state.width = options.defaultStroke.width;
|
|
81
|
+
}
|
|
82
|
+
const kinds = options.shapes;
|
|
83
|
+
const sel = doc.shapes.find((s) => s.id === state.selected) ?? null;
|
|
84
|
+
const update = (shape) => sel && ctx.dispatch({ type: 'annotate.update', id: opId(), shapeId: sel.id, shape });
|
|
85
|
+
const strokeOf = (s) => ('stroke' in s ? s.stroke : undefined);
|
|
86
|
+
const currentStroke = sel ? strokeOf(sel.shape) : { color: state.stroke, width: state.width };
|
|
87
|
+
const currentFill = sel ? ('fill' in sel.shape ? (sel.shape.fill ?? null) : null) : state.fill;
|
|
88
|
+
const setStroke = (patch) => {
|
|
89
|
+
const next = {
|
|
90
|
+
color: currentStroke?.color ?? state.stroke,
|
|
91
|
+
width: currentStroke?.width ?? state.width,
|
|
92
|
+
...patch,
|
|
93
|
+
};
|
|
94
|
+
state.stroke = next.color;
|
|
95
|
+
state.width = next.width;
|
|
96
|
+
state.strokeTouched = true;
|
|
97
|
+
if (sel && 'stroke' in sel.shape)
|
|
98
|
+
update({ ...sel.shape, stroke: next });
|
|
99
|
+
else if (sel && sel.shape.kind === 'text')
|
|
100
|
+
update({ ...sel.shape, color: next.color });
|
|
101
|
+
else
|
|
102
|
+
ctx.refresh();
|
|
103
|
+
};
|
|
104
|
+
const text = sel && sel.shape.kind === 'text' ? sel.shape : null;
|
|
105
|
+
/** Patches the selected text shape; every typography control goes through it. */
|
|
106
|
+
const setText = (patch) => {
|
|
107
|
+
if (text)
|
|
108
|
+
update({ ...text, ...patch });
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Colour, as a palette of discs plus a well. The palette alone is the whole
|
|
112
|
+
* control when the options enforce one.
|
|
113
|
+
*/
|
|
114
|
+
const colorField = (labelKey, current, set) => html `
|
|
115
|
+
<label class="field">
|
|
116
|
+
<span>${ctx.t(labelKey)}</span>
|
|
117
|
+
${options.palette.length > 0
|
|
118
|
+
? html `<div class="swatches" role="group" aria-label=${ctx.t(labelKey)}>
|
|
119
|
+
${options.palette.map((h) => html `<button type="button" class="swatch" data-swatch=${h} style=${`background:${h}`} aria-label=${h} aria-pressed=${current === h.slice(0, 7) ? 'true' : 'false'} @click=${() => set(colorFromHex(h))}></button>`)}
|
|
120
|
+
</div>`
|
|
121
|
+
: nothing}
|
|
122
|
+
${!options.enforce || options.palette.length === 0
|
|
123
|
+
? html `<input data-field="stroke" type="color" .value=${current} @change=${(e) => set(fromHex(e.target.value))} />`
|
|
124
|
+
: nothing}
|
|
125
|
+
</label>`;
|
|
126
|
+
const setFill = (fill) => {
|
|
127
|
+
state.fill = fill;
|
|
128
|
+
if (sel &&
|
|
129
|
+
(sel.shape.kind === 'rect' || sel.shape.kind === 'ellipse' || sel.shape.kind === 'path')) {
|
|
130
|
+
const { fill: _drop, ...rest } = sel.shape;
|
|
131
|
+
update((fill ? { ...rest, fill } : rest));
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
ctx.refresh();
|
|
135
|
+
};
|
|
136
|
+
return html `
|
|
137
|
+
<div class="row choice" role="group" aria-label=${ctx.t('annotate.shape')}>
|
|
138
|
+
<div class="group">
|
|
139
|
+
${kinds.map((k) => html `<sealpixel-button data-kind=${k} ?pressed=${state.kind === k} .label=${ctx.t(`annotate.kind.${k}`)} @click=${() => {
|
|
140
|
+
state.kind = k;
|
|
141
|
+
state.selected = null;
|
|
142
|
+
ctx.refresh();
|
|
143
|
+
}}>${ICONS[k]}</sealpixel-button>`)}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
<div class="rows">
|
|
147
|
+
${
|
|
148
|
+
// A text shape has a colour, a plate and typography; it has no stroke
|
|
149
|
+
// width and no fill, and offering them meant two controls that moved
|
|
150
|
+
// and changed nothing. Every other shape has the stroke set and never
|
|
151
|
+
// a font size.
|
|
152
|
+
text
|
|
153
|
+
? html `
|
|
154
|
+
<label class="field">
|
|
155
|
+
<span>${ctx.t('annotate.text')}</span>
|
|
156
|
+
<textarea data-field="text" rows="1" .value=${text.text} @input=${(e) => {
|
|
157
|
+
state.editingText = e.target.value;
|
|
158
|
+
}} @change=${(e) => {
|
|
159
|
+
state.editingText = null;
|
|
160
|
+
setText({ text: e.target.value });
|
|
161
|
+
}}></textarea>
|
|
162
|
+
</label>
|
|
163
|
+
${colorField('annotate.color', hex(text.color), (c) => setStroke({ color: c }))}
|
|
164
|
+
<label class="field">
|
|
165
|
+
<span>${ctx.t('annotate.background')}</span>
|
|
166
|
+
<input data-field="background" type="color" .value=${hex(text.background ?? [1, 1, 1, 1])} @change=${(e) => setText({ background: fromHex(e.target.value) })} />
|
|
167
|
+
</label>
|
|
168
|
+
${text.background
|
|
169
|
+
? html `<sealpixel-button variant="ghost" data-action="no-background" .label=${ctx.t('annotate.noBackground')} @click=${() => setText({ background: undefined })}>${ctx.t('annotate.noBackground')}</sealpixel-button>`
|
|
170
|
+
: nothing}
|
|
171
|
+
${options.fonts.length > 1
|
|
172
|
+
? html `<label class="field"><span>${ctx.t('annotate.font')}</span>
|
|
173
|
+
<select data-field="font" @change=${(e) => setText({ font: e.target.value })}>
|
|
174
|
+
${options.fonts.map((f) => html `<option value=${f.id} ?selected=${text.font === f.id}>${f.label ?? f.id.replace(/^font\./, '')}</option>`)}
|
|
175
|
+
</select></label>`
|
|
176
|
+
: nothing}
|
|
177
|
+
<sealpixel-stepper data-param="size" .label=${ctx.t('annotate.size')} .value=${text.size} .min=${options.sizeRange.min} .max=${options.sizeRange.max} .step=${options.sizeRange.step} unit="px" @commit=${(e) => setText({ size: e.detail })}></sealpixel-stepper>
|
|
178
|
+
<sealpixel-stepper data-param="line-height" .label=${ctx.t('annotate.lineHeight')} .value=${text.lineHeight ?? 1.2} .min=${0.8} .max=${3} .step=${0.05} .decimals=${2} @commit=${(e) => setText({ lineHeight: e.detail })}></sealpixel-stepper>
|
|
179
|
+
<div class="field">
|
|
180
|
+
<span>${ctx.t('annotate.align')}</span>
|
|
181
|
+
<div class="group" role="group" aria-label=${ctx.t('annotate.align')}>
|
|
182
|
+
${['left', 'center', 'right'].map((a) => html `<sealpixel-button data-align=${a} ?pressed=${(text.align ?? 'left') === a} .label=${ctx.t(`annotate.align.${a}`)} @click=${() => setText({ align: a })}>${ALIGN_ICON[a]}</sealpixel-button>`)}
|
|
183
|
+
</div>
|
|
184
|
+
</div>`
|
|
185
|
+
: html `
|
|
186
|
+
${colorField('annotate.stroke', hex(currentStroke?.color ?? state.stroke), (c) => setStroke({ color: c }))}
|
|
187
|
+
<sealpixel-stepper data-param="width" .label=${ctx.t('annotate.width')} .value=${currentStroke?.width ?? state.width} .min=${options.widthRange.min} .max=${options.widthRange.max} .step=${options.widthRange.step} unit="px" @commit=${(e) => setStroke({ width: e.detail })}></sealpixel-stepper>
|
|
188
|
+
${options.fill
|
|
189
|
+
? html `<label class="field check">
|
|
190
|
+
<input data-field="fill-enabled" type="checkbox" .checked=${currentFill !== null} @change=${(e) => setFill(e.target.checked ? (currentFill ?? [1, 1, 1, 0.5]) : null)} />
|
|
191
|
+
<span>${ctx.t('annotate.fill')}</span>
|
|
192
|
+
</label>`
|
|
193
|
+
: nothing}
|
|
194
|
+
${currentFill
|
|
195
|
+
? html `<label class="field"><span>${ctx.t('annotate.fillColor')}</span><input data-field="fill" type="color" .value=${hex(currentFill)} @change=${(e) => setFill(fromHex(e.target.value, currentFill[3]))} /></label>`
|
|
196
|
+
: nothing}`}
|
|
197
|
+
</div>
|
|
198
|
+
`;
|
|
199
|
+
},
|
|
200
|
+
overlay: (ctx) => {
|
|
201
|
+
const doc = ctx.document.annotate;
|
|
202
|
+
const { width: W, height: H, zoom } = ctx.stage;
|
|
203
|
+
if (!W || !H)
|
|
204
|
+
return svg ``;
|
|
205
|
+
const sw = 1.5 / zoom;
|
|
206
|
+
const toN = (e) => {
|
|
207
|
+
const p = ctx.stage.toImage(e.clientX, e.clientY);
|
|
208
|
+
return [clamp01(p.x / W), clamp01(p.y / H)];
|
|
209
|
+
};
|
|
210
|
+
const down = (e) => {
|
|
211
|
+
e.stopPropagation();
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
const p = toN(e);
|
|
214
|
+
state.selected = null;
|
|
215
|
+
state.drawing = { start: p, current: p, points: [p] };
|
|
216
|
+
const move = (ev) => {
|
|
217
|
+
if (!state.drawing)
|
|
218
|
+
return;
|
|
219
|
+
const q = toN(ev);
|
|
220
|
+
state.drawing.current = q;
|
|
221
|
+
const last = state.drawing.points[state.drawing.points.length - 1];
|
|
222
|
+
if (Math.hypot(q[0] - last[0], q[1] - last[1]) > 0.003)
|
|
223
|
+
state.drawing.points.push(q);
|
|
224
|
+
ctx.refresh();
|
|
225
|
+
};
|
|
226
|
+
const up = () => {
|
|
227
|
+
window.removeEventListener('pointermove', move);
|
|
228
|
+
window.removeEventListener('pointerup', up);
|
|
229
|
+
window.removeEventListener('pointercancel', up);
|
|
230
|
+
const d = state.drawing;
|
|
231
|
+
state.drawing = null;
|
|
232
|
+
if (!d)
|
|
233
|
+
return;
|
|
234
|
+
const shape = shapeFromDrawing(d, state.kind, ctx);
|
|
235
|
+
if (shape) {
|
|
236
|
+
const id = opId();
|
|
237
|
+
ctx.dispatch({ type: 'annotate.add', id, shape });
|
|
238
|
+
state.selected = id;
|
|
239
|
+
}
|
|
240
|
+
ctx.refresh();
|
|
241
|
+
};
|
|
242
|
+
window.addEventListener('pointermove', move);
|
|
243
|
+
window.addEventListener('pointerup', up);
|
|
244
|
+
window.addEventListener('pointercancel', up);
|
|
245
|
+
};
|
|
246
|
+
const pick = (a) => (e) => {
|
|
247
|
+
e.stopPropagation();
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
state.selected = a.id;
|
|
250
|
+
const start = toN(e);
|
|
251
|
+
state.drag = { id: a.id, shape: a.shape, start };
|
|
252
|
+
const move = (ev) => {
|
|
253
|
+
if (!state.drag)
|
|
254
|
+
return;
|
|
255
|
+
const q = toN(ev);
|
|
256
|
+
state.drag.shape = translate(a.shape, q[0] - start[0], q[1] - start[1]);
|
|
257
|
+
ctx.refresh();
|
|
258
|
+
};
|
|
259
|
+
const up = () => {
|
|
260
|
+
window.removeEventListener('pointermove', move);
|
|
261
|
+
window.removeEventListener('pointerup', up);
|
|
262
|
+
window.removeEventListener('pointercancel', up);
|
|
263
|
+
const d = state.drag;
|
|
264
|
+
state.drag = null;
|
|
265
|
+
if (d && JSON.stringify(d.shape) !== JSON.stringify(a.shape)) {
|
|
266
|
+
ctx.dispatch({ type: 'annotate.update', id: opId(), shapeId: a.id, shape: d.shape });
|
|
267
|
+
}
|
|
268
|
+
ctx.refresh();
|
|
269
|
+
};
|
|
270
|
+
window.addEventListener('pointermove', move);
|
|
271
|
+
window.addEventListener('pointerup', up);
|
|
272
|
+
window.addEventListener('pointercancel', up);
|
|
273
|
+
};
|
|
274
|
+
const selected = doc.shapes.find((s) => s.id === state.selected) ?? null;
|
|
275
|
+
const outline = (a) => {
|
|
276
|
+
const dragging = state.drag?.id === a.id;
|
|
277
|
+
const s = dragging ? state.drag?.shape : a.shape;
|
|
278
|
+
const selected = state.selected === a.id;
|
|
279
|
+
const stroke = selected ? 'var(--sealpixel-color-accent)' : 'rgba(255,255,255,0.7)';
|
|
280
|
+
const dash = `${4 / zoom} ${3 / zoom}`;
|
|
281
|
+
// Almost transparent fill keeps the interior grabbable without hiding the pixels.
|
|
282
|
+
const fill = 'rgba(255,255,255,0.001)';
|
|
283
|
+
const grab = Math.max(sw * 6, 8 / zoom);
|
|
284
|
+
// While moving, draw the shape itself so the user sees what lands.
|
|
285
|
+
const ghost = dragging ? preview(s, W, H, sw) : svg ``;
|
|
286
|
+
switch (s.kind) {
|
|
287
|
+
case 'rect':
|
|
288
|
+
case 'text': {
|
|
289
|
+
const r = s.rect;
|
|
290
|
+
return svg `${ghost}<rect data-interactive data-shape=${a.id} x=${r.x * W} y=${r.y * H} width=${Math.max(r.width * W, 2)} height=${Math.max(r.height * H, 2)} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${dash} style="cursor:move" @pointerdown=${pick(a)} />`;
|
|
291
|
+
}
|
|
292
|
+
case 'ellipse': {
|
|
293
|
+
const r = s.rect;
|
|
294
|
+
return svg `${ghost}<ellipse data-interactive data-shape=${a.id} cx=${(r.x + r.width / 2) * W} cy=${(r.y + r.height / 2) * H} rx=${Math.max((r.width / 2) * W, 1)} ry=${Math.max((r.height / 2) * H, 1)} fill=${fill} stroke=${stroke} stroke-width=${sw} stroke-dasharray=${dash} style="cursor:move" @pointerdown=${pick(a)} />`;
|
|
295
|
+
}
|
|
296
|
+
case 'line':
|
|
297
|
+
case 'arrow':
|
|
298
|
+
return svg `${ghost}<line data-interactive data-shape=${a.id} x1=${s.from[0] * W} y1=${s.from[1] * H} x2=${s.to[0] * W} y2=${s.to[1] * H} stroke=${stroke} stroke-width=${grab} stroke-opacity="0.3" style="cursor:move" @pointerdown=${pick(a)} />`;
|
|
299
|
+
case 'path': {
|
|
300
|
+
const d = s.points
|
|
301
|
+
.map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0] * W} ${p[1] * H}`)
|
|
302
|
+
.join(' ');
|
|
303
|
+
return svg `${ghost}<path data-interactive data-shape=${a.id} d=${d} fill="none" stroke=${stroke} stroke-width=${grab} stroke-opacity="0.3" style="cursor:move" @pointerdown=${pick(a)} />`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
let live = svg ``;
|
|
308
|
+
const d = state.drawing;
|
|
309
|
+
if (d) {
|
|
310
|
+
const shape = shapeFromDrawing(d, state.kind, ctx);
|
|
311
|
+
if (shape)
|
|
312
|
+
live = preview(shape, W, H, sw);
|
|
313
|
+
}
|
|
314
|
+
return svg `
|
|
315
|
+
<rect data-interactive data-canvas x="0" y="0" width=${W} height=${H} fill="transparent" style="cursor:crosshair" @pointerdown=${down} />
|
|
316
|
+
${doc.shapes.map(outline)}
|
|
317
|
+
${selected
|
|
318
|
+
? deleteHandle(toPx(bboxOf(state.drag?.id === selected.id ? state.drag.shape : selected.shape), W, H), ctx.stage, ctx.t('annotate.delete'), () => {
|
|
319
|
+
state.selected = null;
|
|
320
|
+
ctx.dispatch({ type: 'annotate.remove', id: opId(), shapeId: selected.id });
|
|
321
|
+
})
|
|
322
|
+
: nothing}
|
|
323
|
+
${live}
|
|
324
|
+
`;
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
function bboxOf(s) {
|
|
328
|
+
switch (s.kind) {
|
|
329
|
+
case 'rect':
|
|
330
|
+
case 'ellipse':
|
|
331
|
+
case 'text':
|
|
332
|
+
return s.rect;
|
|
333
|
+
case 'line':
|
|
334
|
+
case 'arrow':
|
|
335
|
+
return pointsBox([s.from, s.to]);
|
|
336
|
+
case 'path':
|
|
337
|
+
return pointsBox(s.points);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const ICONS = {
|
|
341
|
+
rect: '▭',
|
|
342
|
+
ellipse: '◯',
|
|
343
|
+
line: '╱',
|
|
344
|
+
arrow: '➚',
|
|
345
|
+
path: '〰',
|
|
346
|
+
text: 'T',
|
|
347
|
+
};
|
|
348
|
+
function shapeFromDrawing(d, kind, ctx) {
|
|
349
|
+
const stroke = { color: state.stroke, width: state.width };
|
|
350
|
+
const x = Math.min(d.start[0], d.current[0]);
|
|
351
|
+
const y = Math.min(d.start[1], d.current[1]);
|
|
352
|
+
const width = Math.abs(d.current[0] - d.start[0]);
|
|
353
|
+
const height = Math.abs(d.current[1] - d.start[1]);
|
|
354
|
+
const tooSmall = width < 0.005 && height < 0.005;
|
|
355
|
+
switch (kind) {
|
|
356
|
+
case 'rect':
|
|
357
|
+
return tooSmall
|
|
358
|
+
? null
|
|
359
|
+
: {
|
|
360
|
+
kind: 'rect',
|
|
361
|
+
rect: { x, y, width, height },
|
|
362
|
+
stroke,
|
|
363
|
+
...(state.fill ? { fill: state.fill } : {}),
|
|
364
|
+
};
|
|
365
|
+
case 'ellipse':
|
|
366
|
+
return tooSmall
|
|
367
|
+
? null
|
|
368
|
+
: {
|
|
369
|
+
kind: 'ellipse',
|
|
370
|
+
rect: { x, y, width, height },
|
|
371
|
+
stroke,
|
|
372
|
+
...(state.fill ? { fill: state.fill } : {}),
|
|
373
|
+
};
|
|
374
|
+
case 'line':
|
|
375
|
+
return tooSmall ? null : { kind: 'line', from: d.start, to: d.current, stroke };
|
|
376
|
+
case 'arrow':
|
|
377
|
+
return tooSmall ? null : { kind: 'arrow', from: d.start, to: d.current, stroke };
|
|
378
|
+
case 'path':
|
|
379
|
+
return d.points.length < 2 ? null : { kind: 'path', points: d.points, stroke };
|
|
380
|
+
case 'text': {
|
|
381
|
+
const src = ctx.state.source;
|
|
382
|
+
const size = Math.max(12, Math.round((src?.height ?? 400) / 20));
|
|
383
|
+
return {
|
|
384
|
+
kind: 'text',
|
|
385
|
+
rect: { x, y, width: Math.max(width, 0.3), height: Math.max(height, 0.1) },
|
|
386
|
+
text: ctx.t('annotate.defaultText'),
|
|
387
|
+
font: 'font.roboto',
|
|
388
|
+
size,
|
|
389
|
+
color: state.stroke,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function translate(s, dx, dy) {
|
|
395
|
+
const mv = (p) => [clamp01(p[0] + dx), clamp01(p[1] + dy)];
|
|
396
|
+
switch (s.kind) {
|
|
397
|
+
case 'rect':
|
|
398
|
+
case 'ellipse':
|
|
399
|
+
case 'text':
|
|
400
|
+
return {
|
|
401
|
+
...s,
|
|
402
|
+
rect: {
|
|
403
|
+
...s.rect,
|
|
404
|
+
x: clamp(s.rect.x + dx, 0, 1 - s.rect.width),
|
|
405
|
+
y: clamp(s.rect.y + dy, 0, 1 - s.rect.height),
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
case 'line':
|
|
409
|
+
case 'arrow':
|
|
410
|
+
return { ...s, from: mv(s.from), to: mv(s.to) };
|
|
411
|
+
case 'path':
|
|
412
|
+
return { ...s, points: s.points.map(mv) };
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function preview(s, W, H, sw) {
|
|
416
|
+
const accent = 'var(--sealpixel-color-accent)';
|
|
417
|
+
switch (s.kind) {
|
|
418
|
+
case 'rect':
|
|
419
|
+
case 'text':
|
|
420
|
+
return svg `<rect x=${s.rect.x * W} y=${s.rect.y * H} width=${s.rect.width * W} height=${s.rect.height * H} fill="rgba(91,141,239,0.15)" stroke=${accent} stroke-width=${sw} />`;
|
|
421
|
+
case 'ellipse':
|
|
422
|
+
return svg `<ellipse cx=${(s.rect.x + s.rect.width / 2) * W} cy=${(s.rect.y + s.rect.height / 2) * H} rx=${(s.rect.width / 2) * W} ry=${(s.rect.height / 2) * H} fill="rgba(91,141,239,0.15)" stroke=${accent} stroke-width=${sw} />`;
|
|
423
|
+
case 'line':
|
|
424
|
+
case 'arrow':
|
|
425
|
+
return svg `<line x1=${s.from[0] * W} y1=${s.from[1] * H} x2=${s.to[0] * W} y2=${s.to[1] * H} stroke=${accent} stroke-width=${sw * 2} />`;
|
|
426
|
+
case 'path':
|
|
427
|
+
return svg `<path d=${s.points.map((p, i) => `${i === 0 ? 'M' : 'L'}${p[0] * W} ${p[1] * H}`).join(' ')} fill="none" stroke=${accent} stroke-width=${sw * 2} />`;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function clamp01(v) {
|
|
431
|
+
return clamp(v, 0, 1);
|
|
432
|
+
}
|
|
433
|
+
function clamp(v, lo, hi) {
|
|
434
|
+
return v < lo ? lo : v > hi ? hi : v;
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.js","sourceRoot":"","sources":["../../src/tools/annotate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAwB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,IAAI,EAAE,OAAO,EAA0B,GAAG,EAAE,MAAM,KAAK,CAAC;AACjE,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,EAAE,MAAM,eAAe,CAAC;AA8CrC,MAAM,KAAK,GAAW,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3E,uFAAuF;AACvF,SAAS,UAAU,CAAC,GAAY;IAC9B,OAAO;QACL,GAAG,GAAG;QACN,GAAG,EAAE;YACH,GAAG,GAAG,CAAC,GAAG;YACV,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,4BAA4B,EAAE;YACxD,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,8BAA8B,EAAE;SAC7D;KACF,CAAC;AACJ,CAAC;AAED,MAAM,KAAK,GAWP;IACF,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,IAAI;IACV,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;IACV,WAAW,EAAE,IAAI;CAClB,CAAC;AA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,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,MAAM,iBAAiB,EAAE,GAAG,CAAC,KAAK,CAAC;IACpK,CAAC;AACH,CAAC;AAED,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Rect } from '@sealpixel/core';
|
|
2
|
+
export interface CropLike {
|
|
3
|
+
mask?: 'none' | 'circle' | undefined;
|
|
4
|
+
rotation: number;
|
|
5
|
+
flipX: boolean;
|
|
6
|
+
flipY: boolean;
|
|
7
|
+
rect: Rect;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The crop output mapped back into image pixels, as a polygon. Mirrors the
|
|
11
|
+
* inverse affine in `crates/sealpixel-core/src/geometry.rs` (`crop_actual`):
|
|
12
|
+
* out → bbox → centre → rotate(-r) → unflip → src.
|
|
13
|
+
*/
|
|
14
|
+
export declare function cropPolygon(c: CropLike, W: number, H: number): [number, number][];
|
|
15
|
+
export declare function isIdentityCrop(c: CropLike): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Tools that work in image space (redact, annotate) render the image before
|
|
18
|
+
* crop and resize, because that is the space their shapes live in. This clips
|
|
19
|
+
* the preview to what the crop keeps, so the user still sees the picture they
|
|
20
|
+
* are working on rather than one with a border they already cut off.
|
|
21
|
+
*
|
|
22
|
+
* A `path()` clip in image pixels rather than a percentage polygon: the canvas
|
|
23
|
+
* is sized in image pixels, so the numbers line up, and it is the only form
|
|
24
|
+
* that can express a rotated crop or a circular one. It does not interpolate
|
|
25
|
+
* with `polygon()`, which is fine here — this one is set on entry, not
|
|
26
|
+
* revealed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function cropClipPath(c: CropLike | undefined, W: number, H: number): string | null;
|
|
29
|
+
//# sourceMappingURL=crop-mask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop-mask.d.ts","sourceRoot":"","sources":["../../src/tools/crop-mask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAmBjF;AAyBD,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,OAAO,CAYnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQzF"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The crop output mapped back into image pixels, as a polygon. Mirrors the
|
|
3
|
+
* inverse affine in `crates/sealpixel-core/src/geometry.rs` (`crop_actual`):
|
|
4
|
+
* out → bbox → centre → rotate(-r) → unflip → src.
|
|
5
|
+
*/
|
|
6
|
+
export function cropPolygon(c, W, H) {
|
|
7
|
+
const sin = Math.sin(c.rotation);
|
|
8
|
+
const cos = Math.cos(c.rotation);
|
|
9
|
+
const bw = W * Math.abs(cos) + H * Math.abs(sin);
|
|
10
|
+
const bh = W * Math.abs(sin) + H * Math.abs(cos);
|
|
11
|
+
const fx = c.flipX ? -1 : 1;
|
|
12
|
+
const fy = c.flipY ? -1 : 1;
|
|
13
|
+
const ox = c.rect.x * bw - bw / 2;
|
|
14
|
+
const oy = c.rect.y * bh - bh / 2;
|
|
15
|
+
const a = fx * cos;
|
|
16
|
+
const b = fy * -sin;
|
|
17
|
+
const cc = fx * sin;
|
|
18
|
+
const d = fy * cos;
|
|
19
|
+
const e = fx * (cos * ox + sin * oy) + W / 2;
|
|
20
|
+
const f = fy * (-sin * ox + cos * oy) + H / 2;
|
|
21
|
+
const outW = c.rect.width * bw;
|
|
22
|
+
const outH = c.rect.height * bh;
|
|
23
|
+
const map = (x, y) => [a * x + cc * y + e, b * x + d * y + f];
|
|
24
|
+
return [map(0, 0), map(outW, 0), map(outW, outH), map(0, outH)];
|
|
25
|
+
}
|
|
26
|
+
/** The ellipse inscribed in a (possibly rotated) rectangle given by its corners, as an SVG path. */
|
|
27
|
+
function ellipsePath(p) {
|
|
28
|
+
const [a, b, c, d] = p;
|
|
29
|
+
const cx = (a[0] + c[0]) / 2;
|
|
30
|
+
const cy = (a[1] + c[1]) / 2;
|
|
31
|
+
const rx = Math.hypot(b[0] - a[0], b[1] - a[1]) / 2;
|
|
32
|
+
const ry = Math.hypot(d[0] - a[0], d[1] - a[1]) / 2;
|
|
33
|
+
const rad = Math.atan2(b[1] - a[1], b[0] - a[0]);
|
|
34
|
+
const angle = (rad * 180) / Math.PI;
|
|
35
|
+
const ux = Math.cos(rad);
|
|
36
|
+
const uy = Math.sin(rad);
|
|
37
|
+
const sx = cx - rx * ux;
|
|
38
|
+
const sy = cy - rx * uy;
|
|
39
|
+
const ex = cx + rx * ux;
|
|
40
|
+
const ey = cy + rx * uy;
|
|
41
|
+
return `M${sx} ${sy}A${rx} ${ry} ${angle} 1 0 ${ex} ${ey}A${rx} ${ry} ${angle} 1 0 ${sx} ${sy}`;
|
|
42
|
+
}
|
|
43
|
+
export function isIdentityCrop(c) {
|
|
44
|
+
const r = c.rect;
|
|
45
|
+
return (c.rotation === 0 &&
|
|
46
|
+
!c.flipX &&
|
|
47
|
+
!c.flipY &&
|
|
48
|
+
(c.mask ?? 'none') === 'none' &&
|
|
49
|
+
r.x === 0 &&
|
|
50
|
+
r.y === 0 &&
|
|
51
|
+
r.width === 1 &&
|
|
52
|
+
r.height === 1);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tools that work in image space (redact, annotate) render the image before
|
|
56
|
+
* crop and resize, because that is the space their shapes live in. This clips
|
|
57
|
+
* the preview to what the crop keeps, so the user still sees the picture they
|
|
58
|
+
* are working on rather than one with a border they already cut off.
|
|
59
|
+
*
|
|
60
|
+
* A `path()` clip in image pixels rather than a percentage polygon: the canvas
|
|
61
|
+
* is sized in image pixels, so the numbers line up, and it is the only form
|
|
62
|
+
* that can express a rotated crop or a circular one. It does not interpolate
|
|
63
|
+
* with `polygon()`, which is fine here — this one is set on entry, not
|
|
64
|
+
* revealed.
|
|
65
|
+
*/
|
|
66
|
+
export function cropClipPath(c, W, H) {
|
|
67
|
+
if (!c || isIdentityCrop(c) || !W || !H)
|
|
68
|
+
return null;
|
|
69
|
+
const poly = cropPolygon(c, W, H);
|
|
70
|
+
const inner = c.mask === 'circle'
|
|
71
|
+
? ellipsePath(poly)
|
|
72
|
+
: `${poly.map(([x, y], i) => `${i === 0 ? 'M' : 'L'}${x} ${y}`).join(' ')} Z`;
|
|
73
|
+
return `path('${inner}')`;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=crop-mask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop-mask.js","sourceRoot":"","sources":["../../src/tools/crop-mask.ts"],"names":[],"mappings":"AAUA;;;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,KAAK,CAAC;QACT,CAAC,CAAC,CAAC,KAAK,CAAC;QACT,CAAC,CAAC,KAAK,KAAK,CAAC;QACb,CAAC,CAAC,MAAM,KAAK,CAAC,CACf,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,CAAuB,EAAE,CAAS,EAAE,CAAS;IACxE,IAAI,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACrD,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,KAAK,GACT,CAAC,CAAC,IAAI,KAAK,QAAQ;QACjB,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACnB,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IAClF,OAAO,SAAS,KAAK,IAAI,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Rect } from '@sealpixel/core';
|
|
2
|
+
import type { UiTool } from '../tool.js';
|
|
3
|
+
type Handle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'move';
|
|
4
|
+
export declare const cropTool: UiTool;
|
|
5
|
+
/**
|
|
6
|
+
* Applies a normalised drag delta to `start`. `aspect` is width/height in
|
|
7
|
+
* output pixels; `stageAspect` converts it into normalised units.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyDrag(start: Rect, handle: Handle, dx: number, dy: number, aspect: number | null, stageAspect: number): Rect;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=crop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.d.ts","sourceRoot":"","sources":["../../src/tools/crop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIrD,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;AAYxD,KAAK,MAAM,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC;AAoGzE,eAAO,MAAM,QAAQ,EAAE,MAsNtB,CAAC;AAsBF;;;GAGG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,WAAW,EAAE,MAAM,GAClB,IAAI,CAyCN"}
|