@g9tm/lynxcontrols-studio 0.0.0-stage → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -2
- package/catalog/cards/G9NleTimeline.md +17 -0
- package/catalog/cards/G9Surface.md +16 -0
- package/catalog/cards/G9TransformBox.md +17 -0
- package/catalog/catalog.json +2255 -0
- package/catalog/index.md +7 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +3 -0
- package/dist/nle-timeline/core.d.ts +5 -0
- package/dist/nle-timeline/core.d.ts.map +1 -0
- package/dist/nle-timeline/core.js +4 -0
- package/dist/nle-timeline/core.jsx +4 -0
- package/dist/nle-timeline/edits.d.ts +65 -0
- package/dist/nle-timeline/edits.d.ts.map +1 -0
- package/dist/nle-timeline/edits.js +344 -0
- package/dist/nle-timeline/edits.js.map +1 -0
- package/dist/nle-timeline/edits.jsx +342 -0
- package/dist/nle-timeline/engine.d.ts +159 -0
- package/dist/nle-timeline/engine.d.ts.map +1 -0
- package/dist/nle-timeline/engine.js +899 -0
- package/dist/nle-timeline/engine.js.map +1 -0
- package/dist/nle-timeline/engine.jsx +897 -0
- package/dist/nle-timeline/index.d.ts +6 -0
- package/dist/nle-timeline/index.d.ts.map +1 -0
- package/dist/nle-timeline/index.jsx +5 -0
- package/dist/nle-timeline/layout.d.ts +116 -0
- package/dist/nle-timeline/layout.d.ts.map +1 -0
- package/dist/nle-timeline/layout.js +310 -0
- package/dist/nle-timeline/layout.js.map +1 -0
- package/dist/nle-timeline/layout.jsx +308 -0
- package/dist/nle-timeline/model.d.ts +140 -0
- package/dist/nle-timeline/model.d.ts.map +1 -0
- package/dist/nle-timeline/model.js +155 -0
- package/dist/nle-timeline/model.js.map +1 -0
- package/dist/nle-timeline/model.jsx +153 -0
- package/dist/nle-timeline/nle.d.ts +72 -0
- package/dist/nle-timeline/nle.d.ts.map +1 -0
- package/dist/nle-timeline/nle.jsx +92 -0
- package/dist/surface/core.d.ts +2 -0
- package/dist/surface/core.d.ts.map +1 -0
- package/dist/surface/core.js +1 -0
- package/dist/surface/core.jsx +1 -0
- package/dist/surface/index.d.ts +3 -0
- package/dist/surface/index.d.ts.map +1 -0
- package/dist/surface/index.jsx +2 -0
- package/dist/surface/protocol.d.ts +40 -0
- package/dist/surface/protocol.d.ts.map +1 -0
- package/dist/surface/protocol.js +19 -0
- package/dist/surface/protocol.js.map +1 -0
- package/dist/surface/protocol.jsx +17 -0
- package/dist/surface/surface.d.ts +53 -0
- package/dist/surface/surface.d.ts.map +1 -0
- package/dist/surface/surface.jsx +62 -0
- package/dist/transform-box/core.d.ts +3 -0
- package/dist/transform-box/core.d.ts.map +1 -0
- package/dist/transform-box/core.js +2 -0
- package/dist/transform-box/core.jsx +2 -0
- package/dist/transform-box/engine.d.ts +152 -0
- package/dist/transform-box/engine.d.ts.map +1 -0
- package/dist/transform-box/engine.js +636 -0
- package/dist/transform-box/engine.js.map +1 -0
- package/dist/transform-box/engine.jsx +634 -0
- package/dist/transform-box/geometry.d.ts +129 -0
- package/dist/transform-box/geometry.d.ts.map +1 -0
- package/dist/transform-box/geometry.js +506 -0
- package/dist/transform-box/geometry.js.map +1 -0
- package/dist/transform-box/geometry.jsx +504 -0
- package/dist/transform-box/index.d.ts +4 -0
- package/dist/transform-box/index.d.ts.map +1 -0
- package/dist/transform-box/index.jsx +3 -0
- package/dist/transform-box/transform-box.d.ts +65 -0
- package/dist/transform-box/transform-box.d.ts.map +1 -0
- package/dist/transform-box/transform-box.jsx +104 -0
- package/package.json +56 -4
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** A box on the stage: top-left of the unrotated box, its size, degrees clockwise about its centre. Stage units. */
|
|
2
|
+
export interface TbBox {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
readonly w: number;
|
|
7
|
+
readonly h: number;
|
|
8
|
+
readonly rotation: number;
|
|
9
|
+
/** Selectable, not movable. */
|
|
10
|
+
readonly locked?: boolean;
|
|
11
|
+
/** Corner handles keep the ratio unless shift; true keeps it on edges too. */
|
|
12
|
+
readonly keepAspect?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** An axis-aligned rectangle (stage units): the stage, a safe zone. */
|
|
15
|
+
export interface TbRect {
|
|
16
|
+
readonly x: number;
|
|
17
|
+
readonly y: number;
|
|
18
|
+
readonly w: number;
|
|
19
|
+
readonly h: number;
|
|
20
|
+
readonly label?: string;
|
|
21
|
+
}
|
|
22
|
+
/** A box by its centre (what resizing and rotation work in). */
|
|
23
|
+
export interface TbFrame {
|
|
24
|
+
readonly cx: number;
|
|
25
|
+
readonly cy: number;
|
|
26
|
+
readonly w: number;
|
|
27
|
+
readonly h: number;
|
|
28
|
+
readonly rotation: number;
|
|
29
|
+
}
|
|
30
|
+
/** Stage → element: `screen = offset + stage × scale`. */
|
|
31
|
+
export interface TbFit {
|
|
32
|
+
readonly scale: number;
|
|
33
|
+
readonly ox: number;
|
|
34
|
+
readonly oy: number;
|
|
35
|
+
}
|
|
36
|
+
/** Axis-aligned bounds (stage units). */
|
|
37
|
+
export interface TbAabb {
|
|
38
|
+
readonly x0: number;
|
|
39
|
+
readonly y0: number;
|
|
40
|
+
readonly x1: number;
|
|
41
|
+
readonly y1: number;
|
|
42
|
+
}
|
|
43
|
+
/** A handle of the selection frame: the eight resize handles by compass point, and `rot`. */
|
|
44
|
+
export type TbHandle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'rot';
|
|
45
|
+
/** Each resize handle's direction from the frame's centre (-1, 0 or 1 per axis). */
|
|
46
|
+
export declare const HANDLE_SIGNS: Record<Exclude<TbHandle, 'rot'>, readonly [number, number]>;
|
|
47
|
+
/** The stage fitted inside the element (with padding), then zoomed and panned (CSS px). */
|
|
48
|
+
export declare function fitOf(stage: {
|
|
49
|
+
readonly w: number;
|
|
50
|
+
readonly h: number;
|
|
51
|
+
}, view: {
|
|
52
|
+
readonly w: number;
|
|
53
|
+
readonly h: number;
|
|
54
|
+
}, zoom: number, panX: number, panY: number, padding?: number): TbFit;
|
|
55
|
+
/** Stage units to element px under a fit. */
|
|
56
|
+
export declare function toScreen(fit: TbFit, x: number, y: number): [number, number];
|
|
57
|
+
/** Element px to stage units under a fit. */
|
|
58
|
+
export declare function toStage(fit: TbFit, sx: number, sy: number): [number, number];
|
|
59
|
+
/** Rotates a vector by `deg` degrees clockwise (screen axes). */
|
|
60
|
+
export declare function rotate(x: number, y: number, deg: number): [number, number];
|
|
61
|
+
/** A box as a frame: its centre, size and rotation. */
|
|
62
|
+
export declare function frameOf(box: TbBox): TbFrame;
|
|
63
|
+
/** A frame back as a box with `id`, keeping `from`'s other fields (locked, keepAspect). */
|
|
64
|
+
export declare function boxOfFrame(id: string, frame: TbFrame, from?: TbBox): TbBox;
|
|
65
|
+
/** Corners nw, ne, se, sw. */
|
|
66
|
+
export declare function cornersOf(frame: TbFrame): [number, number][];
|
|
67
|
+
/** The axis-aligned bounds of rotated frames. */
|
|
68
|
+
export declare function aabbOf(frames: readonly TbFrame[]): TbAabb;
|
|
69
|
+
/** The frame the handles sit on: a box's own for one, the bounding box for several. */
|
|
70
|
+
export declare function selectionFrame(boxes: readonly TbBox[]): TbFrame | null;
|
|
71
|
+
/** Whether a point lies inside a rotated frame, `slack` stage units around it included. */
|
|
72
|
+
export declare function contains(frame: TbFrame, x: number, y: number, slack?: number): boolean;
|
|
73
|
+
/** The top box under a stage point (the last one drawn wins). */
|
|
74
|
+
export declare function hitBox(boxes: readonly TbBox[], x: number, y: number, slack?: number): TbBox | null;
|
|
75
|
+
/** Handle positions in element px; the rotation handle sits `rotGap` px above the top edge. */
|
|
76
|
+
export declare function handlePoints(frame: TbFrame, fit: TbFit, rotGap?: number): {
|
|
77
|
+
handle: TbHandle;
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
}[];
|
|
81
|
+
/** The handle within `radius` px of an element point; edge handles only when the box is big enough on screen. */
|
|
82
|
+
export declare function hitHandle(frame: TbFrame, fit: TbFit, x: number, y: number, radius: number): TbHandle | null;
|
|
83
|
+
/** How a resize behaves: keep the aspect, scale from the centre, the smallest side. */
|
|
84
|
+
export interface ResizeOptions {
|
|
85
|
+
readonly keepAspect: boolean;
|
|
86
|
+
readonly fromCenter: boolean;
|
|
87
|
+
/** Smallest side (stage units). */
|
|
88
|
+
readonly min: number;
|
|
89
|
+
}
|
|
90
|
+
/** Resizes `start` by dragging `handle` to stage point (x, y), in the frame's own rotated axes. */
|
|
91
|
+
export declare function resizeFrame(start: TbFrame, handle: Exclude<TbHandle, 'rot'>, x: number, y: number, o: ResizeOptions): TbFrame;
|
|
92
|
+
/** Maps boxes from one selection frame to another (scaled inside it; each keeps its rotation). */
|
|
93
|
+
export declare function mapBoxes(boxes: readonly TbBox[], from: TbFrame, to: TbFrame): TbBox[];
|
|
94
|
+
/** Rotates boxes about a point by `delta` degrees. */
|
|
95
|
+
export declare function rotateBoxes(boxes: readonly TbBox[], cx: number, cy: number, delta: number): TbBox[];
|
|
96
|
+
/** The boxes moved by `dx`, `dy` stage units. */
|
|
97
|
+
export declare function moveBoxes(boxes: readonly TbBox[], dx: number, dy: number): TbBox[];
|
|
98
|
+
/** Degrees in (-180, 180]. */
|
|
99
|
+
export declare function normDeg(d: number): number;
|
|
100
|
+
/** Shift snaps to `step` degrees; otherwise right angles pull within `magnet`. */
|
|
101
|
+
export declare function snapAngle(deg: number, step: number | null, magnet?: number): number;
|
|
102
|
+
/** A guide line to draw (stage units): vertical at x = `at` (axis x) or horizontal at y = `at`. */
|
|
103
|
+
export interface TbGuide {
|
|
104
|
+
readonly axis: 'x' | 'y';
|
|
105
|
+
readonly at: number;
|
|
106
|
+
readonly from: number;
|
|
107
|
+
readonly to: number;
|
|
108
|
+
readonly kind: 'edge' | 'center' | 'gap';
|
|
109
|
+
}
|
|
110
|
+
/** A move after snapping: the corrected offset and the guides to draw. */
|
|
111
|
+
export interface SnapResult {
|
|
112
|
+
readonly dx: number;
|
|
113
|
+
readonly dy: number;
|
|
114
|
+
readonly guides: TbGuide[];
|
|
115
|
+
}
|
|
116
|
+
/** Snaps a moving bounding box to the stage, its safe zones and the other boxes, within `within` stage units. */
|
|
117
|
+
export declare function snapMove(moving: TbAabb, others: readonly TbAabb[], stage: {
|
|
118
|
+
w: number;
|
|
119
|
+
h: number;
|
|
120
|
+
}, zones: readonly TbRect[], within: number): SnapResult;
|
|
121
|
+
/** Snaps the moved edges of an unrotated frame being resized (the far edges stay). */
|
|
122
|
+
export declare function snapResize(frame: TbFrame, handle: Exclude<TbHandle, 'rot'>, others: readonly TbAabb[], stage: {
|
|
123
|
+
w: number;
|
|
124
|
+
h: number;
|
|
125
|
+
}, zones: readonly TbRect[], within: number): {
|
|
126
|
+
frame: TbFrame;
|
|
127
|
+
guides: TbGuide[];
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/transform-box/geometry.ts"],"names":[],"mappings":"AAIA,oHAAoH;AACpH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,uEAAuE;AACvE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC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AAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,MAAM,GACb,UAAU,CAIZ;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAChC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,CA2BvC"}
|
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
const HANDLE_SIGNS = {
|
|
2
|
+
nw: [
|
|
3
|
+
-1,
|
|
4
|
+
-1
|
|
5
|
+
],
|
|
6
|
+
n: [
|
|
7
|
+
0,
|
|
8
|
+
-1
|
|
9
|
+
],
|
|
10
|
+
ne: [
|
|
11
|
+
1,
|
|
12
|
+
-1
|
|
13
|
+
],
|
|
14
|
+
e: [
|
|
15
|
+
1,
|
|
16
|
+
0
|
|
17
|
+
],
|
|
18
|
+
se: [
|
|
19
|
+
1,
|
|
20
|
+
1
|
|
21
|
+
],
|
|
22
|
+
s: [
|
|
23
|
+
0,
|
|
24
|
+
1
|
|
25
|
+
],
|
|
26
|
+
sw: [
|
|
27
|
+
-1,
|
|
28
|
+
1
|
|
29
|
+
],
|
|
30
|
+
w: [
|
|
31
|
+
-1,
|
|
32
|
+
0
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
const DEG = Math.PI / 180;
|
|
36
|
+
function fitOf(stage, view, zoom, panX, panY, padding = 16) {
|
|
37
|
+
const base = Math.max(1e-6, Math.min((view.w - 2 * padding) / stage.w, (view.h - 2 * padding) / stage.h));
|
|
38
|
+
const scale = base * zoom;
|
|
39
|
+
return {
|
|
40
|
+
scale,
|
|
41
|
+
ox: (view.w - stage.w * scale) / 2 + panX,
|
|
42
|
+
oy: (view.h - stage.h * scale) / 2 + panY
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function toScreen(fit, x, y) {
|
|
46
|
+
return [
|
|
47
|
+
fit.ox + x * fit.scale,
|
|
48
|
+
fit.oy + y * fit.scale
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
function toStage(fit, sx, sy) {
|
|
52
|
+
return [
|
|
53
|
+
(sx - fit.ox) / fit.scale,
|
|
54
|
+
(sy - fit.oy) / fit.scale
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
function rotate(x, y, deg) {
|
|
58
|
+
if (!deg) return [
|
|
59
|
+
x,
|
|
60
|
+
y
|
|
61
|
+
];
|
|
62
|
+
const c = Math.cos(deg * DEG);
|
|
63
|
+
const s = Math.sin(deg * DEG);
|
|
64
|
+
return [
|
|
65
|
+
x * c - y * s,
|
|
66
|
+
x * s + y * c
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
function frameOf(box) {
|
|
70
|
+
return {
|
|
71
|
+
cx: box.x + box.w / 2,
|
|
72
|
+
cy: box.y + box.h / 2,
|
|
73
|
+
w: box.w,
|
|
74
|
+
h: box.h,
|
|
75
|
+
rotation: box.rotation
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function boxOfFrame(id, frame, from) {
|
|
79
|
+
return {
|
|
80
|
+
...null != from ? from : {
|
|
81
|
+
id
|
|
82
|
+
},
|
|
83
|
+
id,
|
|
84
|
+
x: frame.cx - frame.w / 2,
|
|
85
|
+
y: frame.cy - frame.h / 2,
|
|
86
|
+
w: frame.w,
|
|
87
|
+
h: frame.h,
|
|
88
|
+
rotation: frame.rotation
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function cornersOf(frame) {
|
|
92
|
+
const hw = frame.w / 2;
|
|
93
|
+
const hh = frame.h / 2;
|
|
94
|
+
return [
|
|
95
|
+
[
|
|
96
|
+
-hw,
|
|
97
|
+
-hh
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
hw,
|
|
101
|
+
-hh
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
hw,
|
|
105
|
+
hh
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
-hw,
|
|
109
|
+
hh
|
|
110
|
+
]
|
|
111
|
+
].map(([x, y])=>{
|
|
112
|
+
const [rx, ry] = rotate(x, y, frame.rotation);
|
|
113
|
+
return [
|
|
114
|
+
frame.cx + rx,
|
|
115
|
+
frame.cy + ry
|
|
116
|
+
];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function aabbOf(frames) {
|
|
120
|
+
let x0 = 1 / 0;
|
|
121
|
+
let y0 = 1 / 0;
|
|
122
|
+
let x1 = -1 / 0;
|
|
123
|
+
let y1 = -1 / 0;
|
|
124
|
+
for (const f of frames)for (const [x, y] of cornersOf(f)){
|
|
125
|
+
x0 = Math.min(x0, x);
|
|
126
|
+
y0 = Math.min(y0, y);
|
|
127
|
+
x1 = Math.max(x1, x);
|
|
128
|
+
y1 = Math.max(y1, y);
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
x0,
|
|
132
|
+
y0,
|
|
133
|
+
x1,
|
|
134
|
+
y1
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function selectionFrame(boxes) {
|
|
138
|
+
if (!boxes.length) return null;
|
|
139
|
+
if (1 === boxes.length) return frameOf(boxes[0]);
|
|
140
|
+
const a = aabbOf(boxes.map(frameOf));
|
|
141
|
+
return {
|
|
142
|
+
cx: (a.x0 + a.x1) / 2,
|
|
143
|
+
cy: (a.y0 + a.y1) / 2,
|
|
144
|
+
w: a.x1 - a.x0,
|
|
145
|
+
h: a.y1 - a.y0,
|
|
146
|
+
rotation: 0
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function contains(frame, x, y, slack = 0) {
|
|
150
|
+
const [lx, ly] = rotate(x - frame.cx, y - frame.cy, -frame.rotation);
|
|
151
|
+
return Math.abs(lx) <= frame.w / 2 + slack && Math.abs(ly) <= frame.h / 2 + slack;
|
|
152
|
+
}
|
|
153
|
+
function hitBox(boxes, x, y, slack = 0) {
|
|
154
|
+
for(let i = boxes.length - 1; i >= 0; i--){
|
|
155
|
+
const box = boxes[i];
|
|
156
|
+
if (contains(frameOf(box), x, y, slack)) return box;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
function handlePoints(frame, fit, rotGap = 28) {
|
|
161
|
+
const out = [];
|
|
162
|
+
for (const handle of Object.keys(HANDLE_SIGNS)){
|
|
163
|
+
const [hx, hy] = HANDLE_SIGNS[handle];
|
|
164
|
+
const [rx, ry] = rotate(hx * frame.w / 2, hy * frame.h / 2, frame.rotation);
|
|
165
|
+
const [sx, sy] = toScreen(fit, frame.cx + rx, frame.cy + ry);
|
|
166
|
+
out.push({
|
|
167
|
+
handle,
|
|
168
|
+
x: sx,
|
|
169
|
+
y: sy
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const [rx, ry] = rotate(0, -frame.h / 2 - rotGap / fit.scale, frame.rotation);
|
|
173
|
+
const [sx, sy] = toScreen(fit, frame.cx + rx, frame.cy + ry);
|
|
174
|
+
out.push({
|
|
175
|
+
handle: 'rot',
|
|
176
|
+
x: sx,
|
|
177
|
+
y: sy
|
|
178
|
+
});
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
function hitHandle(frame, fit, x, y, radius) {
|
|
182
|
+
var _ref;
|
|
183
|
+
const small = Math.min(frame.w, frame.h) * fit.scale < 4 * radius;
|
|
184
|
+
let best = null;
|
|
185
|
+
for (const p of handlePoints(frame, fit)){
|
|
186
|
+
if (small && 1 === p.handle.length) continue;
|
|
187
|
+
const d = Math.hypot(p.x - x, p.y - y);
|
|
188
|
+
if (d <= radius && (!best || d < best.d)) best = {
|
|
189
|
+
handle: p.handle,
|
|
190
|
+
d
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return null != (_ref = null == best ? void 0 : best.handle) ? _ref : null;
|
|
194
|
+
}
|
|
195
|
+
function resizeFrame(start, handle, x, y, o) {
|
|
196
|
+
const [hx, hy] = HANDLE_SIGNS[handle];
|
|
197
|
+
const [px, py] = rotate(x - start.cx, y - start.cy, -start.rotation);
|
|
198
|
+
const ax = o.fromCenter ? 0 : -hx * start.w / 2;
|
|
199
|
+
const ay = o.fromCenter ? 0 : -hy * start.h / 2;
|
|
200
|
+
const k = o.fromCenter ? 2 : 1;
|
|
201
|
+
let w = hx ? Math.max(o.min, hx * (px - ax) * k) : start.w;
|
|
202
|
+
let h = hy ? Math.max(o.min, hy * (py - ay) * k) : start.h;
|
|
203
|
+
if (o.keepAspect) {
|
|
204
|
+
const ratio = start.w / start.h;
|
|
205
|
+
if (hx && hy) {
|
|
206
|
+
const s = Math.max(w / start.w, h / start.h);
|
|
207
|
+
w = Math.max(o.min, start.w * s);
|
|
208
|
+
h = Math.max(o.min, w / ratio);
|
|
209
|
+
} else if (hx) h = Math.max(o.min, w / ratio);
|
|
210
|
+
else w = Math.max(o.min, h * ratio);
|
|
211
|
+
}
|
|
212
|
+
const lcx = o.fromCenter || !hx ? 0 : ax + hx * w / 2;
|
|
213
|
+
const lcy = o.fromCenter || !hy ? 0 : ay + hy * h / 2;
|
|
214
|
+
const [rx, ry] = rotate(lcx, lcy, start.rotation);
|
|
215
|
+
return {
|
|
216
|
+
cx: start.cx + rx,
|
|
217
|
+
cy: start.cy + ry,
|
|
218
|
+
w,
|
|
219
|
+
h,
|
|
220
|
+
rotation: start.rotation
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function mapBoxes(boxes, from, to) {
|
|
224
|
+
const sx = to.w / Math.max(1e-9, from.w);
|
|
225
|
+
const sy = to.h / Math.max(1e-9, from.h);
|
|
226
|
+
if (1 === boxes.length) return [
|
|
227
|
+
boxOfFrame(boxes[0].id, to, boxes[0])
|
|
228
|
+
];
|
|
229
|
+
return boxes.map((box)=>{
|
|
230
|
+
const f = frameOf(box);
|
|
231
|
+
const [lx, ly] = rotate(f.cx - from.cx, f.cy - from.cy, -from.rotation);
|
|
232
|
+
const [rx, ry] = rotate(lx * sx, ly * sy, to.rotation);
|
|
233
|
+
const rel = ((box.rotation - from.rotation) % 180 + 180) % 180;
|
|
234
|
+
const quarter = Math.abs(rel - 90) < 1;
|
|
235
|
+
const straight = rel < 1 || rel > 179;
|
|
236
|
+
const w = straight ? f.w * sx : quarter ? f.w * sy : f.w * Math.sqrt(sx * sy);
|
|
237
|
+
const h = straight ? f.h * sy : quarter ? f.h * sx : f.h * Math.sqrt(sx * sy);
|
|
238
|
+
return boxOfFrame(box.id, {
|
|
239
|
+
cx: to.cx + rx,
|
|
240
|
+
cy: to.cy + ry,
|
|
241
|
+
w,
|
|
242
|
+
h,
|
|
243
|
+
rotation: box.rotation
|
|
244
|
+
}, box);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function rotateBoxes(boxes, cx, cy, delta) {
|
|
248
|
+
return boxes.map((box)=>{
|
|
249
|
+
const f = frameOf(box);
|
|
250
|
+
const [rx, ry] = rotate(f.cx - cx, f.cy - cy, delta);
|
|
251
|
+
return boxOfFrame(box.id, {
|
|
252
|
+
...f,
|
|
253
|
+
cx: cx + rx,
|
|
254
|
+
cy: cy + ry,
|
|
255
|
+
rotation: normDeg(box.rotation + delta)
|
|
256
|
+
}, box);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function moveBoxes(boxes, dx, dy) {
|
|
260
|
+
return boxes.map((b)=>({
|
|
261
|
+
...b,
|
|
262
|
+
x: b.x + dx,
|
|
263
|
+
y: b.y + dy
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
function normDeg(d) {
|
|
267
|
+
let v = d % 360;
|
|
268
|
+
if (v <= -180) v += 360;
|
|
269
|
+
if (v > 180) v -= 360;
|
|
270
|
+
return Math.round(1000 * v) / 1000;
|
|
271
|
+
}
|
|
272
|
+
function snapAngle(deg, step, magnet = 3) {
|
|
273
|
+
if (step) return normDeg(Math.round(deg / step) * step);
|
|
274
|
+
const right = 90 * Math.round(deg / 90);
|
|
275
|
+
return Math.abs(deg - right) <= magnet ? normDeg(right) : normDeg(deg);
|
|
276
|
+
}
|
|
277
|
+
function targetsOf(axis, others, stage, zones) {
|
|
278
|
+
const out = [];
|
|
279
|
+
const full = 'x' === axis ? [
|
|
280
|
+
0,
|
|
281
|
+
stage.h
|
|
282
|
+
] : [
|
|
283
|
+
0,
|
|
284
|
+
stage.w
|
|
285
|
+
];
|
|
286
|
+
const size = 'x' === axis ? stage.w : stage.h;
|
|
287
|
+
out.push({
|
|
288
|
+
v: 0,
|
|
289
|
+
kind: 'edge',
|
|
290
|
+
span: full
|
|
291
|
+
}, {
|
|
292
|
+
v: size / 2,
|
|
293
|
+
kind: 'center',
|
|
294
|
+
span: full
|
|
295
|
+
}, {
|
|
296
|
+
v: size,
|
|
297
|
+
kind: 'edge',
|
|
298
|
+
span: full
|
|
299
|
+
});
|
|
300
|
+
for (const z of zones){
|
|
301
|
+
const a = 'x' === axis ? z.x : z.y;
|
|
302
|
+
const len = 'x' === axis ? z.w : z.h;
|
|
303
|
+
const span = 'x' === axis ? [
|
|
304
|
+
z.y,
|
|
305
|
+
z.y + z.h
|
|
306
|
+
] : [
|
|
307
|
+
z.x,
|
|
308
|
+
z.x + z.w
|
|
309
|
+
];
|
|
310
|
+
out.push({
|
|
311
|
+
v: a,
|
|
312
|
+
kind: 'edge',
|
|
313
|
+
span
|
|
314
|
+
}, {
|
|
315
|
+
v: a + len,
|
|
316
|
+
kind: 'edge',
|
|
317
|
+
span
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
for (const o of others){
|
|
321
|
+
const a0 = 'x' === axis ? o.x0 : o.y0;
|
|
322
|
+
const a1 = 'x' === axis ? o.x1 : o.y1;
|
|
323
|
+
const span = 'x' === axis ? [
|
|
324
|
+
o.y0,
|
|
325
|
+
o.y1
|
|
326
|
+
] : [
|
|
327
|
+
o.x0,
|
|
328
|
+
o.x1
|
|
329
|
+
];
|
|
330
|
+
out.push({
|
|
331
|
+
v: a0,
|
|
332
|
+
kind: 'edge',
|
|
333
|
+
span
|
|
334
|
+
}, {
|
|
335
|
+
v: (a0 + a1) / 2,
|
|
336
|
+
kind: 'center',
|
|
337
|
+
span
|
|
338
|
+
}, {
|
|
339
|
+
v: a1,
|
|
340
|
+
kind: 'edge',
|
|
341
|
+
span
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
function snapAxis(axis, m, others, stage, zones, within) {
|
|
347
|
+
const a0 = 'x' === axis ? m.x0 : m.y0;
|
|
348
|
+
const a1 = 'x' === axis ? m.x1 : m.y1;
|
|
349
|
+
const mine = [
|
|
350
|
+
{
|
|
351
|
+
v: a0,
|
|
352
|
+
kind: 'edge'
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
v: (a0 + a1) / 2,
|
|
356
|
+
kind: 'center'
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
v: a1,
|
|
360
|
+
kind: 'edge'
|
|
361
|
+
}
|
|
362
|
+
];
|
|
363
|
+
const mSpan = 'x' === axis ? [
|
|
364
|
+
m.y0,
|
|
365
|
+
m.y1
|
|
366
|
+
] : [
|
|
367
|
+
m.x0,
|
|
368
|
+
m.x1
|
|
369
|
+
];
|
|
370
|
+
let best = null;
|
|
371
|
+
for (const t of targetsOf(axis, others, stage, zones))for (const v of mine){
|
|
372
|
+
const d = t.v - v.v;
|
|
373
|
+
if (Math.abs(d) <= within && (!best || Math.abs(d) < Math.abs(best.d) - 1e-9)) best = {
|
|
374
|
+
d,
|
|
375
|
+
at: t.v,
|
|
376
|
+
span: t.span,
|
|
377
|
+
kind: 'center' === v.kind && 'center' === t.kind ? 'center' : 'edge'
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
let gap = null;
|
|
381
|
+
const across = (o)=>'x' === axis ? o.y0 < m.y1 && o.y1 > m.y0 : o.x0 < m.x1 && o.x1 > m.x0;
|
|
382
|
+
let before = null;
|
|
383
|
+
let after = null;
|
|
384
|
+
for (const o of others){
|
|
385
|
+
if (!across(o)) continue;
|
|
386
|
+
const o0 = 'x' === axis ? o.x0 : o.y0;
|
|
387
|
+
const o1 = 'x' === axis ? o.x1 : o.y1;
|
|
388
|
+
if (o1 <= a0 + within && (!before || o1 > ('x' === axis ? before.x1 : before.y1))) before = o;
|
|
389
|
+
if (o0 >= a1 - within && (!after || o0 < ('x' === axis ? after.x0 : after.y0))) after = o;
|
|
390
|
+
}
|
|
391
|
+
if (before && after) {
|
|
392
|
+
const b1 = 'x' === axis ? before.x1 : before.y1;
|
|
393
|
+
const f0 = 'x' === axis ? after.x0 : after.y0;
|
|
394
|
+
const size = a1 - a0;
|
|
395
|
+
const want = (b1 + f0) / 2 - size / 2;
|
|
396
|
+
const d = want - a0;
|
|
397
|
+
if (Math.abs(d) <= within && f0 - b1 > size) {
|
|
398
|
+
const mid = (mSpan[0] + mSpan[1]) / 2;
|
|
399
|
+
const other = 'x' === axis ? 'y' : 'x';
|
|
400
|
+
gap = {
|
|
401
|
+
d,
|
|
402
|
+
guides: [
|
|
403
|
+
{
|
|
404
|
+
axis: other,
|
|
405
|
+
at: mid,
|
|
406
|
+
from: b1,
|
|
407
|
+
to: want,
|
|
408
|
+
kind: 'gap'
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
axis: other,
|
|
412
|
+
at: mid,
|
|
413
|
+
from: want + size,
|
|
414
|
+
to: f0,
|
|
415
|
+
kind: 'gap'
|
|
416
|
+
}
|
|
417
|
+
]
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (gap && (!best || Math.abs(gap.d) < Math.abs(best.d))) return gap;
|
|
422
|
+
if (!best) return {
|
|
423
|
+
d: 0,
|
|
424
|
+
guides: []
|
|
425
|
+
};
|
|
426
|
+
const from = Math.min(best.span[0], mSpan[0]);
|
|
427
|
+
const to = Math.max(best.span[1], mSpan[1]);
|
|
428
|
+
return {
|
|
429
|
+
d: best.d,
|
|
430
|
+
guides: [
|
|
431
|
+
{
|
|
432
|
+
axis,
|
|
433
|
+
at: best.at,
|
|
434
|
+
from,
|
|
435
|
+
to,
|
|
436
|
+
kind: best.kind
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function snapMove(moving, others, stage, zones, within) {
|
|
442
|
+
const x = snapAxis('x', moving, others, stage, zones, within);
|
|
443
|
+
const y = snapAxis('y', moving, others, stage, zones, within);
|
|
444
|
+
return {
|
|
445
|
+
dx: x.d,
|
|
446
|
+
dy: y.d,
|
|
447
|
+
guides: [
|
|
448
|
+
...x.guides,
|
|
449
|
+
...y.guides
|
|
450
|
+
]
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function snapResize(frame, handle, others, stage, zones, within) {
|
|
454
|
+
if (0 !== frame.rotation) return {
|
|
455
|
+
frame,
|
|
456
|
+
guides: []
|
|
457
|
+
};
|
|
458
|
+
const [hx, hy] = HANDLE_SIGNS[handle];
|
|
459
|
+
let x0 = frame.cx - frame.w / 2;
|
|
460
|
+
let x1 = frame.cx + frame.w / 2;
|
|
461
|
+
let y0 = frame.cy - frame.h / 2;
|
|
462
|
+
let y1 = frame.cy + frame.h / 2;
|
|
463
|
+
const guides = [];
|
|
464
|
+
const pick = (axis, v, span)=>{
|
|
465
|
+
let best = null;
|
|
466
|
+
for (const t of targetsOf(axis, others, stage, zones))if (Math.abs(t.v - v) <= within && (!best || Math.abs(t.v - v) < Math.abs(best.v - v))) best = t;
|
|
467
|
+
if (!best) return v;
|
|
468
|
+
guides.push({
|
|
469
|
+
axis,
|
|
470
|
+
at: best.v,
|
|
471
|
+
from: Math.min(span[0], best.span[0]),
|
|
472
|
+
to: Math.max(span[1], best.span[1]),
|
|
473
|
+
kind: 'edge'
|
|
474
|
+
});
|
|
475
|
+
return best.v;
|
|
476
|
+
};
|
|
477
|
+
if (hx > 0) x1 = pick('x', x1, [
|
|
478
|
+
y0,
|
|
479
|
+
y1
|
|
480
|
+
]);
|
|
481
|
+
if (hx < 0) x0 = pick('x', x0, [
|
|
482
|
+
y0,
|
|
483
|
+
y1
|
|
484
|
+
]);
|
|
485
|
+
if (hy > 0) y1 = pick('y', y1, [
|
|
486
|
+
x0,
|
|
487
|
+
x1
|
|
488
|
+
]);
|
|
489
|
+
if (hy < 0) y0 = pick('y', y0, [
|
|
490
|
+
x0,
|
|
491
|
+
x1
|
|
492
|
+
]);
|
|
493
|
+
return {
|
|
494
|
+
frame: {
|
|
495
|
+
cx: (x0 + x1) / 2,
|
|
496
|
+
cy: (y0 + y1) / 2,
|
|
497
|
+
w: x1 - x0,
|
|
498
|
+
h: y1 - y0,
|
|
499
|
+
rotation: 0
|
|
500
|
+
},
|
|
501
|
+
guides
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
export { HANDLE_SIGNS, aabbOf, boxOfFrame, contains, cornersOf, fitOf, frameOf, handlePoints, hitBox, hitHandle, mapBoxes, moveBoxes, normDeg, resizeFrame, rotate, rotateBoxes, selectionFrame, snapAngle, snapMove, snapResize, toScreen, toStage };
|
|
505
|
+
|
|
506
|
+
//# sourceMappingURL=geometry.js.map
|