@nokecy/designer-shared 0.0.0-stage → 2.0.0-beta.11
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 +21 -0
- package/LICENSE.md +21 -0
- package/PROVENANCE.json +35 -0
- package/README.md +9 -2
- package/esm/animation.d.ts +2 -0
- package/esm/animation.js +34 -0
- package/esm/animation.js.map +1 -0
- package/esm/array.d.ts +37 -0
- package/esm/array.js +112 -0
- package/esm/array.js.map +1 -0
- package/esm/clone.d.ts +4 -0
- package/esm/clone.js +106 -0
- package/esm/clone.js.map +1 -0
- package/esm/compose.d.ts +1 -0
- package/esm/compose.js +8 -0
- package/esm/compose.js.map +1 -0
- package/esm/coordinate.d.ts +106 -0
- package/esm/coordinate.js +485 -0
- package/esm/coordinate.js.map +1 -0
- package/esm/element.d.ts +6 -0
- package/esm/element.js +138 -0
- package/esm/element.js.map +1 -0
- package/esm/event.d.ts +81 -0
- package/esm/event.js +214 -0
- package/esm/event.js.map +1 -0
- package/esm/globalThisPolyfill.d.ts +1 -0
- package/esm/globalThisPolyfill.js +23 -0
- package/esm/globalThisPolyfill.js.map +1 -0
- package/esm/index.d.ts +17 -0
- package/esm/index.js +18 -0
- package/esm/index.js.map +1 -0
- package/esm/instanceof.d.ts +1 -0
- package/esm/instanceof.js +12 -0
- package/esm/instanceof.js.map +1 -0
- package/esm/keycode.d.ts +147 -0
- package/esm/keycode.js +151 -0
- package/esm/keycode.js.map +1 -0
- package/esm/lru.d.ts +73 -0
- package/esm/lru.js +294 -0
- package/esm/lru.js.map +1 -0
- package/esm/observer.d.ts +9 -0
- package/esm/observer.js +30 -0
- package/esm/observer.js.map +1 -0
- package/esm/request-idle.d.ts +10 -0
- package/esm/request-idle.js +9 -0
- package/esm/request-idle.js.map +1 -0
- package/esm/scroller.d.ts +10 -0
- package/esm/scroller.js +83 -0
- package/esm/scroller.js.map +1 -0
- package/esm/subscribable.d.ts +14 -0
- package/esm/subscribable.js +49 -0
- package/esm/subscribable.js.map +1 -0
- package/esm/types.d.ts +13 -0
- package/esm/types.js +22 -0
- package/esm/types.js.map +1 -0
- package/esm/uid.d.ts +1 -0
- package/esm/uid.js +10 -0
- package/esm/uid.js.map +1 -0
- package/lib/animation.d.ts +2 -0
- package/lib/animation.js +39 -0
- package/lib/animation.js.map +1 -0
- package/lib/array.d.ts +37 -0
- package/lib/array.js +126 -0
- package/lib/array.js.map +1 -0
- package/lib/clone.d.ts +4 -0
- package/lib/clone.js +111 -0
- package/lib/clone.js.map +1 -0
- package/lib/compose.d.ts +1 -0
- package/lib/compose.js +12 -0
- package/lib/compose.js.map +1 -0
- package/lib/coordinate.d.ts +106 -0
- package/lib/coordinate.js +514 -0
- package/lib/coordinate.js.map +1 -0
- package/lib/element.d.ts +6 -0
- package/lib/element.js +146 -0
- package/lib/element.js.map +1 -0
- package/lib/event.d.ts +81 -0
- package/lib/event.js +219 -0
- package/lib/event.js.map +1 -0
- package/lib/globalThisPolyfill.d.ts +1 -0
- package/lib/globalThisPolyfill.js +26 -0
- package/lib/globalThisPolyfill.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +34 -0
- package/lib/index.js.map +1 -0
- package/lib/instanceof.d.ts +1 -0
- package/lib/instanceof.js +16 -0
- package/lib/instanceof.js.map +1 -0
- package/lib/keycode.d.ts +147 -0
- package/lib/keycode.js +155 -0
- package/lib/keycode.js.map +1 -0
- package/lib/lru.d.ts +73 -0
- package/lib/lru.js +298 -0
- package/lib/lru.js.map +1 -0
- package/lib/observer.d.ts +9 -0
- package/lib/observer.js +34 -0
- package/lib/observer.js.map +1 -0
- package/lib/request-idle.d.ts +10 -0
- package/lib/request-idle.js +14 -0
- package/lib/request-idle.js.map +1 -0
- package/lib/scroller.d.ts +10 -0
- package/lib/scroller.js +89 -0
- package/lib/scroller.js.map +1 -0
- package/lib/subscribable.d.ts +14 -0
- package/lib/subscribable.js +53 -0
- package/lib/subscribable.js.map +1 -0
- package/lib/types.d.ts +13 -0
- package/lib/types.js +30 -0
- package/lib/types.js.map +1 -0
- package/lib/uid.d.ts +1 -0
- package/lib/uid.js +13 -0
- package/lib/uid.js.map +1 -0
- package/package.json +46 -4
- package/src/animation.ts +38 -0
- package/src/array.ts +301 -0
- package/src/clone.ts +105 -0
- package/src/compose.ts +7 -0
- package/src/coordinate.ts +640 -0
- package/src/element.ts +144 -0
- package/src/event.ts +395 -0
- package/src/globalThisPolyfill.ts +19 -0
- package/src/index.ts +17 -0
- package/src/instanceof.ts +10 -0
- package/src/keycode.ts +150 -0
- package/src/lru.ts +322 -0
- package/src/observer.ts +38 -0
- package/src/request-idle.ts +22 -0
- package/src/scroller.ts +113 -0
- package/src/subscribable.ts +60 -0
- package/src/types.ts +27 -0
- package/src/uid.ts +10 -0
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RectQuadrant = exports.LineSegment = exports.Rect = exports.Point = void 0;
|
|
4
|
+
exports.isRect = isRect;
|
|
5
|
+
exports.isPoint = isPoint;
|
|
6
|
+
exports.isLineSegment = isLineSegment;
|
|
7
|
+
exports.isPointInRect = isPointInRect;
|
|
8
|
+
exports.isEqualRect = isEqualRect;
|
|
9
|
+
exports.getRectPoints = getRectPoints;
|
|
10
|
+
exports.isRectInRect = isRectInRect;
|
|
11
|
+
exports.isCrossRectInRect = isCrossRectInRect;
|
|
12
|
+
exports.calcQuadrantOfPointToRect = calcQuadrantOfPointToRect;
|
|
13
|
+
exports.calcDistanceOfPointToRect = calcDistanceOfPointToRect;
|
|
14
|
+
exports.calcDistancePointToEdge = calcDistancePointToEdge;
|
|
15
|
+
exports.isNearAfter = isNearAfter;
|
|
16
|
+
exports.calcRelativeOfPointToRect = calcRelativeOfPointToRect;
|
|
17
|
+
exports.calcBoundingRect = calcBoundingRect;
|
|
18
|
+
exports.calcRectByStartEndPoint = calcRectByStartEndPoint;
|
|
19
|
+
exports.calcEdgeLinesOfRect = calcEdgeLinesOfRect;
|
|
20
|
+
exports.calcRectOfAxisLineSegment = calcRectOfAxisLineSegment;
|
|
21
|
+
exports.calcSpaceBlockOfRect = calcSpaceBlockOfRect;
|
|
22
|
+
exports.calcExtendsLineSegmentOfRect = calcExtendsLineSegmentOfRect;
|
|
23
|
+
exports.calcOffsetOfSnapLineSegmentToEdge = calcOffsetOfSnapLineSegmentToEdge;
|
|
24
|
+
exports.calcDistanceOfSnapLineToEdges = calcDistanceOfSnapLineToEdges;
|
|
25
|
+
exports.calcCombineSnapLineSegment = calcCombineSnapLineSegment;
|
|
26
|
+
exports.calcClosestEdges = calcClosestEdges;
|
|
27
|
+
const types_1 = require("./types");
|
|
28
|
+
function isRect(rect) {
|
|
29
|
+
return (rect === null || rect === void 0 ? void 0 : rect.x) && (rect === null || rect === void 0 ? void 0 : rect.y) && (rect === null || rect === void 0 ? void 0 : rect.width) && (rect === null || rect === void 0 ? void 0 : rect.height);
|
|
30
|
+
}
|
|
31
|
+
function isPoint(val) {
|
|
32
|
+
return (0, types_1.isValidNumber)(val === null || val === void 0 ? void 0 : val.x) && (0, types_1.isValidNumber)(val === null || val === void 0 ? void 0 : val.y);
|
|
33
|
+
}
|
|
34
|
+
function isLineSegment(val) {
|
|
35
|
+
return isPoint(val === null || val === void 0 ? void 0 : val.start) && isPoint(val === null || val === void 0 ? void 0 : val.end);
|
|
36
|
+
}
|
|
37
|
+
class Point {
|
|
38
|
+
constructor(x, y) {
|
|
39
|
+
this.x = x || 0;
|
|
40
|
+
this.y = y || 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Point = Point;
|
|
44
|
+
class Rect {
|
|
45
|
+
constructor(x, y, width, height) {
|
|
46
|
+
this.x = 0;
|
|
47
|
+
this.y = 0;
|
|
48
|
+
this.width = 0;
|
|
49
|
+
this.height = 0;
|
|
50
|
+
this.x = x;
|
|
51
|
+
this.y = y;
|
|
52
|
+
this.width = width || 0;
|
|
53
|
+
this.height = height || 0;
|
|
54
|
+
}
|
|
55
|
+
get left() {
|
|
56
|
+
return this.x;
|
|
57
|
+
}
|
|
58
|
+
get right() {
|
|
59
|
+
return this.x + this.width;
|
|
60
|
+
}
|
|
61
|
+
get top() {
|
|
62
|
+
return this.y;
|
|
63
|
+
}
|
|
64
|
+
get bottom() {
|
|
65
|
+
return this.y + this.height;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Rect = Rect;
|
|
69
|
+
class LineSegment {
|
|
70
|
+
constructor(start, end) {
|
|
71
|
+
this.start = { ...start };
|
|
72
|
+
this.end = { ...end };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.LineSegment = LineSegment;
|
|
76
|
+
var RectQuadrant;
|
|
77
|
+
(function (RectQuadrant) {
|
|
78
|
+
RectQuadrant["Inner1"] = "I1";
|
|
79
|
+
RectQuadrant["Inner2"] = "I2";
|
|
80
|
+
RectQuadrant["Inner3"] = "I3";
|
|
81
|
+
RectQuadrant["Inner4"] = "I4";
|
|
82
|
+
RectQuadrant["Outer1"] = "O1";
|
|
83
|
+
RectQuadrant["Outer2"] = "O2";
|
|
84
|
+
RectQuadrant["Outer3"] = "O3";
|
|
85
|
+
RectQuadrant["Outer4"] = "O4";
|
|
86
|
+
})(RectQuadrant || (exports.RectQuadrant = RectQuadrant = {}));
|
|
87
|
+
function isPointInRect(point, rect, sensitive = true) {
|
|
88
|
+
const boundSensor = (value) => {
|
|
89
|
+
if (!sensitive)
|
|
90
|
+
return 0;
|
|
91
|
+
const sensor = value * 0.1;
|
|
92
|
+
if (sensor > 20)
|
|
93
|
+
return 20;
|
|
94
|
+
if (sensor < 10)
|
|
95
|
+
return 10;
|
|
96
|
+
return sensor;
|
|
97
|
+
};
|
|
98
|
+
return (point.x >= rect.x + boundSensor(rect.width) &&
|
|
99
|
+
point.x <= rect.x + rect.width - boundSensor(rect.width) &&
|
|
100
|
+
point.y >= rect.y + boundSensor(rect.height) &&
|
|
101
|
+
point.y <= rect.y + rect.height - boundSensor(rect.height));
|
|
102
|
+
}
|
|
103
|
+
function isEqualRect(target, source) {
|
|
104
|
+
return (target &&
|
|
105
|
+
source &&
|
|
106
|
+
target.x === source.x &&
|
|
107
|
+
target.y === source.y &&
|
|
108
|
+
target.width === source.width &&
|
|
109
|
+
target.height === source.height);
|
|
110
|
+
}
|
|
111
|
+
function getRectPoints(source) {
|
|
112
|
+
const p1 = new Point(source.x, source.y);
|
|
113
|
+
const p2 = new Point(source.x + source.width, source.y);
|
|
114
|
+
const p3 = new Point(source.x + source.width, source.y + source.height);
|
|
115
|
+
const p4 = new Point(source.x, source.y + source.height);
|
|
116
|
+
return [p1, p2, p3, p4];
|
|
117
|
+
}
|
|
118
|
+
function isRectInRect(target, source) {
|
|
119
|
+
const [p1, p2, p3, p4] = getRectPoints(target);
|
|
120
|
+
return (isPointInRect(p1, source, false) &&
|
|
121
|
+
isPointInRect(p2, source, false) &&
|
|
122
|
+
isPointInRect(p3, source, false) &&
|
|
123
|
+
isPointInRect(p4, source, false));
|
|
124
|
+
}
|
|
125
|
+
function isCrossRectInRect(target, source) {
|
|
126
|
+
const targetCenterPoint = new Point(target.x + target.width / 2, target.y + target.height / 2);
|
|
127
|
+
const sourceCenterPoint = new Point(source.x + source.width / 2, source.y + source.height / 2);
|
|
128
|
+
return (Math.abs(targetCenterPoint.x - sourceCenterPoint.x) <=
|
|
129
|
+
target.width / 2 + source.width / 2 &&
|
|
130
|
+
Math.abs(targetCenterPoint.y - sourceCenterPoint.y) <=
|
|
131
|
+
target.height / 2 + source.height / 2);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 计算点在矩形的哪个象限
|
|
135
|
+
* @param point
|
|
136
|
+
* @param rect
|
|
137
|
+
*/
|
|
138
|
+
function calcQuadrantOfPointToRect(point, rect) {
|
|
139
|
+
const isInner = isPointInRect(point, rect);
|
|
140
|
+
if (point.x <= rect.x + rect.width / 2) {
|
|
141
|
+
if (point.y <= rect.y + rect.height / 2) {
|
|
142
|
+
if (isInner) {
|
|
143
|
+
return RectQuadrant.Inner1;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return RectQuadrant.Outer1;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (isInner) {
|
|
151
|
+
return RectQuadrant.Inner4;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return RectQuadrant.Outer4;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
if (point.y <= rect.y + rect.height / 2) {
|
|
160
|
+
if (isInner) {
|
|
161
|
+
return RectQuadrant.Inner2;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
return RectQuadrant.Outer2;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
if (isInner) {
|
|
169
|
+
return RectQuadrant.Inner3;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
return RectQuadrant.Outer3;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function calcDistanceOfPointToRect(point, rect) {
|
|
178
|
+
let minX = Math.min(Math.abs(point.x - rect.x), Math.abs(point.x - (rect.x + rect.width)));
|
|
179
|
+
let minY = Math.min(Math.abs(point.y - rect.y), Math.abs(point.y - (rect.y + rect.height)));
|
|
180
|
+
if (point.x >= rect.x && point.x <= rect.x + rect.width) {
|
|
181
|
+
minX = 0;
|
|
182
|
+
}
|
|
183
|
+
if (point.y >= rect.y && point.y <= rect.y + rect.height) {
|
|
184
|
+
minY = 0;
|
|
185
|
+
}
|
|
186
|
+
return Math.sqrt(minX ** 2 + minY ** 2);
|
|
187
|
+
}
|
|
188
|
+
function calcDistancePointToEdge(point, rect) {
|
|
189
|
+
const distanceTop = Math.abs(point.y - rect.y);
|
|
190
|
+
const distanceBottom = Math.abs(point.y - (rect.y + rect.height));
|
|
191
|
+
const distanceLeft = Math.abs(point.x - rect.x);
|
|
192
|
+
const distanceRight = Math.abs(point.x - (rect.x + rect.width));
|
|
193
|
+
return Math.min(distanceTop, distanceBottom, distanceLeft, distanceRight);
|
|
194
|
+
}
|
|
195
|
+
function isNearAfter(point, rect, inline = false) {
|
|
196
|
+
if (inline) {
|
|
197
|
+
return (Math.abs(point.x - rect.x) + Math.abs(point.y - rect.y) >
|
|
198
|
+
Math.abs(point.x - (rect.x + rect.width)) +
|
|
199
|
+
Math.abs(point.y - (rect.y + rect.height)));
|
|
200
|
+
}
|
|
201
|
+
return Math.abs(point.y - rect.y) > Math.abs(point.y - (rect.y + rect.height));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 计算点鱼矩形的相对位置信息
|
|
205
|
+
* @param point
|
|
206
|
+
* @param rect
|
|
207
|
+
*/
|
|
208
|
+
function calcRelativeOfPointToRect(point, rect) {
|
|
209
|
+
const distance = calcDistanceOfPointToRect(point, rect);
|
|
210
|
+
const quadrant = calcQuadrantOfPointToRect(point, rect);
|
|
211
|
+
return {
|
|
212
|
+
quadrant,
|
|
213
|
+
distance,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function calcBoundingRect(rects) {
|
|
217
|
+
if (!(rects === null || rects === void 0 ? void 0 : rects.length))
|
|
218
|
+
return;
|
|
219
|
+
if ((rects === null || rects === void 0 ? void 0 : rects.length) === 1 && !rects[0])
|
|
220
|
+
return;
|
|
221
|
+
let minTop = Infinity;
|
|
222
|
+
let maxBottom = -Infinity;
|
|
223
|
+
let minLeft = Infinity;
|
|
224
|
+
let maxRight = -Infinity;
|
|
225
|
+
rects.forEach((item) => {
|
|
226
|
+
const rect = new Rect(item.x, item.y, item.width, item.height);
|
|
227
|
+
if (rect.top <= minTop) {
|
|
228
|
+
minTop = rect.top;
|
|
229
|
+
}
|
|
230
|
+
if (rect.bottom >= maxBottom) {
|
|
231
|
+
maxBottom = rect.bottom;
|
|
232
|
+
}
|
|
233
|
+
if (rect.left <= minLeft) {
|
|
234
|
+
minLeft = rect.left;
|
|
235
|
+
}
|
|
236
|
+
if (rect.right >= maxRight) {
|
|
237
|
+
maxRight = rect.right;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return new Rect(minLeft, minTop, maxRight - minLeft, maxBottom - minTop);
|
|
241
|
+
}
|
|
242
|
+
function calcRectByStartEndPoint(startPoint, endPoint, scrollX = 0, scrollY = 0) {
|
|
243
|
+
let drawStartX = 0, drawStartY = 0;
|
|
244
|
+
if (endPoint.x + scrollX >= startPoint.x &&
|
|
245
|
+
endPoint.y + scrollY >= startPoint.y) {
|
|
246
|
+
//4象限
|
|
247
|
+
drawStartX = startPoint.x;
|
|
248
|
+
drawStartY = startPoint.y;
|
|
249
|
+
return new Rect(drawStartX - scrollX, drawStartY - scrollY, Math.abs(endPoint.x - startPoint.x + scrollX), Math.abs(endPoint.y - startPoint.y + scrollY));
|
|
250
|
+
}
|
|
251
|
+
else if (endPoint.x + scrollX < startPoint.x &&
|
|
252
|
+
endPoint.y + scrollY < startPoint.y) {
|
|
253
|
+
//1象限
|
|
254
|
+
drawStartX = endPoint.x;
|
|
255
|
+
drawStartY = endPoint.y;
|
|
256
|
+
return new Rect(drawStartX, drawStartY, Math.abs(endPoint.x - startPoint.x + scrollX), Math.abs(endPoint.y - startPoint.y + scrollY));
|
|
257
|
+
}
|
|
258
|
+
else if (endPoint.x + scrollX < startPoint.x &&
|
|
259
|
+
endPoint.y + scrollY >= startPoint.y) {
|
|
260
|
+
//3象限
|
|
261
|
+
drawStartX = endPoint.x;
|
|
262
|
+
drawStartY = startPoint.y;
|
|
263
|
+
return new Rect(drawStartX - scrollX, drawStartY - scrollY, Math.abs(endPoint.x - startPoint.x + scrollX), Math.abs(endPoint.y - startPoint.y + scrollY));
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
//2象限
|
|
267
|
+
drawStartX = startPoint.x;
|
|
268
|
+
drawStartY = endPoint.y;
|
|
269
|
+
return new Rect(drawStartX, drawStartY, Math.abs(endPoint.x - startPoint.x + scrollX), Math.abs(endPoint.y - startPoint.y + scrollY));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function calcEdgeLinesOfRect(rect) {
|
|
273
|
+
if (!rect)
|
|
274
|
+
return;
|
|
275
|
+
return {
|
|
276
|
+
v: [
|
|
277
|
+
new LineSegment(new Point(rect.x, rect.y), new Point(rect.x, rect.y + rect.height)),
|
|
278
|
+
new LineSegment(new Point(rect.x + rect.width / 2, rect.y), new Point(rect.x + rect.width / 2, rect.y + rect.height)),
|
|
279
|
+
new LineSegment(new Point(rect.x + rect.width, rect.y), new Point(rect.x + rect.width, rect.y + rect.height)),
|
|
280
|
+
],
|
|
281
|
+
h: [
|
|
282
|
+
new LineSegment(new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y)),
|
|
283
|
+
new LineSegment(new Point(rect.x, rect.y + rect.height / 2), new Point(rect.x + rect.width, rect.y + rect.height / 2)),
|
|
284
|
+
new LineSegment(new Point(rect.x, rect.y + rect.height), new Point(rect.x + rect.width, rect.y + rect.height)),
|
|
285
|
+
],
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function calcRectOfAxisLineSegment(line) {
|
|
289
|
+
if (!isLineSegment(line))
|
|
290
|
+
return;
|
|
291
|
+
const isXAxis = line.start.x === line.end.x;
|
|
292
|
+
return new Rect(line.start.x, line.start.y, isXAxis ? 0 : line.end.x - line.start.x, isXAxis ? line.end.y - line.start.y : 0);
|
|
293
|
+
}
|
|
294
|
+
function calcSpaceBlockOfRect(target, source, type) {
|
|
295
|
+
const targetRect = new Rect(target.x, target.y, target.width, target.height);
|
|
296
|
+
const sourceRect = new Rect(source.x, source.y, source.width, source.height);
|
|
297
|
+
if (sourceRect.bottom < targetRect.top && sourceRect.left > targetRect.right)
|
|
298
|
+
return;
|
|
299
|
+
if (sourceRect.top > targetRect.bottom && sourceRect.left > targetRect.right)
|
|
300
|
+
return;
|
|
301
|
+
if (sourceRect.bottom < targetRect.top && sourceRect.right < targetRect.left)
|
|
302
|
+
return;
|
|
303
|
+
if (sourceRect.top > targetRect.bottom && sourceRect.right < targetRect.left)
|
|
304
|
+
return;
|
|
305
|
+
if (sourceRect.bottom < targetRect.top) {
|
|
306
|
+
const distance = targetRect.top - sourceRect.bottom;
|
|
307
|
+
const left = Math.min(sourceRect.left, targetRect.left);
|
|
308
|
+
const right = Math.max(sourceRect.right, targetRect.right);
|
|
309
|
+
if (type && type !== 'top')
|
|
310
|
+
return;
|
|
311
|
+
return {
|
|
312
|
+
type: 'top',
|
|
313
|
+
distance,
|
|
314
|
+
rect: new Rect(left, sourceRect.bottom, right - left, distance),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
else if (sourceRect.top > targetRect.bottom) {
|
|
318
|
+
const distance = sourceRect.top - targetRect.bottom;
|
|
319
|
+
const left = Math.min(sourceRect.left, targetRect.left);
|
|
320
|
+
const right = Math.max(sourceRect.right, targetRect.right);
|
|
321
|
+
if (type && type !== 'bottom')
|
|
322
|
+
return;
|
|
323
|
+
return {
|
|
324
|
+
type: 'bottom',
|
|
325
|
+
distance,
|
|
326
|
+
rect: new Rect(left, targetRect.bottom, right - left, distance),
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
else if (sourceRect.right < targetRect.left) {
|
|
330
|
+
const distance = targetRect.left - sourceRect.right;
|
|
331
|
+
const top = Math.min(sourceRect.top, targetRect.top);
|
|
332
|
+
const bottom = Math.max(sourceRect.bottom, targetRect.bottom);
|
|
333
|
+
if (type && type !== 'left')
|
|
334
|
+
return;
|
|
335
|
+
return {
|
|
336
|
+
type: 'left',
|
|
337
|
+
distance,
|
|
338
|
+
rect: new Rect(sourceRect.right, top, distance, bottom - top),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
else if (sourceRect.left > targetRect.right) {
|
|
342
|
+
const distance = sourceRect.left - targetRect.right;
|
|
343
|
+
const top = Math.min(sourceRect.top, targetRect.top);
|
|
344
|
+
const bottom = Math.max(sourceRect.bottom, targetRect.bottom);
|
|
345
|
+
if (type && type !== 'right')
|
|
346
|
+
return;
|
|
347
|
+
return {
|
|
348
|
+
type: 'right',
|
|
349
|
+
distance,
|
|
350
|
+
rect: new Rect(targetRect.right, top, distance, bottom - top),
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function calcExtendsLineSegmentOfRect(targetRect, referRect) {
|
|
355
|
+
if (referRect.right < targetRect.right &&
|
|
356
|
+
targetRect.left <= referRect.right) {
|
|
357
|
+
//右侧
|
|
358
|
+
if (referRect.bottom < targetRect.top) {
|
|
359
|
+
//上方
|
|
360
|
+
return {
|
|
361
|
+
start: { x: referRect.right, y: referRect.bottom },
|
|
362
|
+
end: { x: targetRect.right, y: referRect.bottom },
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
else if (referRect.top > targetRect.bottom) {
|
|
366
|
+
//下方
|
|
367
|
+
return {
|
|
368
|
+
start: { x: referRect.right, y: referRect.top },
|
|
369
|
+
end: { x: targetRect.right, y: referRect.top },
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else if (referRect.left > targetRect.left &&
|
|
374
|
+
targetRect.right >= referRect.left) {
|
|
375
|
+
//左侧
|
|
376
|
+
if (referRect.bottom < targetRect.top) {
|
|
377
|
+
//上方
|
|
378
|
+
return {
|
|
379
|
+
start: { x: targetRect.left, y: referRect.bottom },
|
|
380
|
+
end: { x: referRect.left, y: referRect.bottom },
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
else if (referRect.top > targetRect.bottom) {
|
|
384
|
+
//下方
|
|
385
|
+
return {
|
|
386
|
+
start: { x: targetRect.left, y: referRect.top },
|
|
387
|
+
end: { x: referRect.left, y: referRect.top },
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (referRect.top < targetRect.top && targetRect.bottom >= referRect.top) {
|
|
392
|
+
//refer在上方
|
|
393
|
+
if (referRect.right < targetRect.left) {
|
|
394
|
+
//右侧
|
|
395
|
+
return {
|
|
396
|
+
start: { x: referRect.right, y: referRect.bottom },
|
|
397
|
+
end: { x: referRect.right, y: targetRect.bottom },
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
else if (referRect.left > targetRect.right) {
|
|
401
|
+
//左侧
|
|
402
|
+
return {
|
|
403
|
+
start: { x: referRect.left, y: referRect.bottom },
|
|
404
|
+
end: { x: referRect.left, y: targetRect.bottom },
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (referRect.bottom > targetRect.bottom &&
|
|
409
|
+
referRect.top <= targetRect.bottom) {
|
|
410
|
+
//refer下方
|
|
411
|
+
if (referRect.right < targetRect.left) {
|
|
412
|
+
//右侧
|
|
413
|
+
return {
|
|
414
|
+
start: { x: referRect.right, y: targetRect.top },
|
|
415
|
+
end: { x: referRect.right, y: referRect.top },
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
else if (referRect.left > targetRect.right) {
|
|
419
|
+
//左侧
|
|
420
|
+
return {
|
|
421
|
+
start: { x: referRect.left, y: targetRect.top },
|
|
422
|
+
end: { x: referRect.left, y: referRect.top },
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function calcOffsetOfSnapLineSegmentToEdge(line, current) {
|
|
428
|
+
const edges = calcEdgeLinesOfRect(current);
|
|
429
|
+
const isVerticalLine = line.start.x === line.end.x;
|
|
430
|
+
if (isVerticalLine) {
|
|
431
|
+
return { x: calcMinDistanceValue(edges.x, line.start.x) - current.x, y: 0 };
|
|
432
|
+
}
|
|
433
|
+
function calcEdgeLinesOfRect(rect) {
|
|
434
|
+
return {
|
|
435
|
+
x: [rect.x, rect.x + rect.width / 2, rect.x + rect.width],
|
|
436
|
+
y: [rect.y, rect.y + rect.height / 2, rect.y + rect.height],
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function calcMinDistanceValue(edges, targetValue) {
|
|
440
|
+
let minDistance = Infinity, minDistanceIndex = -1;
|
|
441
|
+
for (let i = 0; i < edges.length; i++) {
|
|
442
|
+
const distance = Math.abs(edges[i] - targetValue);
|
|
443
|
+
if (minDistance > distance) {
|
|
444
|
+
minDistance = distance;
|
|
445
|
+
minDistanceIndex = i;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return edges[minDistanceIndex];
|
|
449
|
+
}
|
|
450
|
+
return { x: 0, y: calcMinDistanceValue(edges.y, line.start.y) - current.y };
|
|
451
|
+
}
|
|
452
|
+
function calcDistanceOfSnapLineToEdges(line, edges) {
|
|
453
|
+
var _a, _b, _c, _d;
|
|
454
|
+
let distance = Infinity;
|
|
455
|
+
if (!edges)
|
|
456
|
+
return distance;
|
|
457
|
+
if (((_a = line === null || line === void 0 ? void 0 : line.start) === null || _a === void 0 ? void 0 : _a.y) === ((_b = line === null || line === void 0 ? void 0 : line.end) === null || _b === void 0 ? void 0 : _b.y)) {
|
|
458
|
+
edges.h.forEach((target) => {
|
|
459
|
+
const _distance = Math.abs(target.start.y - line.start.y);
|
|
460
|
+
if (_distance < distance) {
|
|
461
|
+
distance = _distance;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
else if (((_c = line === null || line === void 0 ? void 0 : line.start) === null || _c === void 0 ? void 0 : _c.x) === ((_d = line === null || line === void 0 ? void 0 : line.end) === null || _d === void 0 ? void 0 : _d.x)) {
|
|
466
|
+
edges.v.forEach((target) => {
|
|
467
|
+
const _distance = Math.abs(target.start.x - line.start.x);
|
|
468
|
+
if (_distance < distance) {
|
|
469
|
+
distance = _distance;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
throw new Error('can not calculate slash distance');
|
|
475
|
+
}
|
|
476
|
+
return distance;
|
|
477
|
+
}
|
|
478
|
+
function calcCombineSnapLineSegment(target, source) {
|
|
479
|
+
if (target.start.x === target.end.x) {
|
|
480
|
+
return new LineSegment(new Point(target.start.x, target.start.y > source.start.y ? source.start.y : target.start.y), new Point(target.start.x, target.end.y > source.end.y ? target.end.y : source.end.y));
|
|
481
|
+
}
|
|
482
|
+
return new LineSegment(new Point(target.start.x > source.start.x ? source.start.x : target.start.x, target.start.y), new Point(target.end.x > source.end.x ? target.end.x : source.end.x, target.end.y));
|
|
483
|
+
}
|
|
484
|
+
function calcClosestEdges(line, edges) {
|
|
485
|
+
var _a, _b, _c, _d;
|
|
486
|
+
let result = {
|
|
487
|
+
start: { x: 0, y: 0 },
|
|
488
|
+
end: { x: 0, y: 0 },
|
|
489
|
+
};
|
|
490
|
+
let distance = Infinity;
|
|
491
|
+
if (((_a = line === null || line === void 0 ? void 0 : line.start) === null || _a === void 0 ? void 0 : _a.y) === ((_b = line === null || line === void 0 ? void 0 : line.end) === null || _b === void 0 ? void 0 : _b.y)) {
|
|
492
|
+
edges.h.forEach((target) => {
|
|
493
|
+
const _distance = Math.abs(target.start.y - line.start.y);
|
|
494
|
+
if (_distance < distance) {
|
|
495
|
+
distance = _distance;
|
|
496
|
+
result = target;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
else if (((_c = line === null || line === void 0 ? void 0 : line.start) === null || _c === void 0 ? void 0 : _c.x) === ((_d = line === null || line === void 0 ? void 0 : line.end) === null || _d === void 0 ? void 0 : _d.x)) {
|
|
501
|
+
edges.v.forEach((target) => {
|
|
502
|
+
const _distance = Math.abs(target.start.x - line.start.x);
|
|
503
|
+
if (_distance < distance) {
|
|
504
|
+
distance = _distance;
|
|
505
|
+
result = target;
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
throw new Error('can not calculate slash distance');
|
|
511
|
+
}
|
|
512
|
+
return [distance, result];
|
|
513
|
+
}
|
|
514
|
+
//# sourceMappingURL=coordinate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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I,uBAAJ,IAAI,CAAE,GAAG,0CAAE,CAAC,CAAA,EAAE,CAAC;QACpC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACzD,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;gBACzB,QAAQ,GAAG,SAAS,CAAA;gBACpB,MAAM,GAAG,MAAM,CAAA;YACjB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;SAAM,IAAI,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,CAAC,OAAK,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,0CAAE,CAAC,CAAA,EAAE,CAAC;QAC3C,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACzD,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;gBACzB,QAAQ,GAAG,SAAS,CAAA;gBACpB,MAAM,GAAG,MAAM,CAAA;YACjB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;IACrD,CAAC;IACD,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AAC3B,CAAC","sourcesContent":["import { isValidNumber } from './types'\nexport interface IPoint {\n x: number\n y: number\n}\n\nexport interface ISize {\n width: number\n height: number\n}\n\nexport interface ILineSegment {\n start: IPoint\n end: IPoint\n}\n\nexport interface IRectEdgeLines {\n v: ILineSegment[]\n h: ILineSegment[]\n}\n\nexport function isRect(rect: any): rect is IRect {\n return rect?.x && rect?.y && rect?.width && rect?.height\n}\n\nexport function isPoint(val: any): val is IPoint {\n return isValidNumber(val?.x) && isValidNumber(val?.y)\n}\n\nexport function isLineSegment(val: any): val is ILineSegment {\n return isPoint(val?.start) && isPoint(val?.end)\n}\n\nexport class Point implements IPoint {\n x: number\n y: number\n constructor(x?: number, y?: number) {\n this.x = x || 0\n this.y = y || 0\n }\n}\n\nexport class Rect implements IRect {\n x = 0\n y = 0\n width = 0\n height = 0\n constructor(x: number, y: number, width?: number, height?: number) {\n this.x = x\n this.y = y\n this.width = width || 0\n this.height = height || 0\n }\n\n get left() {\n return this.x\n }\n\n get right() {\n return this.x + this.width\n }\n\n get top() {\n return this.y\n }\n\n get bottom() {\n return this.y + this.height\n }\n}\n\nexport class LineSegment {\n start: IPoint\n end: IPoint\n constructor(start: IPoint, end: IPoint) {\n this.start = { ...start }\n this.end = { ...end }\n }\n}\n\nexport interface IRect {\n x: number\n y: number\n width: number\n height: number\n}\n\nexport enum RectQuadrant {\n Inner1 = 'I1', //内部第一象限\n Inner2 = 'I2', //内部第二象限\n Inner3 = 'I3', //内部第三象限\n Inner4 = 'I4', //内部第四象限\n Outer1 = 'O1', //内部第五象限\n Outer2 = 'O2', //内部第六象限\n Outer3 = 'O3', //内部第七象限\n Outer4 = 'O4', //内部第八象限\n}\n\nexport interface IPointToRectRelative {\n quadrant: RectQuadrant\n distance: number\n}\n\nexport function isPointInRect(point: IPoint, rect: IRect, sensitive = true) {\n const boundSensor = (value: number) => {\n if (!sensitive) return 0\n const sensor = value * 0.1\n if (sensor > 20) return 20\n if (sensor < 10) return 10\n return sensor\n }\n\n return (\n point.x >= rect.x + boundSensor(rect.width) &&\n point.x <= rect.x + rect.width - boundSensor(rect.width) &&\n point.y >= rect.y + boundSensor(rect.height) &&\n point.y <= rect.y + rect.height - boundSensor(rect.height)\n )\n}\n\nexport function isEqualRect(target?: IRect, source?: IRect) {\n return (\n target &&\n source &&\n target.x === source.x &&\n target.y === source.y &&\n target.width === source.width &&\n target.height === source.height\n )\n}\n\nexport function getRectPoints(source: IRect) {\n const p1 = new Point(source.x, source.y)\n const p2 = new Point(source.x + source.width, source.y)\n const p3 = new Point(source.x + source.width, source.y + source.height)\n const p4 = new Point(source.x, source.y + source.height)\n return [p1, p2, p3, p4]\n}\n\nexport function isRectInRect(target: IRect, source: IRect) {\n const [p1, p2, p3, p4] = getRectPoints(target)\n return (\n isPointInRect(p1, source, false) &&\n isPointInRect(p2, source, false) &&\n isPointInRect(p3, source, false) &&\n isPointInRect(p4, source, false)\n )\n}\n\nexport function isCrossRectInRect(target: IRect, source: IRect) {\n const targetCenterPoint = new Point(\n target.x + target.width / 2,\n target.y + target.height / 2\n )\n const sourceCenterPoint = new Point(\n source.x + source.width / 2,\n source.y + source.height / 2\n )\n return (\n Math.abs(targetCenterPoint.x - sourceCenterPoint.x) <=\n target.width / 2 + source.width / 2 &&\n Math.abs(targetCenterPoint.y - sourceCenterPoint.y) <=\n target.height / 2 + source.height / 2\n )\n}\n\n/**\n * 计算点在矩形的哪个象限\n * @param point\n * @param rect\n */\nexport function calcQuadrantOfPointToRect(point: IPoint, rect: IRect) {\n const isInner = isPointInRect(point, rect)\n if (point.x <= rect.x + rect.width / 2) {\n if (point.y <= rect.y + rect.height / 2) {\n if (isInner) {\n return RectQuadrant.Inner1\n } else {\n return RectQuadrant.Outer1\n }\n } else {\n if (isInner) {\n return RectQuadrant.Inner4\n } else {\n return RectQuadrant.Outer4\n }\n }\n } else {\n if (point.y <= rect.y + rect.height / 2) {\n if (isInner) {\n return RectQuadrant.Inner2\n } else {\n return RectQuadrant.Outer2\n }\n } else {\n if (isInner) {\n return RectQuadrant.Inner3\n } else {\n return RectQuadrant.Outer3\n }\n }\n }\n}\n\nexport function calcDistanceOfPointToRect(point: IPoint, rect: IRect) {\n let minX = Math.min(\n Math.abs(point.x - rect.x),\n Math.abs(point.x - (rect.x + rect.width))\n )\n let minY = Math.min(\n Math.abs(point.y - rect.y),\n Math.abs(point.y - (rect.y + rect.height))\n )\n if (point.x >= rect.x && point.x <= rect.x + rect.width) {\n minX = 0\n }\n if (point.y >= rect.y && point.y <= rect.y + rect.height) {\n minY = 0\n }\n\n return Math.sqrt(minX ** 2 + minY ** 2)\n}\n\nexport function calcDistancePointToEdge(point: IPoint, rect: IRect) {\n const distanceTop = Math.abs(point.y - rect.y)\n const distanceBottom = Math.abs(point.y - (rect.y + rect.height))\n const distanceLeft = Math.abs(point.x - rect.x)\n const distanceRight = Math.abs(point.x - (rect.x + rect.width))\n return Math.min(distanceTop, distanceBottom, distanceLeft, distanceRight)\n}\n\nexport function isNearAfter(point: IPoint, rect: IRect, inline = false) {\n if (inline) {\n return (\n Math.abs(point.x - rect.x) + Math.abs(point.y - rect.y) >\n Math.abs(point.x - (rect.x + rect.width)) +\n Math.abs(point.y - (rect.y + rect.height))\n )\n }\n return Math.abs(point.y - rect.y) > Math.abs(point.y - (rect.y + rect.height))\n}\n\n/**\n * 计算点鱼矩形的相对位置信息\n * @param point\n * @param rect\n */\nexport function calcRelativeOfPointToRect(\n point: IPoint,\n rect: IRect\n): IPointToRectRelative {\n const distance = calcDistanceOfPointToRect(point, rect)\n const quadrant = calcQuadrantOfPointToRect(point, rect)\n return {\n quadrant,\n distance,\n }\n}\n\nexport function calcBoundingRect(rects: IRect[]) {\n if (!rects?.length) return\n if (rects?.length === 1 && !rects[0]) return\n let minTop = Infinity\n let maxBottom = -Infinity\n let minLeft = Infinity\n let maxRight = -Infinity\n rects.forEach((item) => {\n const rect = new Rect(item.x, item.y, item.width, item.height)\n if (rect.top <= minTop) {\n minTop = rect.top\n }\n if (rect.bottom >= maxBottom) {\n maxBottom = rect.bottom\n }\n if (rect.left <= minLeft) {\n minLeft = rect.left\n }\n if (rect.right >= maxRight) {\n maxRight = rect.right\n }\n })\n return new Rect(minLeft, minTop, maxRight - minLeft, maxBottom - minTop)\n}\n\nexport function calcRectByStartEndPoint(\n startPoint: IPoint,\n endPoint: IPoint,\n scrollX = 0,\n scrollY = 0\n) {\n let drawStartX = 0,\n drawStartY = 0\n if (\n endPoint.x + scrollX >= startPoint.x &&\n endPoint.y + scrollY >= startPoint.y\n ) {\n //4象限\n drawStartX = startPoint.x\n drawStartY = startPoint.y\n return new Rect(\n drawStartX - scrollX,\n drawStartY - scrollY,\n Math.abs(endPoint.x - startPoint.x + scrollX),\n Math.abs(endPoint.y - startPoint.y + scrollY)\n )\n } else if (\n endPoint.x + scrollX < startPoint.x &&\n endPoint.y + scrollY < startPoint.y\n ) {\n //1象限\n drawStartX = endPoint.x\n drawStartY = endPoint.y\n return new Rect(\n drawStartX,\n drawStartY,\n Math.abs(endPoint.x - startPoint.x + scrollX),\n Math.abs(endPoint.y - startPoint.y + scrollY)\n )\n } else if (\n endPoint.x + scrollX < startPoint.x &&\n endPoint.y + scrollY >= startPoint.y\n ) {\n //3象限\n drawStartX = endPoint.x\n drawStartY = startPoint.y\n return new Rect(\n drawStartX - scrollX,\n drawStartY - scrollY,\n Math.abs(endPoint.x - startPoint.x + scrollX),\n Math.abs(endPoint.y - startPoint.y + scrollY)\n )\n } else {\n //2象限\n drawStartX = startPoint.x\n drawStartY = endPoint.y\n return new Rect(\n drawStartX,\n drawStartY,\n Math.abs(endPoint.x - startPoint.x + scrollX),\n Math.abs(endPoint.y - startPoint.y + scrollY)\n )\n }\n}\n\nexport function calcEdgeLinesOfRect(rect?: IRect): IRectEdgeLines | undefined {\n if (!rect) return\n return {\n v: [\n new LineSegment(\n new Point(rect.x, rect.y),\n new Point(rect.x, rect.y + rect.height)\n ),\n new LineSegment(\n new Point(rect.x + rect.width / 2, rect.y),\n new Point(rect.x + rect.width / 2, rect.y + rect.height)\n ),\n new LineSegment(\n new Point(rect.x + rect.width, rect.y),\n new Point(rect.x + rect.width, rect.y + rect.height)\n ),\n ],\n h: [\n new LineSegment(\n new Point(rect.x, rect.y),\n new Point(rect.x + rect.width, rect.y)\n ),\n new LineSegment(\n new Point(rect.x, rect.y + rect.height / 2),\n new Point(rect.x + rect.width, rect.y + rect.height / 2)\n ),\n new LineSegment(\n new Point(rect.x, rect.y + rect.height),\n new Point(rect.x + rect.width, rect.y + rect.height)\n ),\n ],\n }\n}\n\nexport function calcRectOfAxisLineSegment(line?: ILineSegment) {\n if (!isLineSegment(line)) return\n const isXAxis = line.start.x === line.end.x\n return new Rect(\n line.start.x,\n line.start.y,\n isXAxis ? 0 : line.end.x - line.start.x,\n isXAxis ? line.end.y - line.start.y : 0\n )\n}\n\nexport function calcSpaceBlockOfRect(\n target: IRect,\n source: IRect,\n type?: string\n) {\n const targetRect = new Rect(target.x, target.y, target.width, target.height)\n const sourceRect = new Rect(source.x, source.y, source.width, source.height)\n if (sourceRect.bottom < targetRect.top && sourceRect.left > targetRect.right)\n return\n if (sourceRect.top > targetRect.bottom && sourceRect.left > targetRect.right)\n return\n if (sourceRect.bottom < targetRect.top && sourceRect.right < targetRect.left)\n return\n if (sourceRect.top > targetRect.bottom && sourceRect.right < targetRect.left)\n return\n if (sourceRect.bottom < targetRect.top) {\n const distance = targetRect.top - sourceRect.bottom\n const left = Math.min(sourceRect.left, targetRect.left)\n const right = Math.max(sourceRect.right, targetRect.right)\n if (type && type !== 'top') return\n return {\n type: 'top',\n distance,\n rect: new Rect(left, sourceRect.bottom, right - left, distance),\n }\n } else if (sourceRect.top > targetRect.bottom) {\n const distance = sourceRect.top - targetRect.bottom\n const left = Math.min(sourceRect.left, targetRect.left)\n const right = Math.max(sourceRect.right, targetRect.right)\n if (type && type !== 'bottom') return\n return {\n type: 'bottom',\n distance,\n rect: new Rect(left, targetRect.bottom, right - left, distance),\n }\n } else if (sourceRect.right < targetRect.left) {\n const distance = targetRect.left - sourceRect.right\n const top = Math.min(sourceRect.top, targetRect.top)\n const bottom = Math.max(sourceRect.bottom, targetRect.bottom)\n if (type && type !== 'left') return\n return {\n type: 'left',\n distance,\n rect: new Rect(sourceRect.right, top, distance, bottom - top),\n }\n } else if (sourceRect.left > targetRect.right) {\n const distance = sourceRect.left - targetRect.right\n const top = Math.min(sourceRect.top, targetRect.top)\n const bottom = Math.max(sourceRect.bottom, targetRect.bottom)\n if (type && type !== 'right') return\n return {\n type: 'right',\n distance,\n rect: new Rect(targetRect.right, top, distance, bottom - top),\n }\n }\n}\n\nexport function calcExtendsLineSegmentOfRect(\n targetRect: Rect,\n referRect: Rect\n) {\n if (\n referRect.right < targetRect.right &&\n targetRect.left <= referRect.right\n ) {\n //右侧\n if (referRect.bottom < targetRect.top) {\n //上方\n return {\n start: { x: referRect.right, y: referRect.bottom },\n end: { x: targetRect.right, y: referRect.bottom },\n }\n } else if (referRect.top > targetRect.bottom) {\n //下方\n return {\n start: { x: referRect.right, y: referRect.top },\n end: { x: targetRect.right, y: referRect.top },\n }\n }\n } else if (\n referRect.left > targetRect.left &&\n targetRect.right >= referRect.left\n ) {\n //左侧\n if (referRect.bottom < targetRect.top) {\n //上方\n return {\n start: { x: targetRect.left, y: referRect.bottom },\n end: { x: referRect.left, y: referRect.bottom },\n }\n } else if (referRect.top > targetRect.bottom) {\n //下方\n return {\n start: { x: targetRect.left, y: referRect.top },\n end: { x: referRect.left, y: referRect.top },\n }\n }\n }\n if (referRect.top < targetRect.top && targetRect.bottom >= referRect.top) {\n //refer在上方\n if (referRect.right < targetRect.left) {\n //右侧\n return {\n start: { x: referRect.right, y: referRect.bottom },\n end: { x: referRect.right, y: targetRect.bottom },\n }\n } else if (referRect.left > targetRect.right) {\n //左侧\n return {\n start: { x: referRect.left, y: referRect.bottom },\n end: { x: referRect.left, y: targetRect.bottom },\n }\n }\n } else if (\n referRect.bottom > targetRect.bottom &&\n referRect.top <= targetRect.bottom\n ) {\n //refer下方\n if (referRect.right < targetRect.left) {\n //右侧\n return {\n start: { x: referRect.right, y: targetRect.top },\n end: { x: referRect.right, y: referRect.top },\n }\n } else if (referRect.left > targetRect.right) {\n //左侧\n return {\n start: { x: referRect.left, y: targetRect.top },\n end: { x: referRect.left, y: referRect.top },\n }\n }\n }\n}\n\nexport function calcOffsetOfSnapLineSegmentToEdge(\n line: ILineSegment,\n current: IRect\n) {\n const edges = calcEdgeLinesOfRect(current)\n const isVerticalLine = line.start.x === line.end.x\n if (isVerticalLine) {\n return { x: calcMinDistanceValue(edges.x, line.start.x) - current.x, y: 0 }\n }\n function calcEdgeLinesOfRect(rect: IRect) {\n return {\n x: [rect.x, rect.x + rect.width / 2, rect.x + rect.width],\n y: [rect.y, rect.y + rect.height / 2, rect.y + rect.height],\n }\n }\n function calcMinDistanceValue(edges: number[], targetValue: number) {\n let minDistance = Infinity,\n minDistanceIndex = -1\n for (let i = 0; i < edges.length; i++) {\n const distance = Math.abs(edges[i] - targetValue)\n if (minDistance > distance) {\n minDistance = distance\n minDistanceIndex = i\n }\n }\n return edges[minDistanceIndex]\n }\n\n return { x: 0, y: calcMinDistanceValue(edges.y, line.start.y) - current.y }\n}\n\nexport function calcDistanceOfSnapLineToEdges(\n line: ILineSegment,\n edges?: IRectEdgeLines\n) {\n let distance = Infinity\n if (!edges) return distance\n if (line?.start?.y === line?.end?.y) {\n edges.h.forEach((target) => {\n const _distance = Math.abs(target.start.y - line.start.y)\n if (_distance < distance) {\n distance = _distance\n }\n })\n } else if (line?.start?.x === line?.end?.x) {\n edges.v.forEach((target) => {\n const _distance = Math.abs(target.start.x - line.start.x)\n if (_distance < distance) {\n distance = _distance\n }\n })\n } else {\n throw new Error('can not calculate slash distance')\n }\n return distance\n}\n\nexport function calcCombineSnapLineSegment(\n target: ILineSegment,\n source: ILineSegment\n): ILineSegment {\n if (target.start.x === target.end.x) {\n return new LineSegment(\n new Point(\n target.start.x,\n target.start.y > source.start.y ? source.start.y : target.start.y\n ),\n new Point(\n target.start.x,\n target.end.y > source.end.y ? target.end.y : source.end.y\n )\n )\n }\n\n return new LineSegment(\n new Point(\n target.start.x > source.start.x ? source.start.x : target.start.x,\n target.start.y\n ),\n new Point(\n target.end.x > source.end.x ? target.end.x : source.end.x,\n target.end.y\n )\n )\n}\n\nexport function calcClosestEdges(\n line: ILineSegment,\n edges: IRectEdgeLines\n): [number, ILineSegment] {\n let result: ILineSegment = {\n start: { x: 0, y: 0 },\n end: { x: 0, y: 0 },\n }\n let distance = Infinity\n if (line?.start?.y === line?.end?.y) {\n edges.h.forEach((target) => {\n const _distance = Math.abs(target.start.y - line.start.y)\n if (_distance < distance) {\n distance = _distance\n result = target\n }\n })\n } else if (line?.start?.x === line?.end?.x) {\n edges.v.forEach((target) => {\n const _distance = Math.abs(target.start.x - line.start.x)\n if (_distance < distance) {\n distance = _distance\n result = target\n }\n })\n } else {\n throw new Error('can not calculate slash distance')\n }\n return [distance, result]\n}\n"]}
|
package/lib/element.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Point } from './coordinate';
|
|
2
|
+
export declare const calcElementOuterWidth: (innerWidth: number, style: CSSStyleDeclaration) => number;
|
|
3
|
+
export declare const calcElementLayout: (element: Element) => "vertical" | "horizontal";
|
|
4
|
+
export declare const calcElementTranslate: (element: HTMLElement) => Point;
|
|
5
|
+
export declare const calcElementRotate: (element: HTMLElement) => number;
|
|
6
|
+
export declare const calcElementScale: (element: HTMLElement) => number;
|