@leafer-in/arrow 2.0.2 → 2.0.4
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.cjs +144 -45
- package/dist/arrow.esm.js +144 -45
- package/dist/arrow.esm.min.js +1 -1
- package/dist/arrow.esm.min.js.map +1 -1
- package/dist/arrow.js +127 -45
- package/dist/arrow.min.cjs +1 -1
- package/dist/arrow.min.cjs.map +1 -1
- package/dist/arrow.min.js +1 -1
- package/dist/arrow.min.js.map +1 -1
- package/package.json +4 -4
- package/src/PathArrowModule.ts +47 -17
- package/src/data/arrows.ts +53 -21
- package/src/index.ts +20 -4
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
|
|
107
|
+
const zero = {
|
|
108
|
+
x: 0
|
|
109
|
+
}, half = {
|
|
108
110
|
x: -.5
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
const angle = {
|
|
112
|
-
connect:
|
|
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
|
|
134
|
-
connect:
|
|
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
|
|
141
|
-
dashPath: [ 1, -2, 0, 2, -.5, 0 ]
|
|
142
|
+
path: [ ...triangleLinePath ]
|
|
142
143
|
};
|
|
143
144
|
|
|
144
|
-
const
|
|
145
|
+
const triangle = DataHelper.clone(triangleFill);
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
path: [ ...
|
|
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.
|
|
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
|
|
199
|
+
const circleFill = {
|
|
176
200
|
connect: {
|
|
177
201
|
x: .5
|
|
178
202
|
},
|
|
179
|
-
path: [ ...circleLine.path
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
262
|
-
|
|
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)
|
|
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)
|
|
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 =
|
|
334
|
-
const pathForArrow = ui.__.__pathForArrow = [];
|
|
405
|
+
const path = uData.__pathForRender = clonePathForArrow ? [ ...data ] : data;
|
|
335
406
|
if (useStartArrow) {
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
346
|
-
|
|
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(
|
|
403
|
-
|
|
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,
|
|
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
|
});
|
package/dist/arrow.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LineData as
|
|
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
|