@meta2d/core 1.0.55 → 1.0.57

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.
Files changed (223) hide show
  1. package/index.d.ts +9 -9
  2. package/index.js +9 -9
  3. package/package.json +38 -39
  4. package/src/canvas/canvas.d.ts +456 -456
  5. package/src/canvas/canvas.js +7583 -8186
  6. package/src/canvas/canvas.js.map +1 -1
  7. package/src/canvas/canvasImage.d.ts +27 -28
  8. package/src/canvas/canvasImage.js +440 -502
  9. package/src/canvas/canvasImage.js.map +1 -1
  10. package/src/canvas/canvasTemplate.d.ts +18 -19
  11. package/src/canvas/canvasTemplate.js +208 -228
  12. package/src/canvas/canvasTemplate.js.map +1 -1
  13. package/src/canvas/index.d.ts +2 -2
  14. package/src/canvas/index.js +2 -2
  15. package/src/canvas/magnifierCanvas.d.ts +19 -20
  16. package/src/canvas/magnifierCanvas.js +101 -100
  17. package/src/canvas/magnifierCanvas.js.map +1 -1
  18. package/src/canvas/offscreen.d.ts +1 -2
  19. package/src/canvas/offscreen.js +13 -13
  20. package/src/canvas/offscreen.js.map +1 -1
  21. package/src/core.d.ts +479 -479
  22. package/src/core.js +4589 -5198
  23. package/src/core.js.map +1 -1
  24. package/src/data.d.ts +34 -34
  25. package/src/data.js +84 -84
  26. package/src/data.js.map +1 -1
  27. package/src/diagrams/arrow.d.ts +4 -4
  28. package/src/diagrams/arrow.js +46 -46
  29. package/src/diagrams/arrow.js.map +1 -1
  30. package/src/diagrams/circle.d.ts +2 -2
  31. package/src/diagrams/circle.js +8 -8
  32. package/src/diagrams/circle.js.map +1 -1
  33. package/src/diagrams/cloud.d.ts +2 -2
  34. package/src/diagrams/cloud.js +11 -11
  35. package/src/diagrams/cloud.js.map +1 -1
  36. package/src/diagrams/cube.d.ts +2 -2
  37. package/src/diagrams/cube.js +67 -69
  38. package/src/diagrams/cube.js.map +1 -1
  39. package/src/diagrams/diamond.d.ts +2 -2
  40. package/src/diagrams/diamond.js +12 -12
  41. package/src/diagrams/diamond.js.map +1 -1
  42. package/src/diagrams/file.d.ts +2 -2
  43. package/src/diagrams/file.js +17 -17
  44. package/src/diagrams/file.js.map +1 -1
  45. package/src/diagrams/gif.d.ts +5 -5
  46. package/src/diagrams/gif.js +88 -89
  47. package/src/diagrams/gif.js.map +1 -1
  48. package/src/diagrams/hexagon.d.ts +2 -2
  49. package/src/diagrams/hexagon.js +54 -54
  50. package/src/diagrams/hexagon.js.map +1 -1
  51. package/src/diagrams/iframe.d.ts +2 -2
  52. package/src/diagrams/iframe.js +337 -355
  53. package/src/diagrams/iframe.js.map +1 -1
  54. package/src/diagrams/index.d.ts +71 -71
  55. package/src/diagrams/index.js +76 -76
  56. package/src/diagrams/index.js.map +1 -1
  57. package/src/diagrams/line/arrow.d.ts +2 -2
  58. package/src/diagrams/line/arrow.js +127 -127
  59. package/src/diagrams/line/arrow.js.map +1 -1
  60. package/src/diagrams/line/curve.d.ts +16 -16
  61. package/src/diagrams/line/curve.js +226 -235
  62. package/src/diagrams/line/curve.js.map +1 -1
  63. package/src/diagrams/line/index.d.ts +5 -5
  64. package/src/diagrams/line/index.js +5 -5
  65. package/src/diagrams/line/line.d.ts +42 -42
  66. package/src/diagrams/line/line.js +369 -430
  67. package/src/diagrams/line/line.js.map +1 -1
  68. package/src/diagrams/line/polyline.d.ts +10 -10
  69. package/src/diagrams/line/polyline.js +626 -656
  70. package/src/diagrams/line/polyline.js.map +1 -1
  71. package/src/diagrams/line/smooth.d.ts +3 -3
  72. package/src/diagrams/line/smooth.js +135 -173
  73. package/src/diagrams/line/smooth.js.map +1 -1
  74. package/src/diagrams/message.d.ts +2 -2
  75. package/src/diagrams/message.js +14 -14
  76. package/src/diagrams/message.js.map +1 -1
  77. package/src/diagrams/mindLine.d.ts +3 -3
  78. package/src/diagrams/mindLine.js +29 -30
  79. package/src/diagrams/mindLine.js.map +1 -1
  80. package/src/diagrams/mindNode.d.ts +3 -3
  81. package/src/diagrams/mindNode.js +160 -188
  82. package/src/diagrams/mindNode.js.map +1 -1
  83. package/src/diagrams/panel.d.ts +2 -2
  84. package/src/diagrams/panel.js +130 -130
  85. package/src/diagrams/panel.js.map +1 -1
  86. package/src/diagrams/pentagon.d.ts +3 -3
  87. package/src/diagrams/pentagon.js +44 -45
  88. package/src/diagrams/pentagon.js.map +1 -1
  89. package/src/diagrams/pentagram.d.ts +3 -3
  90. package/src/diagrams/pentagram.js +50 -76
  91. package/src/diagrams/pentagram.js.map +1 -1
  92. package/src/diagrams/people.d.ts +2 -2
  93. package/src/diagrams/people.js +18 -18
  94. package/src/diagrams/people.js.map +1 -1
  95. package/src/diagrams/rectangle.d.ts +3 -3
  96. package/src/diagrams/rectangle.js +25 -25
  97. package/src/diagrams/rectangle.js.map +1 -1
  98. package/src/diagrams/svg/parse.d.ts +15 -15
  99. package/src/diagrams/svg/parse.js +278 -325
  100. package/src/diagrams/svg/parse.js.map +1 -1
  101. package/src/diagrams/svgPath.d.ts +2 -2
  102. package/src/diagrams/svgPath.js +28 -29
  103. package/src/diagrams/svgPath.js.map +1 -1
  104. package/src/diagrams/triangle.d.ts +3 -3
  105. package/src/diagrams/triangle.js +39 -40
  106. package/src/diagrams/triangle.js.map +1 -1
  107. package/src/diagrams/video.d.ts +5 -5
  108. package/src/diagrams/video.js +183 -184
  109. package/src/diagrams/video.js.map +1 -1
  110. package/src/dialog/dialog.d.ts +21 -21
  111. package/src/dialog/dialog.js +156 -97
  112. package/src/dialog/dialog.js.map +1 -1
  113. package/src/dialog/index.d.ts +1 -1
  114. package/src/dialog/index.js +1 -1
  115. package/src/event/event.d.ts +102 -102
  116. package/src/event/event.js +21 -21
  117. package/src/event/index.d.ts +1 -1
  118. package/src/event/index.js +1 -1
  119. package/src/map/index.d.ts +1 -1
  120. package/src/map/index.js +1 -1
  121. package/src/map/map.d.ts +21 -21
  122. package/src/map/map.js +211 -209
  123. package/src/map/map.js.map +1 -1
  124. package/src/options.d.ts +130 -130
  125. package/src/options.js +79 -79
  126. package/src/options.js.map +1 -1
  127. package/src/pen/arrow.d.ts +4 -4
  128. package/src/pen/arrow.js +187 -187
  129. package/src/pen/arrow.js.map +1 -1
  130. package/src/pen/index.d.ts +6 -6
  131. package/src/pen/index.js +6 -6
  132. package/src/pen/math.d.ts +28 -28
  133. package/src/pen/math.js +212 -303
  134. package/src/pen/math.js.map +1 -1
  135. package/src/pen/model.d.ts +514 -514
  136. package/src/pen/model.js +209 -209
  137. package/src/pen/model.js.map +1 -1
  138. package/src/pen/plugin.d.ts +5 -5
  139. package/src/pen/plugin.js +57 -87
  140. package/src/pen/plugin.js.map +1 -1
  141. package/src/pen/render.d.ts +146 -147
  142. package/src/pen/render.js +3233 -3235
  143. package/src/pen/render.js.map +1 -1
  144. package/src/pen/text.d.ts +8 -8
  145. package/src/pen/text.js +315 -374
  146. package/src/pen/text.js.map +1 -1
  147. package/src/pen/utils.d.ts +2 -2
  148. package/src/pen/utils.js +18 -40
  149. package/src/pen/utils.js.map +1 -1
  150. package/src/point/index.d.ts +1 -1
  151. package/src/point/index.js +1 -1
  152. package/src/point/point.d.ts +65 -65
  153. package/src/point/point.js +177 -178
  154. package/src/point/point.js.map +1 -1
  155. package/src/rect/index.d.ts +1 -1
  156. package/src/rect/index.js +1 -1
  157. package/src/rect/rect.d.ts +52 -52
  158. package/src/rect/rect.js +426 -485
  159. package/src/rect/rect.js.map +1 -1
  160. package/src/rect/triangle.d.ts +2 -2
  161. package/src/rect/triangle.js +9 -9
  162. package/src/rect/triangle.js.map +1 -1
  163. package/src/scroll/index.d.ts +1 -1
  164. package/src/scroll/index.js +1 -1
  165. package/src/scroll/scroll.d.ts +35 -35
  166. package/src/scroll/scroll.js +233 -220
  167. package/src/scroll/scroll.js.map +1 -1
  168. package/src/store/global.d.ts +25 -25
  169. package/src/store/global.js +17 -17
  170. package/src/store/global.js.map +1 -1
  171. package/src/store/index.d.ts +2 -2
  172. package/src/store/index.js +2 -2
  173. package/src/store/store.d.ts +228 -228
  174. package/src/store/store.js +86 -120
  175. package/src/store/store.js.map +1 -1
  176. package/src/theme.d.ts +13 -13
  177. package/src/theme.js +22 -22
  178. package/src/theme.js.map +1 -1
  179. package/src/title/index.d.ts +1 -1
  180. package/src/title/index.js +1 -1
  181. package/src/title/title.d.ts +30 -30
  182. package/src/title/title.js +98 -98
  183. package/src/title/title.js.map +1 -1
  184. package/src/tooltip/index.d.ts +1 -1
  185. package/src/tooltip/index.js +1 -1
  186. package/src/tooltip/tooltip.d.ts +40 -40
  187. package/src/tooltip/tooltip.js +171 -166
  188. package/src/tooltip/tooltip.js.map +1 -1
  189. package/src/utils/clone.d.ts +8 -8
  190. package/src/utils/clone.js +83 -87
  191. package/src/utils/clone.js.map +1 -1
  192. package/src/utils/color.d.ts +3 -3
  193. package/src/utils/color.js +109 -125
  194. package/src/utils/color.js.map +1 -1
  195. package/src/utils/error.d.ts +2 -2
  196. package/src/utils/error.js +5 -5
  197. package/src/utils/error.js.map +1 -1
  198. package/src/utils/file.d.ts +3 -3
  199. package/src/utils/file.js +39 -91
  200. package/src/utils/file.js.map +1 -1
  201. package/src/utils/index.d.ts +9 -8
  202. package/src/utils/index.js +9 -8
  203. package/src/utils/index.js.map +1 -1
  204. package/src/utils/math.d.ts +18 -18
  205. package/src/utils/math.js +113 -151
  206. package/src/utils/math.js.map +1 -1
  207. package/src/utils/object.d.ts +2 -2
  208. package/src/utils/object.js +20 -20
  209. package/src/utils/object.js.map +1 -1
  210. package/src/utils/padding.d.ts +7 -7
  211. package/src/utils/padding.js +46 -46
  212. package/src/utils/padding.js.map +1 -1
  213. package/src/utils/time.d.ts +1 -1
  214. package/src/utils/time.js +16 -16
  215. package/src/utils/time.js.map +1 -1
  216. package/src/utils/url.d.ts +4 -4
  217. package/src/utils/url.js +26 -26
  218. package/src/utils/url.js.map +1 -1
  219. package/src/utils/uuid.d.ts +4 -4
  220. package/src/utils/uuid.js +12 -12
  221. package/src/utils/browser.d.ts +0 -1
  222. package/src/utils/browser.js +0 -4
  223. package/src/utils/browser.js.map +0 -1
