@leafer-in/arrow 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/arrow.js CHANGED
@@ -1,70 +1,42 @@
1
1
  this.LeaferIN = this.LeaferIN || {};
2
- this.LeaferIN.arrow = (function (exports, draw) {
3
- 'use strict';
4
2
 
5
- /******************************************************************************
6
- Copyright (c) Microsoft Corporation.
7
-
8
- Permission to use, copy, modify, and/or distribute this software for any
9
- purpose with or without fee is hereby granted.
10
-
11
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
- PERFORMANCE OF THIS SOFTWARE.
18
- ***************************************************************************** */
19
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
20
-
21
-
22
- function __decorate(decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
-
29
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
30
- var e = new Error(message);
31
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32
- };
33
-
34
- class ArrowData extends draw.LineData {
3
+ this.LeaferIN.arrow = function(exports, draw) {
4
+ "use strict";
5
+ function __decorate(decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
35
9
  }
36
-
10
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
11
+ var e = new Error(message);
12
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
13
+ };
14
+ class ArrowData extends draw.LineData {}
37
15
  function arrowType(defaultValue) {
38
- return draw.decorateLeafAttr(defaultValue, (key) => draw.attr({
16
+ return draw.decorateLeafAttr(defaultValue, key => draw.attr({
39
17
  set(value) {
40
18
  if (this.__setAttr(key, value)) {
41
19
  const data = this.__;
42
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
20
+ data.__useArrow = data.startArrow !== "none" || data.endArrow !== "none";
43
21
  draw.doStrokeType(this);
44
22
  }
45
23
  }
46
24
  }));
47
25
  }
48
-
49
26
  exports.Arrow = class Arrow extends draw.Line {
50
- get __tag() { return 'Arrow'; }
27
+ get __tag() {
28
+ return "Arrow";
29
+ }
51
30
  constructor(data) {
52
31
  super(data);
53
32
  this.__.__useArrow = true;
54
33
  }
55
34
  };
56
- __decorate([
57
- draw.dataProcessor(ArrowData)
58
- ], exports.Arrow.prototype, "__", void 0);
59
- __decorate([
60
- arrowType('angle')
61
- ], exports.Arrow.prototype, "endArrow", void 0);
62
- exports.Arrow = __decorate([
63
- draw.registerUI()
64
- ], exports.Arrow);
65
-
66
- const { M: M$1, L: L$1, C: C$1, Q: Q$1, O: O$1 } = draw.PathCommandMap;
67
- const { rotate: rotate$1, copyFrom: copyFrom$1, scale } = draw.PointHelper;
35
+ __decorate([ draw.dataProcessor(ArrowData) ], exports.Arrow.prototype, "__", void 0);
36
+ __decorate([ arrowType("angle") ], exports.Arrow.prototype, "endArrow", void 0);
37
+ exports.Arrow = __decorate([ draw.registerUI() ], exports.Arrow);
38
+ const {M: M$1, L: L$1, C: C$1, Q: Q$1, O: O$1} = draw.PathCommandMap;
39
+ const {rotate: rotate$1, copyFrom: copyFrom$1, scale: scale} = draw.PointHelper;
68
40
  const point = {};
69
41
  const PathMatrixHelper = {
70
42
  layout(data, x, y, scaleX, scaleY, rotation, origin) {
@@ -72,32 +44,32 @@ this.LeaferIN.arrow = (function (exports, draw) {
72
44
  while (i < len) {
73
45
  command = data[i];
74
46
  switch (command) {
75
- case M$1:
76
- case L$1:
77
- setPoint$1(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
78
- i += 3;
79
- break;
80
- case C$1:
81
- for (j = 1; j < 6; j += 2)
82
- setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
83
- i += 7;
84
- break;
85
- case Q$1:
86
- for (j = 1; j < 4; j += 2)
87
- setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
88
- i += 5;
89
- break;
90
- case O$1:
91
- data[i + 1] += x;
92
- data[i + 2] += y;
93
- if (scaleX)
94
- data[i + 3] *= scaleX;
95
- if (rotation) {
96
- data[i + 4] += rotation;
97
- data[i + 5] += rotation;
98
- }
99
- i += 7;
100
- break;
47
+ case M$1:
48
+ case L$1:
49
+ setPoint$1(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
50
+ i += 3;
51
+ break;
52
+
53
+ case C$1:
54
+ for (j = 1; j < 6; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
55
+ i += 7;
56
+ break;
57
+
58
+ case Q$1:
59
+ for (j = 1; j < 4; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
60
+ i += 5;
61
+ break;
62
+
63
+ case O$1:
64
+ data[i + 1] += x;
65
+ data[i + 2] += y;
66
+ if (scaleX) data[i + 3] *= scaleX;
67
+ if (rotation) {
68
+ data[i + 4] += rotation;
69
+ data[i + 5] += rotation;
70
+ }
71
+ i += 7;
72
+ break;
101
73
  }
102
74
  }
103
75
  },
@@ -107,139 +79,198 @@ this.LeaferIN.arrow = (function (exports, draw) {
107
79
  };
108
80
  function setPoint$1(data, startIndex, x, y, scaleX, scaleY, rotation, origin) {
109
81
  copyFrom$1(point, data[startIndex], data[startIndex + 1]);
110
- if (rotation)
111
- rotate$1(point, rotation, origin);
112
- if (scaleX)
113
- scale(point, scaleX, scaleY);
82
+ if (rotation) rotate$1(point, rotation, origin);
83
+ if (scaleX) scale(point, scaleX, scaleY);
114
84
  data[startIndex] = x + point.x;
115
85
  data[startIndex + 1] = y + point.y;
116
86
  }
117
-
118
- const { layout, rotate } = PathMatrixHelper;
119
- const { getAngle } = draw.PointHelper;
120
- const half = { x: -0.5 };
121
- const angle = { connect: half, offset: { x: -0.71, bevelJoin: 0.36, roundJoin: 0.22 }, path: [1, -3, -3, 2, 0, 0, 2, -3, 3] };
122
- const angleSide = { connect: half, offset: { x: -1.207, bevelJoin: 0.854, roundJoin: 0.707 }, path: [1, -3, -3, 2, 0, 0, 2, -1, 0] };
123
- const triangleLinePath = [1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0];
124
- const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1], dashPath: [1, -2, 0, 2, -0.5, 0] };
125
- const arrowLinePath = [1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0];
126
- const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95], dashPath: [1, -3, 0, 2, -0.5, 0] };
127
- const triangleFlip = { offset: half, path: [...triangle.path], dashPath: [1, -2.5, 0, 2, -1, 0] };
128
- rotate(triangleFlip.path, 180, { x: -1.5, y: 0 });
129
- const circleLine = { connect: { x: -1.3 }, path: [1, 1.8, -0.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0], };
130
- const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0], dashPath: [1, -0.5, 0, 2, 0.5, 0] };
131
- const squareLine = { connect: { x: -1.3 }, path: [1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0] };
132
- const square = { path: [...squareLine.path, 2, -1.4, -0.49, 2, 1, -0.49, 1, -1.4, 0.49, 2, 1, 0.49] };
87
+ const {layout: layout, rotate: rotate} = PathMatrixHelper;
88
+ const {getAngle: getAngle} = draw.PointHelper;
89
+ const half = {
90
+ x: -.5
91
+ };
92
+ const angle = {
93
+ connect: half,
94
+ offset: {
95
+ x: -.71,
96
+ bevelJoin: .36,
97
+ roundJoin: .22
98
+ },
99
+ path: [ 1, -3, -3, 2, 0, 0, 2, -3, 3 ]
100
+ };
101
+ const angleSide = {
102
+ connect: half,
103
+ offset: {
104
+ x: -1.207,
105
+ bevelJoin: .854,
106
+ roundJoin: .707
107
+ },
108
+ path: [ 1, -3, -3, 2, 0, 0, 2, -1, 0 ]
109
+ };
110
+ const triangleLinePath = [ 1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0 ];
111
+ const triangle = {
112
+ connect: half,
113
+ offset: {
114
+ x: -.9,
115
+ bevelJoin: .624,
116
+ roundJoin: .4
117
+ },
118
+ path: [ ...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1 ],
119
+ dashPath: [ 1, -2, 0, 2, -.5, 0 ]
120
+ };
121
+ const arrowLinePath = [ 1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0 ];
122
+ const arrow = {
123
+ connect: half,
124
+ offset: {
125
+ x: -1.1,
126
+ bevelJoin: .872,
127
+ roundJoin: .6
128
+ },
129
+ path: [ ...arrowLinePath, 1, -2.25, .95, 2, -2.25, -.95 ],
130
+ dashPath: [ 1, -3, 0, 2, -.5, 0 ]
131
+ };
132
+ const triangleFlip = {
133
+ offset: half,
134
+ path: [ ...triangle.path ],
135
+ dashPath: [ 1, -2.5, 0, 2, -1, 0 ]
136
+ };
137
+ rotate(triangleFlip.path, 180, {
138
+ x: -1.5,
139
+ y: 0
140
+ });
141
+ const circleLine = {
142
+ connect: {
143
+ x: -1.3
144
+ },
145
+ path: [ 1, 1.8, -.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0 ]
146
+ };
147
+ const circle = {
148
+ connect: {
149
+ x: .5
150
+ },
151
+ path: [ ...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0 ],
152
+ dashPath: [ 1, -.5, 0, 2, .5, 0 ]
153
+ };
154
+ const squareLine = {
155
+ connect: {
156
+ x: -1.3
157
+ },
158
+ path: [ 1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0 ]
159
+ };
160
+ const square = {
161
+ path: [ ...squareLine.path, 2, -1.4, -.49, 2, 1, -.49, 1, -1.4, .49, 2, 1, .49 ]
162
+ };
133
163
  const diamondLine = draw.DataHelper.clone(squareLine);
134
164
  const diamond = draw.DataHelper.clone(square);
135
165
  rotate(diamondLine.path, 45);
136
166
  rotate(diamond.path, 45);
137
- const mark = { offset: half, path: [1, 0, -2, 2, 0, 2] };
167
+ const mark = {
168
+ offset: half,
169
+ path: [ 1, 0, -2, 2, 0, 2 ]
170
+ };
138
171
  const arrows = {
139
- angle,
140
- 'angle-side': angleSide,
141
- arrow,
142
- triangle,
143
- 'triangle-flip': triangleFlip,
144
- circle,
145
- 'circle-line': circleLine,
146
- square,
147
- 'square-line': squareLine,
148
- diamond,
149
- 'diamond-line': diamondLine,
150
- mark,
172
+ angle: angle,
173
+ "angle-side": angleSide,
174
+ arrow: arrow,
175
+ triangle: triangle,
176
+ "triangle-flip": triangleFlip,
177
+ circle: circle,
178
+ "circle-line": circleLine,
179
+ square: square,
180
+ "square-line": squareLine,
181
+ diamond: diamond,
182
+ "diamond-line": diamondLine,
183
+ mark: mark
151
184
  };
152
185
  function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
153
- const { strokeCap, strokeJoin } = ui.__;
154
- const { offset, connect, path, dashPath } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
186
+ const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
187
+ const {offset: offset, connect: connect, path: path, dashPath: dashPath} = draw.isObject(arrow) ? arrow : arrows[arrow];
155
188
  let connectX = connect ? connect.x : 0;
156
189
  let offsetX = offset ? offset.x : 0;
157
- const data = [...path];
158
- if (hasDashPattern && dashPath)
159
- data.push(...dashPath);
160
- if (strokeCap !== 'none')
161
- connectX -= 0.5;
190
+ const data = [ ...path ];
191
+ if (hasDashPattern && dashPath) data.push(...dashPath);
192
+ if (strokeCap !== "none") connectX -= .5;
162
193
  if (offset) {
163
- if (strokeJoin === 'round' && offset.roundJoin)
164
- offsetX += offset.roundJoin;
165
- else if (strokeJoin === 'bevel' && offset.bevelJoin)
166
- offsetX += offset.bevelJoin;
194
+ if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
167
195
  }
168
- if (offsetX)
169
- layout(data, offsetX, 0);
196
+ if (offsetX) layout(data, offsetX, 0);
170
197
  layout(data, to.x, to.y, scale, scale, getAngle(from, to));
171
198
  connectOffset.x = (connectX + offsetX) * scale;
172
199
  return data;
173
200
  }
174
-
175
- const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = draw.PathCommandMap;
176
- const { copy, copyFrom, getDistancePoint, } = draw.PointHelper;
201
+ const {M: M, L: L, C: C, Q: Q, Z: Z, N: N, D: D, X: X, G: G, F: F, O: O, P: P, U: U} = draw.PathCommandMap;
202
+ const {copy: copy, copyFrom: copyFrom, getDistancePoint: getDistancePoint} = draw.PointHelper;
177
203
  const connectPoint = {};
178
204
  const first = {}, second = {};
179
205
  const last = {}, now = {};
180
206
  const PathArrowModule = {
181
207
  list: arrows,
182
208
  addArrows(ui, changeRenderPath) {
183
- const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data } = ui.__;
184
- let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== 'none';
209
+ const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
210
+ let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
185
211
  while (i < len) {
186
212
  command = data[i];
187
213
  switch (command) {
188
- case M:
189
- case L:
190
- if (count < 2 || i + 6 >= len) {
191
- copyFrom(now, data[i + 1], data[i + 2]);
192
- if (!count && useStartArrow)
193
- copy(first, now);
194
- }
195
- i += 3;
196
- break;
197
- case C:
198
- if (count === 1 || i + 7 === len)
199
- copyPoints(data, last, now, i + 3);
200
- i += 7;
201
- break;
202
- case Q:
203
- if (count === 1 || i + 5 === len)
204
- copyPoints(data, last, now, i + 1);
205
- i += 5;
206
- break;
207
- case Z:
208
- return;
209
- case N:
210
- i += 5;
211
- break;
212
- case D:
213
- i += 9;
214
- break;
215
- case X:
216
- i += 6;
217
- break;
218
- case G:
219
- i += 9;
220
- break;
221
- case F:
222
- i += 5;
223
- break;
224
- case O:
225
- i += 7;
226
- break;
227
- case P:
228
- i += 4;
229
- break;
230
- case U:
231
- if (count === 1 || i + 6 === len)
232
- copyPoints(data, last, now, i + 1);
233
- i += 6;
234
- break;
214
+ case M:
215
+ case L:
216
+ if (count < 2 || i + 6 >= len) {
217
+ copyFrom(now, data[i + 1], data[i + 2]);
218
+ if (!count && useStartArrow) copy(first, now);
219
+ }
220
+ i += 3;
221
+ break;
222
+
223
+ case C:
224
+ if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
225
+ i += 7;
226
+ break;
227
+
228
+ case Q:
229
+ if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
230
+ i += 5;
231
+ break;
232
+
233
+ case Z:
234
+ return;
235
+
236
+ case N:
237
+ i += 5;
238
+ break;
239
+
240
+ case D:
241
+ i += 9;
242
+ break;
243
+
244
+ case X:
245
+ i += 6;
246
+ break;
247
+
248
+ case G:
249
+ i += 9;
250
+ break;
251
+
252
+ case F:
253
+ i += 5;
254
+ break;
255
+
256
+ case O:
257
+ i += 7;
258
+ break;
259
+
260
+ case P:
261
+ i += 4;
262
+ break;
263
+
264
+ case U:
265
+ if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
266
+ i += 6;
267
+ break;
235
268
  }
236
269
  count++;
237
- if (count === 1 && command !== M)
238
- return;
239
- if (count === 2 && useStartArrow)
240
- copy(second, command === L ? now : last);
270
+ if (count === 1 && command !== M) return;
271
+ if (count === 2 && useStartArrow) copy(second, command === L ? now : last);
241
272
  if (i === len) {
242
- const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
273
+ const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
243
274
  const pathForArrow = ui.__.__pathForArrow = [];
244
275
  if (useStartArrow) {
245
276
  const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
@@ -250,32 +281,33 @@ this.LeaferIN.arrow = (function (exports, draw) {
250
281
  path[2] = second.y;
251
282
  }
252
283
  }
253
- if (endArrow && endArrow !== 'none') {
284
+ if (endArrow && endArrow !== "none") {
254
285
  const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
255
286
  dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
256
287
  if (connectPoint.x) {
257
288
  getDistancePoint(now, last, -connectPoint.x, true);
258
289
  let index;
259
290
  switch (command) {
260
- case L:
261
- index = i - 3 + 1;
262
- break;
263
- case C:
264
- index = i - 7 + 5;
265
- break;
266
- case Q:
267
- index = i - 5 + 3;
268
- break;
269
- case U:
270
- index = i - 6 + 3;
271
- break;
291
+ case L:
292
+ index = i - 3 + 1;
293
+ break;
294
+
295
+ case C:
296
+ index = i - 7 + 5;
297
+ break;
298
+
299
+ case Q:
300
+ index = i - 5 + 3;
301
+ break;
302
+
303
+ case U:
304
+ index = i - 6 + 3;
305
+ break;
272
306
  }
273
- if (index)
274
- setPoint(path, last, index);
307
+ if (index) setPoint(path, last, index);
275
308
  }
276
309
  }
277
- }
278
- else {
310
+ } else {
279
311
  copy(last, now);
280
312
  }
281
313
  }
@@ -289,10 +321,9 @@ this.LeaferIN.arrow = (function (exports, draw) {
289
321
  data[startIndex] = point.x;
290
322
  data[startIndex + 1] = point.y;
291
323
  }
292
-
293
- draw.Plugin.add('arrow');
294
- draw.UI.addAttr('startArrow', 'none', arrowType);
295
- draw.UI.addAttr('endArrow', 'none', arrowType);
324
+ draw.Plugin.add("arrow");
325
+ draw.UI.addAttr("startArrow", "none", arrowType);
326
+ draw.UI.addAttr("endArrow", "none", arrowType);
296
327
  Object.assign(draw.PathArrow, PathArrowModule);
297
328
  Object.assign(draw.Paint, {
298
329
  strokeArrow(_stroke, ui, canvas) {
@@ -304,12 +335,9 @@ this.LeaferIN.arrow = (function (exports, draw) {
304
335
  }
305
336
  }
306
337
  });
307
-
308
338
  exports.ArrowData = ArrowData;
309
339
  exports.PathArrowModule = PathArrowModule;
310
340
  exports.PathMatrixHelper = PathMatrixHelper;
311
341
  exports.arrowType = arrowType;
312
-
313
342
  return exports;
314
-
315
- })({}, LeaferUI);
343
+ }({}, LeaferUI);
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@leafer-ui/draw");function t(e,t,r,o){var a,n=arguments.length,s=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(s=(n<3?a(s):n>3?a(t,r,s):a(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class r extends e.LineData{}function o(t){return e.decorateLeafAttr(t,(t=>e.attr({set(r){if(this.__setAttr(t,r)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,e.doStrokeType(this)}}})))}exports.Arrow=class extends e.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},t([e.dataProcessor(r)],exports.Arrow.prototype,"__",void 0),t([o("angle")],exports.Arrow.prototype,"endArrow",void 0),exports.Arrow=t([e.registerUI()],exports.Arrow);const{M:a,L:n,C:s,Q:c,O:i}=e.PathCommandMap,{rotate:p,copyFrom:h,scale:l}=e.PointHelper,d={},f={layout(e,t,r,o,p,h,l){let d,f,_=0,x=e.length;for(;_<x;)switch(d=e[_],d){case a:case n:u(e,_+1,t,r,o,p,h,l),_+=3;break;case s:for(f=1;f<6;f+=2)u(e,_+f,t,r,o,p,h,l);_+=7;break;case c:for(f=1;f<4;f+=2)u(e,_+f,t,r,o,p,h,l);_+=5;break;case i:e[_+1]+=t,e[_+2]+=r,o&&(e[_+3]*=o),h&&(e[_+4]+=h,e[_+5]+=h),_+=7}},rotate(e,t,r){f.layout(e,0,0,1,1,t,r)}};function u(e,t,r,o,a,n,s,c){h(d,e[t],e[t+1]),s&&p(d,s,c),a&&l(d,a,n),e[t]=r+d.x,e[t+1]=o+d.y}const{layout:_,rotate:x}=f,{getAngle:w}=e.PointHelper,b={x:-.5},A={connect:b,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},P={connect:b,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},k={connect:b,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},y={connect:b,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},g={offset:b,path:[...k.path],dashPath:[1,-2.5,0,2,-1,0]};x(g.path,180,{x:-1.5,y:0});const J={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},v={connect:{x:.5},path:[...J.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},m={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},D={path:[...m.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},F=e.DataHelper.clone(m),O=e.DataHelper.clone(D);x(F.path,45),x(O.path,45);const j={angle:A,"angle-side":P,arrow:y,triangle:k,"triangle-flip":g,circle:v,"circle-line":J,square:D,"square-line":m,diamond:O,"diamond-line":F,mark:{offset:b,path:[1,0,-2,2,0,2]}};function H(e,t,r,o,a,n,s){const{strokeCap:c,strokeJoin:i}=e.__,{offset:p,connect:h,path:l,dashPath:d}="object"==typeof t?t:j[t];let f=h?h.x:0,u=p?p.x:0;const x=[...l];return s&&d&&x.push(...d),"none"!==c&&(f-=.5),p&&("round"===i&&p.roundJoin?u+=p.roundJoin:"bevel"===i&&p.bevelJoin&&(u+=p.bevelJoin)),u&&_(x,u,0),_(x,o.x,o.y,a,a,w(r,o)),n.x=(f+u)*a,x}const{M:M,L:C,C:L,Q:R,Z:U,N:q,D:I,X:S,G:E,F:Q,O:T,P:B,U:G}=e.PathCommandMap,{copy:N,copyFrom:W,getDistancePoint:X}=e.PointHelper,Z={},z={},K={},V={},Y={},$={list:j,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:a,dashPattern:n,__pathForRender:s}=e.__;let c,i=0,p=s.length,h=0,l=r&&"none"!==r;for(;i<p;){switch(c=s[i],c){case M:case C:(h<2||i+6>=p)&&(W(Y,s[i+1],s[i+2]),!h&&l&&N(z,Y)),i+=3;break;case L:1!==h&&i+7!==p||ee(s,V,Y,i+3),i+=7;break;case R:1!==h&&i+5!==p||ee(s,V,Y,i+1),i+=5;break;case U:return;case q:i+=5;break;case I:i+=9;break;case S:i+=6;break;case E:i+=9;break;case Q:i+=5;break;case T:i+=7;break;case B:i+=4;break;case G:1!==h&&i+6!==p||ee(s,V,Y,i+1),i+=6}if(h++,1===h&&c!==M)return;if(2===h&&l&&N(K,c===C?Y:V),i===p){const p=e.__.__pathForRender=t?[...s]:s,h=e.__.__pathForArrow=[];if(l){const t=H(e,r,K,z,a,Z,!!n);n?h.push(...t):p.push(...t),Z.x&&(X(z,K,-Z.x,!0),p[1]=K.x,p[2]=K.y)}if(o&&"none"!==o){const t=H(e,o,V,Y,a,Z,!!n);if(n?h.push(...t):p.push(...t),Z.x){let e;switch(X(Y,V,-Z.x,!0),c){case C:e=i-3+1;break;case L:e=i-7+5;break;case R:e=i-5+3;break;case G:e=i-6+3}e&&te(p,V,e)}}}else N(V,Y)}}};function ee(e,t,r,o){W(t,e[o],e[o+1]),W(r,e[o+2],e[o+3])}function te(e,t,r){e[r]=t.x,e[r+1]=t.y}e.Plugin.add("arrow"),e.UI.addAttr("startArrow","none",o),e.UI.addAttr("endArrow","none",o),Object.assign(e.PathArrow,$),Object.assign(e.Paint,{strokeArrow(e,t,r){t.__.dashPattern&&(r.beginPath(),t.__drawPathByData(r,t.__.__pathForArrow),r.dashPattern=null,r.stroke())}}),exports.ArrowData=r,exports.PathArrowModule=$,exports.PathMatrixHelper=f,exports.arrowType=o;
1
+ "use strict";var e=require("@leafer-ui/draw");function t(e,t,r,o){var a,n=arguments.length,s=n<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(a=e[c])&&(s=(n<3?a(s):n>3?a(t,r,s):a(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class r extends e.LineData{}function o(t){return e.decorateLeafAttr(t,t=>e.attr({set(r){if(this.__setAttr(t,r)){const t=this.__;t.__useArrow="none"!==t.startArrow||"none"!==t.endArrow,e.doStrokeType(this)}}}))}exports.Arrow=class extends e.Line{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}},t([e.dataProcessor(r)],exports.Arrow.prototype,"__",void 0),t([o("angle")],exports.Arrow.prototype,"endArrow",void 0),exports.Arrow=t([e.registerUI()],exports.Arrow);const{M:a,L:n,C:s,Q:c,O:i}=e.PathCommandMap,{rotate:p,copyFrom:h,scale:l}=e.PointHelper,d={},f={layout(e,t,r,o,p,h,l){let d,f,_=0,x=e.length;for(;_<x;)switch(d=e[_],d){case a:case n:u(e,_+1,t,r,o,p,h,l),_+=3;break;case s:for(f=1;f<6;f+=2)u(e,_+f,t,r,o,p,h,l);_+=7;break;case c:for(f=1;f<4;f+=2)u(e,_+f,t,r,o,p,h,l);_+=5;break;case i:e[_+1]+=t,e[_+2]+=r,o&&(e[_+3]*=o),h&&(e[_+4]+=h,e[_+5]+=h),_+=7}},rotate(e,t,r){f.layout(e,0,0,1,1,t,r)}};function u(e,t,r,o,a,n,s,c){h(d,e[t],e[t+1]),s&&p(d,s,c),a&&l(d,a,n),e[t]=r+d.x,e[t+1]=o+d.y}const{layout:_,rotate:x}=f,{getAngle:w}=e.PointHelper,b={x:-.5},A={connect:b,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},P={connect:b,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},k={connect:b,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0,1,-2.05,1.1,2,-2.05,-1.1],dashPath:[1,-2,0,2,-.5,0]},y={connect:b,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0,1,-2.25,.95,2,-2.25,-.95],dashPath:[1,-3,0,2,-.5,0]},g={offset:b,path:[...k.path],dashPath:[1,-2.5,0,2,-1,0]};x(g.path,180,{x:-1.5,y:0});const J={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},v={connect:{x:.5},path:[...J.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},m={connect:{x:-1.3},path:[1,-1.4,0,2,-1.4,-1.4,2,1.4,-1.4,2,1.4,1.4,2,-1.4,1.4,2,-1.4,0]},D={path:[...m.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},O=e.DataHelper.clone(m),F=e.DataHelper.clone(D);x(O.path,45),x(F.path,45);const j={angle:A,"angle-side":P,arrow:y,triangle:k,"triangle-flip":g,circle:v,"circle-line":J,square:D,"square-line":m,diamond:F,"diamond-line":O,mark:{offset:b,path:[1,0,-2,2,0,2]}};function H(t,r,o,a,n,s,c){const{strokeCap:i,strokeJoin:p}=t.__,{offset:h,connect:l,path:d,dashPath:f}=e.isObject(r)?r:j[r];let u=l?l.x:0,x=h?h.x:0;const b=[...d];return c&&f&&b.push(...f),"none"!==i&&(u-=.5),h&&("round"===p&&h.roundJoin?x+=h.roundJoin:"bevel"===p&&h.bevelJoin&&(x+=h.bevelJoin)),x&&_(b,x,0),_(b,a.x,a.y,n,n,w(o,a)),s.x=(u+x)*n,b}const{M:M,L:C,C:L,Q:R,Z:U,N:q,D:I,X:S,G:E,F:Q,O:T,P:B,U:G}=e.PathCommandMap,{copy:N,copyFrom:W,getDistancePoint:X}=e.PointHelper,Z={},z={},K={},V={},Y={},$={list:j,addArrows(e,t){const{startArrow:r,endArrow:o,strokeWidth:a,dashPattern:n,__pathForRender:s}=e.__;let c,i=0,p=s.length,h=0,l=r&&"none"!==r;for(;i<p;){switch(c=s[i],c){case M:case C:(h<2||i+6>=p)&&(W(Y,s[i+1],s[i+2]),!h&&l&&N(z,Y)),i+=3;break;case L:1!==h&&i+7!==p||ee(s,V,Y,i+3),i+=7;break;case R:1!==h&&i+5!==p||ee(s,V,Y,i+1),i+=5;break;case U:return;case q:i+=5;break;case I:i+=9;break;case S:i+=6;break;case E:i+=9;break;case Q:i+=5;break;case T:i+=7;break;case B:i+=4;break;case G:1!==h&&i+6!==p||ee(s,V,Y,i+1),i+=6}if(h++,1===h&&c!==M)return;if(2===h&&l&&N(K,c===C?Y:V),i===p){const p=e.__.__pathForRender=t?[...s]:s,h=e.__.__pathForArrow=[];if(l){const t=H(e,r,K,z,a,Z,!!n);n?h.push(...t):p.push(...t),Z.x&&(X(z,K,-Z.x,!0),p[1]=K.x,p[2]=K.y)}if(o&&"none"!==o){const t=H(e,o,V,Y,a,Z,!!n);if(n?h.push(...t):p.push(...t),Z.x){let e;switch(X(Y,V,-Z.x,!0),c){case C:e=i-3+1;break;case L:e=i-7+5;break;case R:e=i-5+3;break;case G:e=i-6+3}e&&te(p,V,e)}}}else N(V,Y)}}};function ee(e,t,r,o){W(t,e[o],e[o+1]),W(r,e[o+2],e[o+3])}function te(e,t,r){e[r]=t.x,e[r+1]=t.y}e.Plugin.add("arrow"),e.UI.addAttr("startArrow","none",o),e.UI.addAttr("endArrow","none",o),Object.assign(e.PathArrow,$),Object.assign(e.Paint,{strokeArrow(e,t,r){t.__.dashPattern&&(r.beginPath(),t.__drawPathByData(r,t.__.__pathForArrow),r.dashPattern=null,r.stroke())}}),exports.ArrowData=r,exports.PathArrowModule=$,exports.PathMatrixHelper=f,exports.arrowType=o;
2
2
  //# sourceMappingURL=arrow.min.cjs.map