@leafer-in/arrow 2.0.1 → 2.0.3

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.esm.js CHANGED
@@ -104,12 +104,14 @@ const {layout: layout, rotate: rotate} = PathMatrixHelper;
104
104
 
105
105
  const {getAngle: getAngle} = PointHelper;
106
106
 
107
- const half = {
107
+ const zero = {
108
+ x: 0
109
+ }, half = {
108
110
  x: -.5
109
111
  };
110
112
 
111
113
  const angle = {
112
- connect: half,
114
+ connect: zero,
113
115
  offset: {
114
116
  x: -.71,
115
117
  bevelJoin: .36,
@@ -130,73 +132,110 @@ const angleSide = {
130
132
 
131
133
  const triangleLinePath = [ 1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0 ];
132
134
 
133
- const triangle = {
134
- connect: half,
135
+ const triangleFill = {
136
+ connect: zero,
135
137
  offset: {
136
138
  x: -.9,
137
139
  bevelJoin: .624,
138
140
  roundJoin: .4
139
141
  },
140
- path: [ ...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1 ],
141
- dashPath: [ 1, -2, 0, 2, -.5, 0 ]
142
+ path: [ ...triangleLinePath ]
142
143
  };
143
144
 
144
- const arrowLinePath = [ 1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0 ];
145
+ const triangle = DataHelper.clone(triangleFill);
145
146
 
146
- const arrow = {
147
- connect: half,
148
- offset: {
149
- x: -1.1,
150
- bevelJoin: .872,
151
- roundJoin: .6
152
- },
153
- path: [ ...arrowLinePath, 1, -2.25, .95, 2, -2.25, -.95 ],
154
- dashPath: [ 1, -3, 0, 2, -.5, 0 ]
147
+ triangle.path = [ ...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1 ];
148
+
149
+ triangle.dashPath = [ 1, -2, 0, 2, -.5, 0 ];
150
+
151
+ const triangleFlipFill = {
152
+ connect: zero,
153
+ offset: half,
154
+ path: [ ...triangleFill.path ]
155
155
  };
156
156
 
157
157
  const triangleFlip = {
158
+ connect: zero,
158
159
  offset: half,
159
160
  path: [ ...triangle.path ],
160
161
  dashPath: [ 1, -2.5, 0, 2, -1, 0 ]
161
162
  };
162
163
 
164
+ rotate(triangleFlipFill.path, 180, {
165
+ x: -1.5,
166
+ y: 0
167
+ });
168
+
163
169
  rotate(triangleFlip.path, 180, {
164
170
  x: -1.5,
165
171
  y: 0
166
172
  });
167
173
 
174
+ const arrowLinePath = [ 1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0 ];
175
+
176
+ const arrowFill = {
177
+ connect: zero,
178
+ offset: {
179
+ x: -1.1,
180
+ bevelJoin: .872,
181
+ roundJoin: .6
182
+ },
183
+ path: [ ...arrowLinePath ]
184
+ };
185
+
186
+ const arrow = DataHelper.clone(arrowFill);
187
+
188
+ arrow.path = [ ...arrowLinePath, 1, -2.25, .95, 2, -2.25, -.95 ];
189
+
190
+ arrow.dashPath = [ 1, -3, 0, 2, -.5, 0 ];
191
+
168
192
  const circleLine = {
169
193
  connect: {
170
- x: -1.3
194
+ x: -1.8
171
195
  },
172
196
  path: [ 1, 1.8, -.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0 ]
173
197
  };
174
198
 
175
- const circle = {
199
+ const circleFill = {
176
200
  connect: {
177
201
  x: .5
178
202
  },
179
- path: [ ...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0 ],
180
- dashPath: [ 1, -.5, 0, 2, .5, 0 ]
203
+ path: [ ...circleLine.path ]
181
204
  };
182
205
 
206
+ const circle = DataHelper.clone(circleFill);
207
+
208
+ circle.path = [ ...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0 ];
209
+
210
+ circle.dashPath = [ 1, -.5, 0, 2, .5, 0 ];
211
+
183
212
  const squareLine = {
184
213
  connect: {
185
- x: -1.3
214
+ x: -1.4
186
215
  },
187
216
  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 ]
188
217
  };
189
218
 
219
+ const squareFill = {
220
+ path: [ ...squareLine.path ]
221
+ };
222
+
190
223
  const square = {
191
224
  path: [ ...squareLine.path, 2, -1.4, -.49, 2, 1, -.49, 1, -1.4, .49, 2, 1, .49 ]
192
225
  };
193
226
 
194
227
  const diamondLine = DataHelper.clone(squareLine);
195
228
 
229
+ diamondLine.connect.x = -1.9;
230
+
231
+ const diamondFill = DataHelper.clone(squareFill);
232
+
196
233
  const diamond = DataHelper.clone(square);
197
234
 
198
235
  rotate(diamondLine.path, 45);
199
236
 
237
+ rotate(diamondFill.path, 45);
238
+
200
239
  rotate(diamond.path, 45);
201
240
 
202
241
  const mark = {
@@ -219,19 +258,34 @@ const arrows = {
219
258
  mark: mark
220
259
  };
221
260
 
261
+ const fillArrows = {
262
+ triangle: triangleFill,
263
+ "triangle-flip": triangleFlipFill,
264
+ arrow: arrowFill,
265
+ circle: circleFill,
266
+ square: squareFill,
267
+ diamond: diamondFill
268
+ };
269
+
222
270
  function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern) {
223
- let pathData, scale;
271
+ let pathData, scale = 1, rotation = 0, fill;
224
272
  const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
225
273
  if (isObject(arrow)) {
226
274
  if (arrow.type) {
227
- scale = arrow.scale;
275
+ scale = arrow.scale || 1;
276
+ rotation = arrow.rotation || 0;
228
277
  pathData = arrows[arrow.type];
278
+ if (scale > 1) {
279
+ const fillData = fillArrows[arrow.type];
280
+ if (fillData) pathData = fillData, fill = true;
281
+ }
229
282
  } else pathData = arrow;
230
283
  } else {
231
284
  pathData = arrows[arrow];
232
285
  }
286
+ if (!fill) fill = pathData.fill;
233
287
  const {offset: offset, connect: connect, path: path, dashPath: dashPath} = pathData;
234
- let connectX = connect ? connect.x : 0;
288
+ let connectX = connect ? connect.x * scale : 0;
235
289
  let offsetX = offset ? offset.x : 0;
236
290
  const data = [ ...path ];
237
291
  if (hasDashPattern && dashPath) data.push(...dashPath);
@@ -239,28 +293,38 @@ function getArrowPath(ui, arrow, from, to, size, connectOffset, hasDashPattern)
239
293
  if (offset) {
240
294
  if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
241
295
  }
242
- if (scale) layout(data, 0, 0, scale, scale);
296
+ if (scale !== 1) layout(data, 0, 0, scale, scale);
243
297
  if (offsetX) layout(data, offsetX, 0);
244
- layout(data, to.x, to.y, size, size, getAngle(from, to));
298
+ layout(data, to.x, to.y, size, size, getAngle(from, to) + rotation);
245
299
  connectOffset.x = (connectX + offsetX) * size;
246
- return data;
300
+ const arrowData = {
301
+ data: data
302
+ };
303
+ if (fill) arrowData.fill = fill;
304
+ return arrowData;
247
305
  }
248
306
 
249
307
  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} = PathCommandMap;
250
308
 
251
- const {copy: copy, copyFrom: copyFrom, getDistancePoint: getDistancePoint} = PointHelper;
309
+ const {copy: copy, copyFrom: copyFrom, getDistancePoint: getDistancePoint, isSame: isSame} = PointHelper;
310
+
311
+ const {stintSet: stintSet} = DataHelper;
252
312
 
253
313
  const connectPoint = {};
254
314
 
255
315
  const first = {}, second = {};
256
316
 
257
- const last = {}, now = {};
317
+ const old = {}, last = {}, now = {};
258
318
 
259
319
  const PathArrowModule = {
260
320
  list: arrows,
261
- addArrows(ui) {
262
- const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = ui.__;
321
+ fillList: fillArrows,
322
+ addArrows(ui, updateCache) {
323
+ const uData = ui.__;
324
+ const {startArrow: startArrow, endArrow: endArrow, __strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data, cornerRadius: cornerRadius} = uData;
263
325
  const clonePathForArrow = !cornerRadius;
326
+ if (!updateCache) uData.__strokeWidthCache = strokeWidth;
327
+ let startArrowPath, singleStartArrow, endArrowPath, singleEndArrow;
264
328
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
265
329
  while (i < len) {
266
330
  command = data[i];
@@ -268,6 +332,7 @@ const PathArrowModule = {
268
332
  case M:
269
333
  case L:
270
334
  if (count < 2 || i + 6 >= len) {
335
+ copy(old, now);
271
336
  copyFrom(now, data[i + 1], data[i + 2]);
272
337
  if (!count && useStartArrow) copy(first, now);
273
338
  }
@@ -275,12 +340,18 @@ const PathArrowModule = {
275
340
  break;
276
341
 
277
342
  case C:
278
- if (count === 1 || i + 7 >= len - 3) copyPoints(data, last, now, i + 3);
343
+ if (count === 1 || i + 7 >= len - 3) {
344
+ copyPoints(data, last, now, i + 3);
345
+ old.x = data[i + 1], old.y = data[i + 2];
346
+ }
279
347
  i += 7;
280
348
  break;
281
349
 
282
350
  case Q:
283
- if (count === 1 || i + 5 >= len - 3) copyPoints(data, last, now, i + 1);
351
+ if (count === 1 || i + 5 >= len - 3) {
352
+ copyPoints(data, last, now, i + 1);
353
+ copy(old, last);
354
+ }
284
355
  i += 5;
285
356
  break;
286
357
 
@@ -318,6 +389,7 @@ const PathArrowModule = {
318
389
  case U:
319
390
  if (count === 1 || i + 6 >= len - 3) {
320
391
  copyPoints(data, last, now, i + 1);
392
+ copy(old, last);
321
393
  if (i + 6 !== len) {
322
394
  now.x -= (now.x - last.x) / 10;
323
395
  now.y -= (now.y - last.y) / 10;
@@ -328,13 +400,13 @@ const PathArrowModule = {
328
400
  }
329
401
  count++;
330
402
  if (count === 1 && command !== M) return;
331
- if (count === 2 && useStartArrow) copy(second, command === L ? now : last);
403
+ if (count === 2 && useStartArrow) copy(second, command === L ? now : isSame(old, first) ? last : old);
332
404
  if (i === len) {
333
- const path = ui.__.__pathForRender = clonePathForArrow ? [ ...data ] : data;
334
- const pathForArrow = ui.__.__pathForArrow = [];
405
+ const path = uData.__pathForRender = clonePathForArrow ? [ ...data ] : data;
335
406
  if (useStartArrow) {
336
- const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
337
- dashPattern ? pathForArrow.push(...startArrowPath) : path.push(...startArrowPath);
407
+ startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
408
+ singleStartArrow = startArrowPath.fill || dashPattern;
409
+ if (!singleStartArrow) path.push(...startArrowPath.data);
338
410
  if (connectPoint.x) {
339
411
  getDistancePoint(first, second, -connectPoint.x, true);
340
412
  path[1] = second.x;
@@ -342,8 +414,10 @@ const PathArrowModule = {
342
414
  }
343
415
  }
344
416
  if (endArrow && endArrow !== "none") {
345
- const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
346
- dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
417
+ if (isSame(last, now)) copy(last, old);
418
+ endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
419
+ singleEndArrow = endArrowPath.fill || dashPattern;
420
+ if (!singleEndArrow) path.push(...endArrowPath.data);
347
421
  if (connectPoint.x) {
348
422
  getDistancePoint(now, last, -connectPoint.x, true);
349
423
  let index;
@@ -370,10 +444,21 @@ const PathArrowModule = {
370
444
  } else {
371
445
  copy(last, now);
372
446
  }
447
+ stintSet(uData, "__startArrowPath", singleStartArrow && startArrowPath);
448
+ stintSet(uData, "__endArrowPath", singleEndArrow && endArrowPath);
449
+ }
450
+ },
451
+ updateArrow(ui) {
452
+ const data = ui.__;
453
+ if (data.strokeScaleFixed) {
454
+ if (data.__strokeWidthCache !== data.__strokeWidth) {
455
+ ui.__updateRenderPath(true);
456
+ }
373
457
  }
374
458
  },
375
- register(name, data) {
459
+ register(name, data, fillData) {
376
460
  this.list[name] = data;
461
+ if (fillData) this.fillList[name] = data;
377
462
  },
378
463
  get(name) {
379
464
  return this.list[name];
@@ -399,12 +484,26 @@ UI.addAttr("endArrow", "none", arrowType);
399
484
  Object.assign(PathArrow, PathArrowModule);
400
485
 
401
486
  Object.assign(Paint, {
402
- strokeArrow(_stroke, ui, canvas, _renderOptions) {
403
- if (ui.__.dashPattern) {
487
+ strokeArrow(stroke, ui, canvas, _renderOptions) {
488
+ const {__startArrowPath: __startArrowPath, __endArrowPath: __endArrowPath, dashPattern: dashPattern} = ui.__;
489
+ if (dashPattern) canvas.dashPattern = null;
490
+ if (__startArrowPath) {
491
+ canvas.beginPath();
492
+ ui.__drawPathByData(canvas, __startArrowPath.data);
493
+ canvas.stroke();
494
+ if (__startArrowPath.fill) {
495
+ canvas.fillStyle = stroke;
496
+ canvas.fill();
497
+ }
498
+ }
499
+ if (__endArrowPath) {
404
500
  canvas.beginPath();
405
- ui.__drawPathByData(canvas, ui.__.__pathForArrow);
406
- canvas.dashPattern = null;
501
+ ui.__drawPathByData(canvas, __endArrowPath.data);
407
502
  canvas.stroke();
503
+ if (__endArrowPath.fill) {
504
+ canvas.fillStyle = stroke;
505
+ canvas.fill();
506
+ }
408
507
  }
409
508
  }
410
509
  });
@@ -1,2 +1,2 @@
1
- import{LineData as e,decorateLeafAttr as t,attr as r,doBoundsType as o,doStrokeType as n,dataProcessor as a,registerUI as s,Line as c,PathArrow as i,PathCommandMap as h,PointHelper as l,DataHelper as p,isObject as d,Plugin as f,UI as u,Paint as _}from"@leafer-ui/draw";function b(e,t,r,o){var n,a=arguments.length,s=a<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--)(n=e[c])&&(s=(a<3?n(s):a>3?n(t,r,s):n(t,r))||s);return a>3&&s&&Object.defineProperty(t,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class x extends e{}function w(e){return t(e,e=>r({set(t){if(this.__setAttr(e,t)){const e=this.__,t="none"!==e.startArrow||"none"!==e.endArrow;e.__useArrow!==t&&o(this),e.__useArrow=t,n(this)}}}))}let y=class extends c{get __tag(){return"Arrow"}constructor(e){super(e),this.__.__useArrow=!0}static registerArrow(e,t){i.register(e,t)}};b([a(x)],y.prototype,"__",void 0),b([w("angle")],y.prototype,"endArrow",void 0),y=b([s()],y);const{M:g,L:k,C:A,Q:P,O:J}=h,{rotate:v,copyFrom:m,scale:F}=l,O={},R={layout(e,t,r,o,n,a,s){let c,i,h=0,l=e.length;for(;h<l;)switch(c=e[h],c){case g:case k:j(e,h+1,t,r,o,n,a,s),h+=3;break;case A:for(i=1;i<6;i+=2)j(e,h+i,t,r,o,n,a,s);h+=7;break;case P:for(i=1;i<4;i+=2)j(e,h+i,t,r,o,n,a,s);h+=5;break;case J:e[h+1]+=t,e[h+2]+=r,o&&(e[h+3]*=o),a&&(e[h+4]+=a,e[h+5]+=a),h+=7}},rotate(e,t,r){R.layout(e,0,0,1,1,t,r)}};function j(e,t,r,o,n,a,s,c){m(O,e[t],e[t+1]),s&&v(O,s,c),n&&F(O,n,a),e[t]=r+O.x,e[t+1]=o+O.y}const{layout:D,rotate:C}=R,{getAngle:q}=l,E={x:-.5},L={connect:E,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},M={connect:E,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},Q={connect:E,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]},S={connect:E,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]},B={offset:E,path:[...Q.path],dashPath:[1,-2.5,0,2,-1,0]};C(B.path,180,{x:-1.5,y:0});const G={connect:{x:-1.3},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},N={connect:{x:.5},path:[...G.path,1,0,0,26,0,0,1,0,360,0],dashPath:[1,-.5,0,2,.5,0]},U={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]},W={path:[...U.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},X=p.clone(U),Z=p.clone(W);C(X.path,45),C(Z.path,45);const z={angle:L,"angle-side":M,arrow:S,triangle:Q,"triangle-flip":B,circle:N,"circle-line":G,square:W,"square-line":U,diamond:Z,"diamond-line":X,mark:{offset:E,path:[1,0,-2,2,0,2]}};function H(e,t,r,o,n,a,s){let c,i;const{strokeCap:h,strokeJoin:l}=e.__;d(t)?t.type?(i=t.scale,c=z[t.type]):c=t:c=z[t];const{offset:p,connect:f,path:u,dashPath:_}=c;let b=f?f.x:0,x=p?p.x:0;const w=[...u];return s&&_&&w.push(..._),"none"!==h&&(b-=.5),p&&("round"===l&&p.roundJoin?x+=p.roundJoin:"bevel"===l&&p.bevelJoin&&(x+=p.bevelJoin)),i&&D(w,0,0,i,i),x&&D(w,x,0),D(w,o.x,o.y,n,n,q(r,o)),a.x=(b+x)*n,w}const{M:I,L:K,C:T,Q:V,Z:Y,N:$,D:ee,X:te,G:re,F:oe,O:ne,P:ae,U:se}=h,{copy:ce,copyFrom:ie,getDistancePoint:he}=l,le={},pe={},de={},fe={},ue={},_e={list:z,addArrows(e){const{startArrow:t,endArrow:r,strokeWidth:o,dashPattern:n,__pathForRender:a,cornerRadius:s}=e.__,c=!s;let i,h=0,l=a.length,p=0,d=t&&"none"!==t;for(;h<l;){switch(i=a[h],i){case I:case K:(p<2||h+6>=l)&&(ie(ue,a[h+1],a[h+2]),!p&&d&&ce(pe,ue)),h+=3;break;case T:(1===p||h+7>=l-3)&&be(a,fe,ue,h+3),h+=7;break;case V:(1===p||h+5>=l-3)&&be(a,fe,ue,h+1),h+=5;break;case Y:return;case $:h+=5;break;case ee:h+=9;break;case te:h+=6;break;case re:h+=9;break;case oe:h+=5;break;case ne:h+=7;break;case ae:h+=4;break;case se:(1===p||h+6>=l-3)&&(be(a,fe,ue,h+1),h+6!==l&&(ue.x-=(ue.x-fe.x)/10,ue.y-=(ue.y-fe.y)/10)),h+=6}if(p++,1===p&&i!==I)return;if(2===p&&d&&ce(de,i===K?ue:fe),h===l){const s=e.__.__pathForRender=c?[...a]:a,l=e.__.__pathForArrow=[];if(d){const r=H(e,t,de,pe,o,le,!!n);n?l.push(...r):s.push(...r),le.x&&(he(pe,de,-le.x,!0),s[1]=de.x,s[2]=de.y)}if(r&&"none"!==r){const t=H(e,r,fe,ue,o,le,!!n);if(n?l.push(...t):s.push(...t),le.x){let e;switch(he(ue,fe,-le.x,!0),i){case K:e=h-3+1;break;case T:e=h-7+5;break;case V:e=h-5+3;break;case se:e=h-6+3}e&&xe(s,fe,e)}}}else ce(fe,ue)}},register(e,t){this.list[e]=t},get(e){return this.list[e]}};function be(e,t,r,o){ie(t,e[o],e[o+1]),ie(r,e[o+2],e[o+3])}function xe(e,t,r){e[r]=t.x,e[r+1]=t.y}f.add("arrow"),u.addAttr("startArrow","none",w),u.addAttr("endArrow","none",w),Object.assign(i,_e),Object.assign(_,{strokeArrow(e,t,r,o){t.__.dashPattern&&(r.beginPath(),t.__drawPathByData(r,t.__.__pathForArrow),r.dashPattern=null,r.stroke())}});export{y as Arrow,x as ArrowData,_e as PathArrowModule,R as PathMatrixHelper,w as arrowType};
1
+ import{LineData as t,decorateLeafAttr as e,attr as r,doBoundsType as a,doStrokeType as o,dataProcessor as n,registerUI as s,Line as c,PathArrow as i,PathCommandMap as l,PointHelper as h,DataHelper as d,isObject as f,Plugin as p,UI as _,Paint as u}from"@leafer-ui/draw";function x(t,e,r,a){var o,n=arguments.length,s=n<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,a);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(n<3?o(s):n>3?o(e,r,s):o(e,r))||s);return n>3&&s&&Object.defineProperty(e,r,s),s}"function"==typeof SuppressedError&&SuppressedError;class b extends t{}function y(t){return e(t,t=>r({set(e){if(this.__setAttr(t,e)){const t=this.__,e="none"!==t.startArrow||"none"!==t.endArrow;t.__useArrow!==e&&a(this),t.__useArrow=e,o(this)}}}))}let w=class extends c{get __tag(){return"Arrow"}constructor(t){super(t),this.__.__useArrow=!0}static registerArrow(t,e){i.register(t,e)}};x([n(b)],w.prototype,"__",void 0),x([y("angle")],w.prototype,"endArrow",void 0),w=x([s()],w);const{M:k,L:g,C:A,Q:P,O:J}=l,{rotate:v,copyFrom:m,scale:O}=h,R={},S={layout(t,e,r,a,o,n,s){let c,i,l=0,h=t.length;for(;l<h;)switch(c=t[l],c){case k:case g:F(t,l+1,e,r,a,o,n,s),l+=3;break;case A:for(i=1;i<6;i+=2)F(t,l+i,e,r,a,o,n,s);l+=7;break;case P:for(i=1;i<4;i+=2)F(t,l+i,e,r,a,o,n,s);l+=5;break;case J:t[l+1]+=e,t[l+2]+=r,a&&(t[l+3]*=a),n&&(t[l+4]+=n,t[l+5]+=n),l+=7}},rotate(t,e,r){S.layout(t,0,0,1,1,e,r)}};function F(t,e,r,a,o,n,s,c){m(R,t[e],t[e+1]),s&&v(R,s,c),o&&O(R,o,n),t[e]=r+R.x,t[e+1]=a+R.y}const{layout:j,rotate:C}=S,{getAngle:D}=h,L={x:0},W={x:-.5},q={connect:L,offset:{x:-.71,bevelJoin:.36,roundJoin:.22},path:[1,-3,-3,2,0,0,2,-3,3]},B={connect:W,offset:{x:-1.207,bevelJoin:.854,roundJoin:.707},path:[1,-3,-3,2,0,0,2,-1,0]},E=[1,-3,0,2,-3,-2,2,0,0,2,-3,2,2,-3,0],M={connect:L,offset:{x:-.9,bevelJoin:.624,roundJoin:.4},path:[...E]},Q=d.clone(M);Q.path=[...E,1,-2.05,1.1,2,-2.05,-1.1],Q.dashPath=[1,-2,0,2,-.5,0];const G={connect:L,offset:W,path:[...M.path]},N={connect:L,offset:W,path:[...Q.path],dashPath:[1,-2.5,0,2,-1,0]};C(G.path,180,{x:-1.5,y:0}),C(N.path,180,{x:-1.5,y:0});const U=[1,-3,0,2,-3.5,-1.8,2,0,0,2,-3.5,1.8,2,-3,0],X={connect:L,offset:{x:-1.1,bevelJoin:.872,roundJoin:.6},path:[...U]},Z=d.clone(X);Z.path=[...U,1,-2.25,.95,2,-2.25,-.95],Z.dashPath=[1,-3,0,2,-.5,0];const z={connect:{x:-1.8},path:[1,1.8,-.1,2,1.8,0,26,0,0,1.8,0,359,0]},H={connect:{x:.5},path:[...z.path]},I=d.clone(H);I.path=[...z.path,1,0,0,26,0,0,1,0,360,0],I.dashPath=[1,-.5,0,2,.5,0];const K={connect:{x:-1.4},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]},T={path:[...K.path]},V={path:[...K.path,2,-1.4,-.49,2,1,-.49,1,-1.4,.49,2,1,.49]},Y=d.clone(K);Y.connect.x=-1.9;const $=d.clone(T),tt=d.clone(V);C(Y.path,45),C($.path,45),C(tt.path,45);const et={angle:q,"angle-side":B,arrow:Z,triangle:Q,"triangle-flip":N,circle:I,"circle-line":z,square:V,"square-line":K,diamond:tt,"diamond-line":Y,mark:{offset:W,path:[1,0,-2,2,0,2]}},rt={triangle:M,"triangle-flip":G,arrow:X,circle:H,square:T,diamond:$};function at(t,e,r,a,o,n,s){let c,i,l=1,h=0;const{strokeCap:d,strokeJoin:p}=t.__;if(f(e))if(e.type){if(l=e.scale||1,h=e.rotation||0,c=et[e.type],l>1){const t=rt[e.type];t&&(c=t,i=!0)}}else c=e;else c=et[e];i||(i=c.fill);const{offset:_,connect:u,path:x,dashPath:b}=c;let y=u?u.x*l:0,w=_?_.x:0;const k=[...x];s&&b&&k.push(...b),"none"!==d&&(y-=.5),_&&("round"===p&&_.roundJoin?w+=_.roundJoin:"bevel"===p&&_.bevelJoin&&(w+=_.bevelJoin)),1!==l&&j(k,0,0,l,l),w&&j(k,w,0),j(k,a.x,a.y,o,o,D(r,a)+h),n.x=(y+w)*o;const g={data:k};return i&&(g.fill=i),g}const{M:ot,L:nt,C:st,Q:ct,Z:it,N:lt,D:ht,X:dt,G:ft,F:pt,O:_t,P:ut,U:xt}=l,{copy:bt,copyFrom:yt,getDistancePoint:wt,isSame:kt}=h,{stintSet:gt}=d,At={},Pt={},Jt={},vt={},mt={},Ot={},Rt={list:et,fillList:rt,addArrows(t,e){const r=t.__,{startArrow:a,endArrow:o,__strokeWidth:n,dashPattern:s,__pathForRender:c,cornerRadius:i}=r,l=!i;let h,d,f,p;e||(r.__strokeWidthCache=n);let _,u=0,x=c.length,b=0,y=a&&"none"!==a;for(;u<x;){switch(_=c[u],_){case ot:case nt:(b<2||u+6>=x)&&(bt(vt,Ot),yt(Ot,c[u+1],c[u+2]),!b&&y&&bt(Pt,Ot)),u+=3;break;case st:(1===b||u+7>=x-3)&&(St(c,mt,Ot,u+3),vt.x=c[u+1],vt.y=c[u+2]),u+=7;break;case ct:(1===b||u+5>=x-3)&&(St(c,mt,Ot,u+1),bt(vt,mt)),u+=5;break;case it:return;case lt:u+=5;break;case ht:u+=9;break;case dt:u+=6;break;case ft:u+=9;break;case pt:u+=5;break;case _t:u+=7;break;case ut:u+=4;break;case xt:(1===b||u+6>=x-3)&&(St(c,mt,Ot,u+1),bt(vt,mt),u+6!==x&&(Ot.x-=(Ot.x-mt.x)/10,Ot.y-=(Ot.y-mt.y)/10)),u+=6}if(b++,1===b&&_!==ot)return;if(2===b&&y&&bt(Jt,_===nt?Ot:kt(vt,Pt)?mt:vt),u===x){const e=r.__pathForRender=l?[...c]:c;if(y&&(h=at(t,a,Jt,Pt,n,At,!!s),d=h.fill||s,d||e.push(...h.data),At.x&&(wt(Pt,Jt,-At.x,!0),e[1]=Jt.x,e[2]=Jt.y)),o&&"none"!==o&&(kt(mt,Ot)&&bt(mt,vt),f=at(t,o,mt,Ot,n,At,!!s),p=f.fill||s,p||e.push(...f.data),At.x)){let t;switch(wt(Ot,mt,-At.x,!0),_){case nt:t=u-3+1;break;case st:t=u-7+5;break;case ct:t=u-5+3;break;case xt:t=u-6+3}t&&Ft(e,mt,t)}}else bt(mt,Ot);gt(r,"__startArrowPath",d&&h),gt(r,"__endArrowPath",p&&f)}},updateArrow(t){const e=t.__;e.strokeScaleFixed&&e.__strokeWidthCache!==e.__strokeWidth&&t.__updateRenderPath(!0)},register(t,e,r){this.list[t]=e,r&&(this.fillList[t]=e)},get(t){return this.list[t]}};function St(t,e,r,a){yt(e,t[a],t[a+1]),yt(r,t[a+2],t[a+3])}function Ft(t,e,r){t[r]=e.x,t[r+1]=e.y}p.add("arrow"),_.addAttr("startArrow","none",y),_.addAttr("endArrow","none",y),Object.assign(i,Rt),Object.assign(u,{strokeArrow(t,e,r,a){const{__startArrowPath:o,__endArrowPath:n,dashPattern:s}=e.__;s&&(r.dashPattern=null),o&&(r.beginPath(),e.__drawPathByData(r,o.data),r.stroke(),o.fill&&(r.fillStyle=t,r.fill())),n&&(r.beginPath(),e.__drawPathByData(r,n.data),r.stroke(),n.fill&&(r.fillStyle=t,r.fill()))}});export{w as Arrow,b as ArrowData,Rt as PathArrowModule,S as PathMatrixHelper,y as arrowType};
2
2
  //# sourceMappingURL=arrow.esm.min.js.map