@@ -1,657 +1,627 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- import { Direction } from '../../data';
27
- import { deleteTempAnchor, facePen, getFromAnchor, getToAnchor, } from '../../pen';
28
- import { s8 } from '../../utils';
29
- var faceSpace = 10;
30
- export function polyline(store, pen, mousedwon) {
31
- var _a;
32
- if (!pen.calculative.worldAnchors) {
33
- pen.calculative.worldAnchors = [];
34
- }
35
- faceSpace = store.options.polylineSpace || 10;
36
- if (pen.calculative.worldAnchors.length < 2) {
37
- return;
38
- }
39
- var from = getFromAnchor(pen);
40
- var to = getToAnchor(pen);
41
- if (!from || !to) {
42
- return;
43
- }
44
- // 拖拽起点
45
- var dragFrom;
46
- if (((_a = pen.anchors) === null || _a === void 0 ? void 0 : _a.length) && from === pen.calculative.activeAnchor) {
47
- dragFrom = true;
48
- from = to;
49
- to = getFromAnchor(pen);
50
- }
51
- else if ((!pen.anchors || !pen.anchors.length) &&
52
- from !== pen.calculative.activeAnchor) {
53
- from = pen.calculative.activeAnchor;
54
- }
55
- if (!from || !to) {
56
- return;
57
- }
58
- from.next = undefined;
59
- to.prev = undefined;
60
- var connected = to.connectTo;
61
- deleteTempAnchor(pen);
62
- var pts = [];
63
- var fromPen = store.pens[from.connectTo];
64
- var toPen = store.pens[to.connectTo];
65
- var fromFace = facePen(from, fromPen);
66
- var toFace = facePen(to, toPen);
67
- var a = getFacePoint(from, fromFace, faceSpace);
68
- if (a) {
69
- from = a;
70
- pts.push(a);
71
- }
72
- a = getFacePoint(to, toFace, faceSpace);
73
- var end = to;
74
- var corner = undefined;
75
- if (a) {
76
- to = a;
77
- if (end.connectTo) {
78
- if ((a.y > end.y && from.y < end.y) || (a.y < end.y && from.y > end.y)) {
79
- //拐角 防止连线覆盖
80
- corner = a;
81
- var _faceSpace = faceSpace;
82
- if (from.x < a.x) {
83
- _faceSpace = -_faceSpace;
84
- }
85
- if (Math.abs(from.x - a.x) < _faceSpace) {
86
- _faceSpace = -_faceSpace;
87
- }
88
- var point = { x: a.x + _faceSpace, y: a.y, id: s8() };
89
- to = point;
90
- }
91
- }
92
- }
93
- switch (fromFace) {
94
- case Direction.Up:
95
- pts.push.apply(pts, __spreadArray([], __read(getNextPointsOfUp(from, to, toFace)), false));
96
- break;
97
- case Direction.Right:
98
- pts.push.apply(pts, __spreadArray([], __read(getNextPointsOfRight(from, to, toFace)), false));
99
- break;
100
- case Direction.Bottom:
101
- pts.push.apply(pts, __spreadArray([], __read(getNextPointsOfBottom(from, to, toFace)), false));
102
- break;
103
- case Direction.Left:
104
- pts.push.apply(pts, __spreadArray([], __read(getNextPointsOfLeft(from, to, toFace)), false));
105
- break;
106
- default:
107
- pts.push.apply(pts, __spreadArray([], __read(getNextPoints(pen, from, to)), false));
108
- break;
109
- }
110
- pts.forEach(function (anchor) {
111
- anchor.id = s8();
112
- anchor.penId = pen.id;
113
- pen.calculative.worldAnchors.push(anchor);
114
- });
115
- pen.calculative.worldAnchors.push(to);
116
- if (corner) {
117
- pen.calculative.worldAnchors.push(corner);
118
- }
119
- if (a) {
120
- pen.calculative.worldAnchors.push(end);
121
- }
122
- if (dragFrom) {
123
- pen.calculative.worldAnchors.reverse();
124
- }
125
- if (connected) {
126
- var i = pen.calculative.worldAnchors.length - 2;
127
- pen.calculative.worldAnchors[i].isTemp = false;
128
- pen.calculative.worldAnchors[1].isTemp = false;
129
- }
130
- }
131
- function getFacePoint(pt, d, dis) {
132
- var point = { x: pt.x, y: pt.y, id: s8() };
133
- switch (d) {
134
- case Direction.Up:
135
- point.y -= dis;
136
- break;
137
- case Direction.Right:
138
- point.x += dis;
139
- break;
140
- case Direction.Bottom:
141
- point.y += dis;
142
- break;
143
- case Direction.Left:
144
- point.x -= dis;
145
- break;
146
- default: {
147
- return;
148
- }
149
- }
150
- return point;
151
- }
152
- function getNextPointsOfUp(from, to, toFace) {
153
- if (from.x === to.x || from.y === to.y) {
154
- return [];
155
- }
156
- var pts = [];
157
- var x;
158
- var y;
159
- switch (toFace) {
160
- case Direction.Up:
161
- if (from.y < to.y) {
162
- x = to.x;
163
- y = from.y;
164
- }
165
- else {
166
- x = from.x;
167
- y = to.y;
168
- }
169
- pts.push({ x: x, y: y });
170
- break;
171
- case Direction.Bottom:
172
- x = to.x;
173
- y = from.y;
174
- if (to.y > from.y) {
175
- x = from.x + (to.x - from.x) / 2;
176
- pts.push({ x: x, y: from.y }, { x: x, y: to.y });
177
- }
178
- else {
179
- var centerY = (from.y + to.y) / 2;
180
- pts.push({ x: from.x, y: centerY }, { x: to.x, y: centerY });
181
- }
182
- break;
183
- case Direction.Right:
184
- x = to.x;
185
- y = from.y;
186
- if (to.x < from.x && to.y < from.y) {
187
- x = from.x;
188
- y = to.y;
189
- }
190
- pts.push({ x: x, y: y });
191
- break;
192
- case Direction.Left:
193
- x = to.x;
194
- y = from.y;
195
- if (to.x > from.x && to.y < from.y) {
196
- x = from.x;
197
- y = to.y;
198
- }
199
- pts.push({ x: x, y: y });
200
- break;
201
- default:
202
- if (to.y > from.y - faceSpace) {
203
- x = from.x + (to.x - from.x) / 2;
204
- pts.push({ x: x, y: from.y }, { x: x, y: to.y });
205
- }
206
- else {
207
- var centerY = (from.y + to.y + faceSpace) / 2;
208
- pts.push({ x: from.x, y: centerY }, { x: to.x, y: centerY });
209
- }
210
- break;
211
- }
212
- return pts;
213
- }
214
- function getNextPointsOfRight(from, to, toFace) {
215
- if (from.x === to.x || from.y === to.y) {
216
- return [];
217
- }
218
- var pts = [];
219
- var x;
220
- var y;
221
- switch (toFace) {
222
- case Direction.Up:
223
- x = from.x;
224
- y = to.y;
225
- if (to.x > from.x && to.y > from.y) {
226
- x = to.x;
227
- y = from.y;
228
- }
229
- pts.push({ x: x, y: y });
230
- break;
231
- case Direction.Bottom:
232
- x = from.x;
233
- y = to.y;
234
- if (to.x > from.x && to.y < from.y) {
235
- x = to.x;
236
- y = from.y;
237
- }
238
- pts.push({ x: x, y: y });
239
- break;
240
- case Direction.Left:
241
- x = to.x;
242
- y = from.y;
243
- if (to.x < from.x) {
244
- y = from.y + (to.y - from.y) / 2;
245
- pts.push({ x: from.x, y: y }, { x: to.x, y: y });
246
- }
247
- else {
248
- var centerX = (from.x + to.x) / 2;
249
- pts.push({ x: centerX, y: y }, { x: centerX, y: to.y });
250
- }
251
- break;
252
- case Direction.Right:
253
- if (to.x < from.x) {
254
- pts.push({ x: from.x, y: to.y });
255
- }
256
- else {
257
- pts.push({ x: to.x, y: from.y });
258
- }
259
- break;
260
- default:
261
- x = to.x;
262
- y = to.y;
263
- if (to.x < from.x + faceSpace) {
264
- pts.push({ x: from.x, y: y });
265
- }
266
- else {
267
- var centerX = (from.x + to.x - faceSpace) / 2;
268
- pts.push({ x: centerX, y: from.y }, { x: centerX, y: y });
269
- }
270
- break;
271
- }
272
- return pts;
273
- }
274
- function getNextPointsOfBottom(from, to, toFace) {
275
- if (from.x === to.x || from.y === to.y) {
276
- return [];
277
- }
278
- var pts = [];
279
- var x;
280
- var y;
281
- switch (toFace) {
282
- case Direction.Up:
283
- x = from.x;
284
- y = to.y;
285
- if (to.y < from.y) {
286
- x = from.x + (to.x - from.x) / 2;
287
- pts.push({ x: x, y: from.y }, { x: x, y: to.y });
288
- }
289
- else {
290
- var centerY = (from.y + to.y) / 2;
291
- pts.push({ x: x, y: centerY }, { x: to.x, y: centerY });
292
- }
293
- break;
294
- case Direction.Right:
295
- x = to.x;
296
- y = from.y;
297
- if (to.x < from.x && to.y > from.y) {
298
- x = from.x;
299
- y = to.y;
300
- }
301
- pts.push({ x: x, y: y });
302
- break;
303
- case Direction.Bottom:
304
- if (from.y > to.y) {
305
- x = to.x;
306
- y = from.y;
307
- }
308
- else {
309
- x = from.x;
310
- y = to.y;
311
- }
312
- pts.push({ x: x, y: y });
313
- break;
314
- case Direction.Left:
315
- x = to.x;
316
- y = from.y;
317
- if (to.x > from.x && to.y > from.y) {
318
- x = from.x;
319
- y = to.y;
320
- }
321
- pts.push({ x: x, y: y });
322
- break;
323
- default:
324
- x = from.x;
325
- if (to.y < from.y + faceSpace) {
326
- x = from.x + (to.x - from.x) / 2;
327
- pts.push({ x: x, y: from.y }, { x: x, y: to.y });
328
- }
329
- else {
330
- var centerY = (from.y + to.y - faceSpace) / 2;
331
- pts.push({ x: x, y: centerY }, { x: to.x, y: centerY });
332
- }
333
- break;
334
- }
335
- return pts;
336
- }
337
- function getNextPointsOfLeft(from, to, toFace) {
338
- if (from.x === to.x || from.y === to.y) {
339
- return [];
340
- }
341
- var pts = [];
342
- var x;
343
- var y;
344
- switch (toFace) {
345
- case Direction.Up:
346
- x = from.x;
347
- y = to.y;
348
- if (to.x < from.x && to.y > from.y) {
349
- x = to.x;
350
- y = from.y;
351
- }
352
- pts.push({ x: x, y: y });
353
- break;
354
- case Direction.Bottom:
355
- x = from.x;
356
- y = to.y;
357
- if (to.x < from.x && to.y < from.y) {
358
- x = to.x;
359
- y = from.y;
360
- }
361
- pts.push({ x: x, y: y });
362
- break;
363
- case Direction.Right:
364
- x = from.x;
365
- y = to.y;
366
- if (to.x > from.x) {
367
- x = to.x;
368
- y = from.y + (to.y - from.y) / 2;
369
- pts.push({ x: from.x, y: y }, { x: to.x, y: y });
370
- }
371
- else {
372
- var centerX = (from.x + to.x) / 2;
373
- pts.push({ x: centerX, y: from.y }, { x: centerX, y: to.y });
374
- }
375
- break;
376
- case Direction.Left:
377
- if (to.x > from.x) {
378
- pts.push({ x: from.x, y: to.y });
379
- }
380
- else {
381
- pts.push({ x: to.x, y: from.y });
382
- }
383
- break;
384
- default:
385
- x = from.x;
386
- y = to.y;
387
- if (to.x < from.x - faceSpace) {
388
- var centerX = (from.x + to.x + faceSpace) / 2;
389
- pts.push({ x: centerX, y: from.y }, { x: centerX, y: y });
390
- }
391
- else {
392
- pts.push({ x: from.x, y: y });
393
- }
394
- break;
395
- }
396
- return pts;
397
- }
398
- function getNextPoints(pen, from, to) {
399
- var pts = [];
400
- if (pen.calculative.drawlineH == undefined) {
401
- pen.calculative.drawlineH =
402
- Math.abs(to.x - from.x) > Math.abs(to.y - from.y);
403
- }
404
- var index = pen.calculative.worldAnchors.findIndex(function (anchor) { return anchor.id == from.id; });
405
- if (index > 1) {
406
- var prev = pen.calculative.worldAnchors[index - 1];
407
- if (prev.x === from.x && prev.y !== from.y) {
408
- //水平
409
- pts.push({ x: to.x, y: from.y });
410
- return pts;
411
- }
412
- else if (prev.y === from.y && prev.x !== from.x) {
413
- //垂直
414
- pts.push({ x: from.x, y: to.y });
415
- return pts;
416
- }
417
- }
418
- if (pen.calculative.worldAnchors.length) {
419
- to.isTemp = undefined;
420
- if (pen.calculative.drawlineH) {
421
- pts.push({ x: to.x, y: from.y });
422
- if (Math.abs(to.y - from.y) < faceSpace) {
423
- to.isTemp = true;
424
- }
425
- }
426
- else {
427
- pts.push({ x: from.x, y: to.y });
428
- if (Math.abs(to.x - from.x) < faceSpace) {
429
- to.isTemp = true;
430
- }
431
- }
432
- }
433
- return pts;
434
- }
435
- export function anchorInHorizontal(pen, anchor, from) {
436
- var _a, _b;
437
- if (from === void 0) { from = true; }
438
- var anchors = pen.calculative.worldAnchors;
439
- if (!from) {
440
- anchors = [];
441
- pen.calculative.worldAnchors.forEach(function (item) {
442
- anchors.unshift(item);
443
- });
444
- }
445
- for (var i = 0; i < anchors.length; i++) {
446
- if (anchors[i].id === anchor.id) {
447
- break;
448
- }
449
- if (anchors[i].y !== anchor.y) {
450
- return false;
451
- }
452
- if (anchors[i].x === ((_a = anchors[i + 1]) === null || _a === void 0 ? void 0 : _a.x) &&
453
- anchors[i].y !== ((_b = anchors[i + 1]) === null || _b === void 0 ? void 0 : _b.y)) {
454
- return false;
455
- }
456
- }
457
- return true;
458
- }
459
- export function anchorInVertical(pen, anchor, from) {
460
- var _a, _b;
461
- if (from === void 0) { from = true; }
462
- var anchors = pen.calculative.worldAnchors;
463
- if (!from) {
464
- anchors = [];
465
- pen.calculative.worldAnchors.forEach(function (item) {
466
- anchors.unshift(item);
467
- });
468
- }
469
- for (var i = 0; i < anchors.length; i++) {
470
- if (anchors[i].id === anchor.id) {
471
- break;
472
- }
473
- if (anchors[i].x !== anchor.x) {
474
- return false;
475
- }
476
- if (anchors[i].y === ((_a = anchors[i + 1]) === null || _a === void 0 ? void 0 : _a.y) &&
477
- anchors[i].x !== ((_b = anchors[i + 1]) === null || _b === void 0 ? void 0 : _b.x)) {
478
- return false;
479
- }
480
- }
481
- return true;
482
- }
483
- export function translatePolylineAnchor(pen, anchor, pt) {
484
- if (!pen.calculative.worldAnchors) {
485
- return;
486
- }
487
- var i = pen.calculative.worldAnchors.findIndex(function (item) { return item.id === anchor.id; });
488
- var from = getFromAnchor(pen);
489
- var to = getToAnchor(pen);
490
- var prev = pen.calculative.worldAnchors[i - 1];
491
- var next = pen.calculative.worldAnchors[i + 1];
492
- if (pen.calculative.h == undefined) {
493
- if (from.connectTo) {
494
- if (anchorInHorizontal(pen, anchor, true)) {
495
- pen.calculative.h = true;
496
- }
497
- else if (anchorInVertical(pen, anchor, true)) {
498
- pen.calculative.h = false;
499
- }
500
- }
501
- if (pen.calculative.h == undefined && to.connectTo) {
502
- if (anchorInHorizontal(pen, anchor, false)) {
503
- pen.calculative.h = true;
504
- }
505
- else if (anchorInVertical(pen, anchor, false)) {
506
- pen.calculative.h = false;
507
- }
508
- }
509
- if (pen.calculative.h == undefined) {
510
- if (prev) {
511
- pen.calculative.h = prev.y === anchor.y;
512
- }
513
- else if (next) {
514
- pen.calculative.h = next.y === anchor.y;
515
- }
516
- }
517
- }
518
- // 水平
519
- if (pen.calculative.h) {
520
- anchor.x = pt.x;
521
- if (from.connectTo && anchorInHorizontal(pen, anchor, true)) {
522
- if (next && next.y !== anchor.y) {
523
- next.x = anchor.x;
524
- }
525
- return;
526
- }
527
- if (to.connectTo && anchorInHorizontal(pen, anchor, false)) {
528
- if (prev && prev.y !== anchor.y) {
529
- prev.x = anchor.x;
530
- }
531
- return;
532
- }
533
- var a = pen.anchors[i];
534
- var d = void 0;
535
- for (var pos = i - 1; pos > -1; pos--) {
536
- prev = pen.anchors[pos];
537
- if (d == undefined) {
538
- d = prev.y === a.y;
539
- }
540
- if (d === true) {
541
- if (prev.y === a.y) {
542
- pen.calculative.worldAnchors[pos].y = pt.y;
543
- }
544
- else {
545
- break;
546
- }
547
- }
548
- else {
549
- if (prev.x === a.x) {
550
- pen.calculative.worldAnchors[pos].x = pt.x;
551
- }
552
- else {
553
- break;
554
- }
555
- }
556
- }
557
- d = undefined;
558
- for (var pos = i + 1; pos < pen.calculative.worldAnchors.length; pos++) {
559
- next = pen.anchors[pos];
560
- if (next) {
561
- if (d == undefined) {
562
- d = next.y === a.y;
563
- }
564
- if (d === true) {
565
- if (next.y === a.y) {
566
- pen.calculative.worldAnchors[pos].y = pt.y;
567
- }
568
- else {
569
- break;
570
- }
571
- }
572
- else {
573
- if (next.x === a.x) {
574
- pen.calculative.worldAnchors[pos].x = pt.x;
575
- }
576
- else {
577
- break;
578
- }
579
- }
580
- }
581
- else {
582
- break;
583
- }
584
- }
585
- anchor.y = pt.y;
586
- }
587
- // 垂直
588
- else {
589
- anchor.y = pt.y;
590
- if (from.connectTo && anchorInVertical(pen, anchor, true)) {
591
- if (next && next.x !== anchor.x) {
592
- next.y = anchor.y;
593
- }
594
- return;
595
- }
596
- if (to.connectTo && anchorInVertical(pen, anchor, false)) {
597
- if (prev && prev.x !== anchor.x) {
598
- prev.y = anchor.y;
599
- }
600
- return;
601
- }
602
- var a = pen.anchors[i];
603
- var d = void 0;
604
- for (var pos = i - 1; pos > -1; pos--) {
605
- prev = pen.anchors[pos];
606
- if (d == undefined) {
607
- d = prev.x === a.x;
608
- }
609
- if (d === true) {
610
- if (prev.x === a.x) {
611
- pen.calculative.worldAnchors[pos].x = pt.x;
612
- }
613
- else {
614
- break;
615
- }
616
- }
617
- else {
618
- if (prev.y === a.y) {
619
- pen.calculative.worldAnchors[pos].y = pt.y;
620
- }
621
- else {
622
- break;
623
- }
624
- }
625
- }
626
- d = undefined;
627
- for (var pos = i + 1; pos < pen.calculative.worldAnchors.length; pos++) {
628
- next = pen.anchors[pos];
629
- if (next) {
630
- if (d == undefined) {
631
- d = next.x === a.x;
632
- }
633
- if (d === true) {
634
- if (next.x === a.x) {
635
- pen.calculative.worldAnchors[pos].x = pt.x;
636
- }
637
- else {
638
- break;
639
- }
640
- }
641
- else {
642
- if (next.y === a.y) {
643
- pen.calculative.worldAnchors[pos].y = pt.y;
644
- }
645
- else {
646
- break;
647
- }
648
- }
649
- }
650
- else {
651
- break;
652
- }
653
- }
654
- anchor.x = pt.x;
655
- }
656
- }
1
+ import { Direction } from '../../data';
2
+ import { deleteTempAnchor, facePen, getFromAnchor, getToAnchor, } from '../../pen';
3
+ import { s8 } from '../../utils';
4
+ let faceSpace = 10;
5
+ export function polyline(store, pen, mousedwon) {
6
+ if (!pen.calculative.worldAnchors) {
7
+ pen.calculative.worldAnchors = [];
8
+ }
9
+ faceSpace = store.options.polylineSpace || 10;
10
+ if (pen.calculative.worldAnchors.length < 2) {
11
+ return;
12
+ }
13
+ let from = getFromAnchor(pen);
14
+ let to = getToAnchor(pen);
15
+ if (!from || !to) {
16
+ return;
17
+ }
18
+ // 拖拽起点
19
+ let dragFrom;
20
+ if (pen.anchors?.length && from === pen.calculative.activeAnchor) {
21
+ dragFrom = true;
22
+ from = to;
23
+ to = getFromAnchor(pen);
24
+ }
25
+ else if ((!pen.anchors || !pen.anchors.length) &&
26
+ from !== pen.calculative.activeAnchor) {
27
+ from = pen.calculative.activeAnchor;
28
+ }
29
+ if (!from || !to) {
30
+ return;
31
+ }
32
+ from.next = undefined;
33
+ to.prev = undefined;
34
+ const connected = to.connectTo;
35
+ deleteTempAnchor(pen);
36
+ const pts = [];
37
+ const fromPen = store.pens[from.connectTo];
38
+ const toPen = store.pens[to.connectTo];
39
+ const fromFace = facePen(from, fromPen);
40
+ const toFace = facePen(to, toPen);
41
+ let a = getFacePoint(from, fromFace, faceSpace);
42
+ if (a) {
43
+ from = a;
44
+ pts.push(a);
45
+ }
46
+ a = getFacePoint(to, toFace, faceSpace);
47
+ const end = to;
48
+ let corner = undefined;
49
+ if (a) {
50
+ to = a;
51
+ if (end.connectTo) {
52
+ if ((a.y > end.y && from.y < end.y) || (a.y < end.y && from.y > end.y)) {
53
+ //拐角 防止连线覆盖
54
+ corner = a;
55
+ let _faceSpace = faceSpace;
56
+ if (from.x < a.x) {
57
+ _faceSpace = -_faceSpace;
58
+ }
59
+ if (Math.abs(from.x - a.x) < _faceSpace) {
60
+ _faceSpace = -_faceSpace;
61
+ }
62
+ const point = { x: a.x + _faceSpace, y: a.y, id: s8() };
63
+ to = point;
64
+ }
65
+ }
66
+ }
67
+ switch (fromFace) {
68
+ case Direction.Up:
69
+ pts.push(...getNextPointsOfUp(from, to, toFace));
70
+ break;
71
+ case Direction.Right:
72
+ pts.push(...getNextPointsOfRight(from, to, toFace));
73
+ break;
74
+ case Direction.Bottom:
75
+ pts.push(...getNextPointsOfBottom(from, to, toFace));
76
+ break;
77
+ case Direction.Left:
78
+ pts.push(...getNextPointsOfLeft(from, to, toFace));
79
+ break;
80
+ default:
81
+ pts.push(...getNextPoints(pen, from, to));
82
+ break;
83
+ }
84
+ pts.forEach((anchor) => {
85
+ anchor.id = s8();
86
+ anchor.penId = pen.id;
87
+ pen.calculative.worldAnchors.push(anchor);
88
+ });
89
+ pen.calculative.worldAnchors.push(to);
90
+ if (corner) {
91
+ pen.calculative.worldAnchors.push(corner);
92
+ }
93
+ if (a) {
94
+ pen.calculative.worldAnchors.push(end);
95
+ }
96
+ if (dragFrom) {
97
+ pen.calculative.worldAnchors.reverse();
98
+ }
99
+ if (connected) {
100
+ const i = pen.calculative.worldAnchors.length - 2;
101
+ pen.calculative.worldAnchors[i].isTemp = false;
102
+ pen.calculative.worldAnchors[1].isTemp = false;
103
+ }
104
+ }
105
+ function getFacePoint(pt, d, dis) {
106
+ const point = { x: pt.x, y: pt.y, id: s8() };
107
+ switch (d) {
108
+ case Direction.Up:
109
+ point.y -= dis;
110
+ break;
111
+ case Direction.Right:
112
+ point.x += dis;
113
+ break;
114
+ case Direction.Bottom:
115
+ point.y += dis;
116
+ break;
117
+ case Direction.Left:
118
+ point.x -= dis;
119
+ break;
120
+ default: {
121
+ return;
122
+ }
123
+ }
124
+ return point;
125
+ }
126
+ function getNextPointsOfUp(from, to, toFace) {
127
+ if (from.x === to.x || from.y === to.y) {
128
+ return [];
129
+ }
130
+ const pts = [];
131
+ let x;
132
+ let y;
133
+ switch (toFace) {
134
+ case Direction.Up:
135
+ if (from.y < to.y) {
136
+ x = to.x;
137
+ y = from.y;
138
+ }
139
+ else {
140
+ x = from.x;
141
+ y = to.y;
142
+ }
143
+ pts.push({ x, y });
144
+ break;
145
+ case Direction.Bottom:
146
+ x = to.x;
147
+ y = from.y;
148
+ if (to.y > from.y) {
149
+ x = from.x + (to.x - from.x) / 2;
150
+ pts.push({ x, y: from.y }, { x, y: to.y });
151
+ }
152
+ else {
153
+ const centerY = (from.y + to.y) / 2;
154
+ pts.push({ x: from.x, y: centerY }, { x: to.x, y: centerY });
155
+ }
156
+ break;
157
+ case Direction.Right:
158
+ x = to.x;
159
+ y = from.y;
160
+ if (to.x < from.x && to.y < from.y) {
161
+ x = from.x;
162
+ y = to.y;
163
+ }
164
+ pts.push({ x, y });
165
+ break;
166
+ case Direction.Left:
167
+ x = to.x;
168
+ y = from.y;
169
+ if (to.x > from.x && to.y < from.y) {
170
+ x = from.x;
171
+ y = to.y;
172
+ }
173
+ pts.push({ x, y });
174
+ break;
175
+ default:
176
+ if (to.y > from.y - faceSpace) {
177
+ x = from.x + (to.x - from.x) / 2;
178
+ pts.push({ x, y: from.y }, { x, y: to.y });
179
+ }
180
+ else {
181
+ const centerY = (from.y + to.y + faceSpace) / 2;
182
+ pts.push({ x: from.x, y: centerY }, { x: to.x, y: centerY });
183
+ }
184
+ break;
185
+ }
186
+ return pts;
187
+ }
188
+ function getNextPointsOfRight(from, to, toFace) {
189
+ if (from.x === to.x || from.y === to.y) {
190
+ return [];
191
+ }
192
+ const pts = [];
193
+ let x;
194
+ let y;
195
+ switch (toFace) {
196
+ case Direction.Up:
197
+ x = from.x;
198
+ y = to.y;
199
+ if (to.x > from.x && to.y > from.y) {
200
+ x = to.x;
201
+ y = from.y;
202
+ }
203
+ pts.push({ x, y });
204
+ break;
205
+ case Direction.Bottom:
206
+ x = from.x;
207
+ y = to.y;
208
+ if (to.x > from.x && to.y < from.y) {
209
+ x = to.x;
210
+ y = from.y;
211
+ }
212
+ pts.push({ x, y });
213
+ break;
214
+ case Direction.Left:
215
+ x = to.x;
216
+ y = from.y;
217
+ if (to.x < from.x) {
218
+ y = from.y + (to.y - from.y) / 2;
219
+ pts.push({ x: from.x, y }, { x: to.x, y });
220
+ }
221
+ else {
222
+ const centerX = (from.x + to.x) / 2;
223
+ pts.push({ x: centerX, y }, { x: centerX, y: to.y });
224
+ }
225
+ break;
226
+ case Direction.Right:
227
+ if (to.x < from.x) {
228
+ pts.push({ x: from.x, y: to.y });
229
+ }
230
+ else {
231
+ pts.push({ x: to.x, y: from.y });
232
+ }
233
+ break;
234
+ default:
235
+ x = to.x;
236
+ y = to.y;
237
+ if (to.x < from.x + faceSpace) {
238
+ pts.push({ x: from.x, y });
239
+ }
240
+ else {
241
+ const centerX = (from.x + to.x - faceSpace) / 2;
242
+ pts.push({ x: centerX, y: from.y }, { x: centerX, y });
243
+ }
244
+ break;
245
+ }
246
+ return pts;
247
+ }
248
+ function getNextPointsOfBottom(from, to, toFace) {
249
+ if (from.x === to.x || from.y === to.y) {
250
+ return [];
251
+ }
252
+ const pts = [];
253
+ let x;
254
+ let y;
255
+ switch (toFace) {
256
+ case Direction.Up:
257
+ x = from.x;
258
+ y = to.y;
259
+ if (to.y < from.y) {
260
+ x = from.x + (to.x - from.x) / 2;
261
+ pts.push({ x, y: from.y }, { x, y: to.y });
262
+ }
263
+ else {
264
+ const centerY = (from.y + to.y) / 2;
265
+ pts.push({ x, y: centerY }, { x: to.x, y: centerY });
266
+ }
267
+ break;
268
+ case Direction.Right:
269
+ x = to.x;
270
+ y = from.y;
271
+ if (to.x < from.x && to.y > from.y) {
272
+ x = from.x;
273
+ y = to.y;
274
+ }
275
+ pts.push({ x, y });
276
+ break;
277
+ case Direction.Bottom:
278
+ if (from.y > to.y) {
279
+ x = to.x;
280
+ y = from.y;
281
+ }
282
+ else {
283
+ x = from.x;
284
+ y = to.y;
285
+ }
286
+ pts.push({ x, y });
287
+ break;
288
+ case Direction.Left:
289
+ x = to.x;
290
+ y = from.y;
291
+ if (to.x > from.x && to.y > from.y) {
292
+ x = from.x;
293
+ y = to.y;
294
+ }
295
+ pts.push({ x, y });
296
+ break;
297
+ default:
298
+ x = from.x;
299
+ if (to.y < from.y + faceSpace) {
300
+ x = from.x + (to.x - from.x) / 2;
301
+ pts.push({ x, y: from.y }, { x, y: to.y });
302
+ }
303
+ else {
304
+ const centerY = (from.y + to.y - faceSpace) / 2;
305
+ pts.push({ x, y: centerY }, { x: to.x, y: centerY });
306
+ }
307
+ break;
308
+ }
309
+ return pts;
310
+ }
311
+ function getNextPointsOfLeft(from, to, toFace) {
312
+ if (from.x === to.x || from.y === to.y) {
313
+ return [];
314
+ }
315
+ const pts = [];
316
+ let x;
317
+ let y;
318
+ switch (toFace) {
319
+ case Direction.Up:
320
+ x = from.x;
321
+ y = to.y;
322
+ if (to.x < from.x && to.y > from.y) {
323
+ x = to.x;
324
+ y = from.y;
325
+ }
326
+ pts.push({ x, y });
327
+ break;
328
+ case Direction.Bottom:
329
+ x = from.x;
330
+ y = to.y;
331
+ if (to.x < from.x && to.y < from.y) {
332
+ x = to.x;
333
+ y = from.y;
334
+ }
335
+ pts.push({ x, y });
336
+ break;
337
+ case Direction.Right:
338
+ x = from.x;
339
+ y = to.y;
340
+ if (to.x > from.x) {
341
+ x = to.x;
342
+ y = from.y + (to.y - from.y) / 2;
343
+ pts.push({ x: from.x, y }, { x: to.x, y });
344
+ }
345
+ else {
346
+ const centerX = (from.x + to.x) / 2;
347
+ pts.push({ x: centerX, y: from.y }, { x: centerX, y: to.y });
348
+ }
349
+ break;
350
+ case Direction.Left:
351
+ if (to.x > from.x) {
352
+ pts.push({ x: from.x, y: to.y });
353
+ }
354
+ else {
355
+ pts.push({ x: to.x, y: from.y });
356
+ }
357
+ break;
358
+ default:
359
+ x = from.x;
360
+ y = to.y;
361
+ if (to.x < from.x - faceSpace) {
362
+ const centerX = (from.x + to.x + faceSpace) / 2;
363
+ pts.push({ x: centerX, y: from.y }, { x: centerX, y });
364
+ }
365
+ else {
366
+ pts.push({ x: from.x, y });
367
+ }
368
+ break;
369
+ }
370
+ return pts;
371
+ }
372
+ function getNextPoints(pen, from, to) {
373
+ const pts = [];
374
+ if (pen.calculative.drawlineH == undefined) {
375
+ pen.calculative.drawlineH =
376
+ Math.abs(to.x - from.x) > Math.abs(to.y - from.y);
377
+ }
378
+ let index = pen.calculative.worldAnchors.findIndex((anchor) => anchor.id == from.id);
379
+ if (index > 1) {
380
+ let prev = pen.calculative.worldAnchors[index - 1];
381
+ if (prev.x === from.x && prev.y !== from.y) {
382
+ //水平
383
+ pts.push({ x: to.x, y: from.y });
384
+ return pts;
385
+ }
386
+ else if (prev.y === from.y && prev.x !== from.x) {
387
+ //垂直
388
+ pts.push({ x: from.x, y: to.y });
389
+ return pts;
390
+ }
391
+ }
392
+ if (pen.calculative.worldAnchors.length) {
393
+ to.isTemp = undefined;
394
+ if (pen.calculative.drawlineH) {
395
+ pts.push({ x: to.x, y: from.y });
396
+ if (Math.abs(to.y - from.y) < faceSpace) {
397
+ to.isTemp = true;
398
+ }
399
+ }
400
+ else {
401
+ pts.push({ x: from.x, y: to.y });
402
+ if (Math.abs(to.x - from.x) < faceSpace) {
403
+ to.isTemp = true;
404
+ }
405
+ }
406
+ }
407
+ return pts;
408
+ }
409
+ export function anchorInHorizontal(pen, anchor, from = true) {
410
+ let anchors = pen.calculative.worldAnchors;
411
+ if (!from) {
412
+ anchors = [];
413
+ pen.calculative.worldAnchors.forEach((item) => {
414
+ anchors.unshift(item);
415
+ });
416
+ }
417
+ for (let i = 0; i < anchors.length; i++) {
418
+ if (anchors[i].id === anchor.id) {
419
+ break;
420
+ }
421
+ if (anchors[i].y !== anchor.y) {
422
+ return false;
423
+ }
424
+ if (anchors[i].x === anchors[i + 1]?.x &&
425
+ anchors[i].y !== anchors[i + 1]?.y) {
426
+ return false;
427
+ }
428
+ }
429
+ return true;
430
+ }
431
+ export function anchorInVertical(pen, anchor, from = true) {
432
+ let anchors = pen.calculative.worldAnchors;
433
+ if (!from) {
434
+ anchors = [];
435
+ pen.calculative.worldAnchors.forEach((item) => {
436
+ anchors.unshift(item);
437
+ });
438
+ }
439
+ for (let i = 0; i < anchors.length; i++) {
440
+ if (anchors[i].id === anchor.id) {
441
+ break;
442
+ }
443
+ if (anchors[i].x !== anchor.x) {
444
+ return false;
445
+ }
446
+ if (anchors[i].y === anchors[i + 1]?.y &&
447
+ anchors[i].x !== anchors[i + 1]?.x) {
448
+ return false;
449
+ }
450
+ }
451
+ return true;
452
+ }
453
+ export function translatePolylineAnchor(pen, anchor, pt) {
454
+ if (!pen.calculative.worldAnchors) {
455
+ return;
456
+ }
457
+ const i = pen.calculative.worldAnchors.findIndex((item) => item.id === anchor.id);
458
+ const from = getFromAnchor(pen);
459
+ const to = getToAnchor(pen);
460
+ let prev = pen.calculative.worldAnchors[i - 1];
461
+ let next = pen.calculative.worldAnchors[i + 1];
462
+ if (pen.calculative.h == undefined) {
463
+ if (from.connectTo) {
464
+ if (anchorInHorizontal(pen, anchor, true)) {
465
+ pen.calculative.h = true;
466
+ }
467
+ else if (anchorInVertical(pen, anchor, true)) {
468
+ pen.calculative.h = false;
469
+ }
470
+ }
471
+ if (pen.calculative.h == undefined && to.connectTo) {
472
+ if (anchorInHorizontal(pen, anchor, false)) {
473
+ pen.calculative.h = true;
474
+ }
475
+ else if (anchorInVertical(pen, anchor, false)) {
476
+ pen.calculative.h = false;
477
+ }
478
+ }
479
+ if (pen.calculative.h == undefined) {
480
+ if (prev) {
481
+ pen.calculative.h = prev.y === anchor.y;
482
+ }
483
+ else if (next) {
484
+ pen.calculative.h = next.y === anchor.y;
485
+ }
486
+ }
487
+ }
488
+ // 水平
489
+ if (pen.calculative.h) {
490
+ anchor.x = pt.x;
491
+ if (from.connectTo && anchorInHorizontal(pen, anchor, true)) {
492
+ if (next && next.y !== anchor.y) {
493
+ next.x = anchor.x;
494
+ }
495
+ return;
496
+ }
497
+ if (to.connectTo && anchorInHorizontal(pen, anchor, false)) {
498
+ if (prev && prev.y !== anchor.y) {
499
+ prev.x = anchor.x;
500
+ }
501
+ return;
502
+ }
503
+ const a = pen.anchors[i];
504
+ let d;
505
+ for (let pos = i - 1; pos > -1; pos--) {
506
+ prev = pen.anchors[pos];
507
+ if (d == undefined) {
508
+ d = prev.y === a.y;
509
+ }
510
+ if (d === true) {
511
+ if (prev.y === a.y) {
512
+ pen.calculative.worldAnchors[pos].y = pt.y;
513
+ }
514
+ else {
515
+ break;
516
+ }
517
+ }
518
+ else {
519
+ if (prev.x === a.x) {
520
+ pen.calculative.worldAnchors[pos].x = pt.x;
521
+ }
522
+ else {
523
+ break;
524
+ }
525
+ }
526
+ }
527
+ d = undefined;
528
+ for (let pos = i + 1; pos < pen.calculative.worldAnchors.length; pos++) {
529
+ next = pen.anchors[pos];
530
+ if (next) {
531
+ if (d == undefined) {
532
+ d = next.y === a.y;
533
+ }
534
+ if (d === true) {
535
+ if (next.y === a.y) {
536
+ pen.calculative.worldAnchors[pos].y = pt.y;
537
+ }
538
+ else {
539
+ break;
540
+ }
541
+ }
542
+ else {
543
+ if (next.x === a.x) {
544
+ pen.calculative.worldAnchors[pos].x = pt.x;
545
+ }
546
+ else {
547
+ break;
548
+ }
549
+ }
550
+ }
551
+ else {
552
+ break;
553
+ }
554
+ }
555
+ anchor.y = pt.y;
556
+ }
557
+ // 垂直
558
+ else {
559
+ anchor.y = pt.y;
560
+ if (from.connectTo && anchorInVertical(pen, anchor, true)) {
561
+ if (next && next.x !== anchor.x) {
562
+ next.y = anchor.y;
563
+ }
564
+ return;
565
+ }
566
+ if (to.connectTo && anchorInVertical(pen, anchor, false)) {
567
+ if (prev && prev.x !== anchor.x) {
568
+ prev.y = anchor.y;
569
+ }
570
+ return;
571
+ }
572
+ const a = pen.anchors[i];
573
+ let d;
574
+ for (let pos = i - 1; pos > -1; pos--) {
575
+ prev = pen.anchors[pos];
576
+ if (d == undefined) {
577
+ d = prev.x === a.x;
578
+ }
579
+ if (d === true) {
580
+ if (prev.x === a.x) {
581
+ pen.calculative.worldAnchors[pos].x = pt.x;
582
+ }
583
+ else {
584
+ break;
585
+ }
586
+ }
587
+ else {
588
+ if (prev.y === a.y) {
589
+ pen.calculative.worldAnchors[pos].y = pt.y;
590
+ }
591
+ else {
592
+ break;
593
+ }
594
+ }
595
+ }
596
+ d = undefined;
597
+ for (let pos = i + 1; pos < pen.calculative.worldAnchors.length; pos++) {
598
+ next = pen.anchors[pos];
599
+ if (next) {
600
+ if (d == undefined) {
601
+ d = next.x === a.x;
602
+ }
603
+ if (d === true) {
604
+ if (next.x === a.x) {
605
+ pen.calculative.worldAnchors[pos].x = pt.x;
606
+ }
607
+ else {
608
+ break;
609
+ }
610
+ }
611
+ else {
612
+ if (next.y === a.y) {
613
+ pen.calculative.worldAnchors[pos].y = pt.y;
614
+ }
615
+ else {
616
+ break;
617
+ }
618
+ }
619
+ }
620
+ else {
621
+ break;
622
+ }
623
+ }
624
+ anchor.x = pt.x;
625
+ }
626
+ }
657
627
  //# sourceMappingURL=polyline.js.map