@leafer-in/arrow 1.8.0 → 1.9.1
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 +276 -195
- package/dist/arrow.esm.js +271 -193
- package/dist/arrow.esm.min.js +1 -1
- package/dist/arrow.esm.min.js.map +1 -1
- package/dist/arrow.js +231 -203
- 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/data/arrows.ts +2 -2
package/dist/arrow.cjs
CHANGED
|
@@ -1,45 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var draw = require(
|
|
4
|
-
|
|
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
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var draw = require("@leafer-ui/draw");
|
|
33
4
|
|
|
34
|
-
|
|
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
|
|
|
11
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
12
|
+
var e = new Error(message);
|
|
13
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class ArrowData extends draw.LineData {}
|
|
17
|
+
|
|
37
18
|
function arrowType(defaultValue) {
|
|
38
|
-
return draw.decorateLeafAttr(defaultValue,
|
|
19
|
+
return draw.decorateLeafAttr(defaultValue, key => draw.attr({
|
|
39
20
|
set(value) {
|
|
40
21
|
if (this.__setAttr(key, value)) {
|
|
41
22
|
const data = this.__;
|
|
42
|
-
data.__useArrow = data.startArrow !==
|
|
23
|
+
data.__useArrow = data.startArrow !== "none" || data.endArrow !== "none";
|
|
43
24
|
draw.doStrokeType(this);
|
|
44
25
|
}
|
|
45
26
|
}
|
|
@@ -47,57 +28,59 @@ function arrowType(defaultValue) {
|
|
|
47
28
|
}
|
|
48
29
|
|
|
49
30
|
exports.Arrow = class Arrow extends draw.Line {
|
|
50
|
-
get __tag() {
|
|
31
|
+
get __tag() {
|
|
32
|
+
return "Arrow";
|
|
33
|
+
}
|
|
51
34
|
constructor(data) {
|
|
52
35
|
super(data);
|
|
53
36
|
this.__.__useArrow = true;
|
|
54
37
|
}
|
|
55
38
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
__decorate([
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const { rotate: rotate$1, copyFrom: copyFrom$1, scale } = draw.PointHelper;
|
|
39
|
+
|
|
40
|
+
__decorate([ draw.dataProcessor(ArrowData) ], exports.Arrow.prototype, "__", void 0);
|
|
41
|
+
|
|
42
|
+
__decorate([ arrowType("angle") ], exports.Arrow.prototype, "endArrow", void 0);
|
|
43
|
+
|
|
44
|
+
exports.Arrow = __decorate([ draw.registerUI() ], exports.Arrow);
|
|
45
|
+
|
|
46
|
+
const {M: M$1, L: L$1, C: C$1, Q: Q$1, O: O$1} = draw.PathCommandMap;
|
|
47
|
+
|
|
48
|
+
const {rotate: rotate$1, copyFrom: copyFrom$1, scale: scale} = draw.PointHelper;
|
|
49
|
+
|
|
68
50
|
const point = {};
|
|
51
|
+
|
|
69
52
|
const PathMatrixHelper = {
|
|
70
53
|
layout(data, x, y, scaleX, scaleY, rotation, origin) {
|
|
71
54
|
let command, i = 0, j, len = data.length;
|
|
72
55
|
while (i < len) {
|
|
73
56
|
command = data[i];
|
|
74
57
|
switch (command) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
58
|
+
case M$1:
|
|
59
|
+
case L$1:
|
|
60
|
+
setPoint$1(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
|
|
61
|
+
i += 3;
|
|
62
|
+
break;
|
|
63
|
+
|
|
64
|
+
case C$1:
|
|
65
|
+
for (j = 1; j < 6; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
|
|
66
|
+
i += 7;
|
|
67
|
+
break;
|
|
68
|
+
|
|
69
|
+
case Q$1:
|
|
70
|
+
for (j = 1; j < 4; j += 2) setPoint$1(data, i + j, x, y, scaleX, scaleY, rotation, origin);
|
|
71
|
+
i += 5;
|
|
72
|
+
break;
|
|
73
|
+
|
|
74
|
+
case O$1:
|
|
75
|
+
data[i + 1] += x;
|
|
76
|
+
data[i + 2] += y;
|
|
77
|
+
if (scaleX) data[i + 3] *= scaleX;
|
|
78
|
+
if (rotation) {
|
|
79
|
+
data[i + 4] += rotation;
|
|
80
|
+
data[i + 5] += rotation;
|
|
81
|
+
}
|
|
82
|
+
i += 7;
|
|
83
|
+
break;
|
|
101
84
|
}
|
|
102
85
|
}
|
|
103
86
|
},
|
|
@@ -105,141 +88,229 @@ const PathMatrixHelper = {
|
|
|
105
88
|
PathMatrixHelper.layout(data, 0, 0, 1, 1, rotation, center);
|
|
106
89
|
}
|
|
107
90
|
};
|
|
91
|
+
|
|
108
92
|
function setPoint$1(data, startIndex, x, y, scaleX, scaleY, rotation, origin) {
|
|
109
93
|
copyFrom$1(point, data[startIndex], data[startIndex + 1]);
|
|
110
|
-
if (rotation)
|
|
111
|
-
|
|
112
|
-
if (scaleX)
|
|
113
|
-
scale(point, scaleX, scaleY);
|
|
94
|
+
if (rotation) rotate$1(point, rotation, origin);
|
|
95
|
+
if (scaleX) scale(point, scaleX, scaleY);
|
|
114
96
|
data[startIndex] = x + point.x;
|
|
115
97
|
data[startIndex + 1] = y + point.y;
|
|
116
98
|
}
|
|
117
99
|
|
|
118
|
-
const { layout, rotate } = PathMatrixHelper;
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
100
|
+
const {layout: layout, rotate: rotate} = PathMatrixHelper;
|
|
101
|
+
|
|
102
|
+
const {getAngle: getAngle} = draw.PointHelper;
|
|
103
|
+
|
|
104
|
+
const half = {
|
|
105
|
+
x: -.5
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const angle = {
|
|
109
|
+
connect: half,
|
|
110
|
+
offset: {
|
|
111
|
+
x: -.71,
|
|
112
|
+
bevelJoin: .36,
|
|
113
|
+
roundJoin: .22
|
|
114
|
+
},
|
|
115
|
+
path: [ 1, -3, -3, 2, 0, 0, 2, -3, 3 ]
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const angleSide = {
|
|
119
|
+
connect: half,
|
|
120
|
+
offset: {
|
|
121
|
+
x: -1.207,
|
|
122
|
+
bevelJoin: .854,
|
|
123
|
+
roundJoin: .707
|
|
124
|
+
},
|
|
125
|
+
path: [ 1, -3, -3, 2, 0, 0, 2, -1, 0 ]
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const triangleLinePath = [ 1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0 ];
|
|
129
|
+
|
|
130
|
+
const triangle = {
|
|
131
|
+
connect: half,
|
|
132
|
+
offset: {
|
|
133
|
+
x: -.9,
|
|
134
|
+
bevelJoin: .624,
|
|
135
|
+
roundJoin: .4
|
|
136
|
+
},
|
|
137
|
+
path: [ ...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1 ],
|
|
138
|
+
dashPath: [ 1, -2, 0, 2, -.5, 0 ]
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const arrowLinePath = [ 1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0 ];
|
|
142
|
+
|
|
143
|
+
const arrow = {
|
|
144
|
+
connect: half,
|
|
145
|
+
offset: {
|
|
146
|
+
x: -1.1,
|
|
147
|
+
bevelJoin: .872,
|
|
148
|
+
roundJoin: .6
|
|
149
|
+
},
|
|
150
|
+
path: [ ...arrowLinePath, 1, -2.25, .95, 2, -2.25, -.95 ],
|
|
151
|
+
dashPath: [ 1, -3, 0, 2, -.5, 0 ]
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const triangleFlip = {
|
|
155
|
+
offset: half,
|
|
156
|
+
path: [ ...triangle.path ],
|
|
157
|
+
dashPath: [ 1, -2.5, 0, 2, -1, 0 ]
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
rotate(triangleFlip.path, 180, {
|
|
161
|
+
x: -1.5,
|
|
162
|
+
y: 0
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const circleLine = {
|
|
166
|
+
connect: {
|
|
167
|
+
x: -1.3
|
|
168
|
+
},
|
|
169
|
+
path: [ 1, 1.8, -.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0 ]
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const circle = {
|
|
173
|
+
connect: {
|
|
174
|
+
x: .5
|
|
175
|
+
},
|
|
176
|
+
path: [ ...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0 ],
|
|
177
|
+
dashPath: [ 1, -.5, 0, 2, .5, 0 ]
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const squareLine = {
|
|
181
|
+
connect: {
|
|
182
|
+
x: -1.3
|
|
183
|
+
},
|
|
184
|
+
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 ]
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const square = {
|
|
188
|
+
path: [ ...squareLine.path, 2, -1.4, -.49, 2, 1, -.49, 1, -1.4, .49, 2, 1, .49 ]
|
|
189
|
+
};
|
|
190
|
+
|
|
133
191
|
const diamondLine = draw.DataHelper.clone(squareLine);
|
|
192
|
+
|
|
134
193
|
const diamond = draw.DataHelper.clone(square);
|
|
194
|
+
|
|
135
195
|
rotate(diamondLine.path, 45);
|
|
196
|
+
|
|
136
197
|
rotate(diamond.path, 45);
|
|
137
|
-
|
|
198
|
+
|
|
199
|
+
const mark = {
|
|
200
|
+
offset: half,
|
|
201
|
+
path: [ 1, 0, -2, 2, 0, 2 ]
|
|
202
|
+
};
|
|
203
|
+
|
|
138
204
|
const arrows = {
|
|
139
|
-
angle,
|
|
140
|
-
|
|
141
|
-
arrow,
|
|
142
|
-
triangle,
|
|
143
|
-
|
|
144
|
-
circle,
|
|
145
|
-
|
|
146
|
-
square,
|
|
147
|
-
|
|
148
|
-
diamond,
|
|
149
|
-
|
|
150
|
-
mark
|
|
205
|
+
angle: angle,
|
|
206
|
+
"angle-side": angleSide,
|
|
207
|
+
arrow: arrow,
|
|
208
|
+
triangle: triangle,
|
|
209
|
+
"triangle-flip": triangleFlip,
|
|
210
|
+
circle: circle,
|
|
211
|
+
"circle-line": circleLine,
|
|
212
|
+
square: square,
|
|
213
|
+
"square-line": squareLine,
|
|
214
|
+
diamond: diamond,
|
|
215
|
+
"diamond-line": diamondLine,
|
|
216
|
+
mark: mark
|
|
151
217
|
};
|
|
218
|
+
|
|
152
219
|
function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
|
|
153
|
-
const { strokeCap, strokeJoin } = ui.__;
|
|
154
|
-
const { offset, connect, path, dashPath } = (
|
|
220
|
+
const {strokeCap: strokeCap, strokeJoin: strokeJoin} = ui.__;
|
|
221
|
+
const {offset: offset, connect: connect, path: path, dashPath: dashPath} = draw.isObject(arrow) ? arrow : arrows[arrow];
|
|
155
222
|
let connectX = connect ? connect.x : 0;
|
|
156
223
|
let offsetX = offset ? offset.x : 0;
|
|
157
|
-
const data = [...path];
|
|
158
|
-
if (hasDashPattern && dashPath)
|
|
159
|
-
|
|
160
|
-
if (strokeCap !== 'none')
|
|
161
|
-
connectX -= 0.5;
|
|
224
|
+
const data = [ ...path ];
|
|
225
|
+
if (hasDashPattern && dashPath) data.push(...dashPath);
|
|
226
|
+
if (strokeCap !== "none") connectX -= .5;
|
|
162
227
|
if (offset) {
|
|
163
|
-
if (strokeJoin ===
|
|
164
|
-
offsetX += offset.roundJoin;
|
|
165
|
-
else if (strokeJoin === 'bevel' && offset.bevelJoin)
|
|
166
|
-
offsetX += offset.bevelJoin;
|
|
228
|
+
if (strokeJoin === "round" && offset.roundJoin) offsetX += offset.roundJoin; else if (strokeJoin === "bevel" && offset.bevelJoin) offsetX += offset.bevelJoin;
|
|
167
229
|
}
|
|
168
|
-
if (offsetX)
|
|
169
|
-
layout(data, offsetX, 0);
|
|
230
|
+
if (offsetX) layout(data, offsetX, 0);
|
|
170
231
|
layout(data, to.x, to.y, scale, scale, getAngle(from, to));
|
|
171
232
|
connectOffset.x = (connectX + offsetX) * scale;
|
|
172
233
|
return data;
|
|
173
234
|
}
|
|
174
235
|
|
|
175
|
-
const { M, L, C, Q, Z, N, D, X, G, F, O, P, U } = draw.PathCommandMap;
|
|
176
|
-
|
|
236
|
+
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;
|
|
237
|
+
|
|
238
|
+
const {copy: copy, copyFrom: copyFrom, getDistancePoint: getDistancePoint} = draw.PointHelper;
|
|
239
|
+
|
|
177
240
|
const connectPoint = {};
|
|
241
|
+
|
|
178
242
|
const first = {}, second = {};
|
|
243
|
+
|
|
179
244
|
const last = {}, now = {};
|
|
245
|
+
|
|
180
246
|
const PathArrowModule = {
|
|
181
247
|
list: arrows,
|
|
182
248
|
addArrows(ui, changeRenderPath) {
|
|
183
|
-
const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data
|
|
184
|
-
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !==
|
|
249
|
+
const {startArrow: startArrow, endArrow: endArrow, strokeWidth: strokeWidth, dashPattern: dashPattern, __pathForRender: data} = ui.__;
|
|
250
|
+
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== "none";
|
|
185
251
|
while (i < len) {
|
|
186
252
|
command = data[i];
|
|
187
253
|
switch (command) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
254
|
+
case M:
|
|
255
|
+
case L:
|
|
256
|
+
if (count < 2 || i + 6 >= len) {
|
|
257
|
+
copyFrom(now, data[i + 1], data[i + 2]);
|
|
258
|
+
if (!count && useStartArrow) copy(first, now);
|
|
259
|
+
}
|
|
260
|
+
i += 3;
|
|
261
|
+
break;
|
|
262
|
+
|
|
263
|
+
case C:
|
|
264
|
+
if (count === 1 || i + 7 === len) copyPoints(data, last, now, i + 3);
|
|
265
|
+
i += 7;
|
|
266
|
+
break;
|
|
267
|
+
|
|
268
|
+
case Q:
|
|
269
|
+
if (count === 1 || i + 5 === len) copyPoints(data, last, now, i + 1);
|
|
270
|
+
i += 5;
|
|
271
|
+
break;
|
|
272
|
+
|
|
273
|
+
case Z:
|
|
274
|
+
return;
|
|
275
|
+
|
|
276
|
+
case N:
|
|
277
|
+
i += 5;
|
|
278
|
+
break;
|
|
279
|
+
|
|
280
|
+
case D:
|
|
281
|
+
i += 9;
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case X:
|
|
285
|
+
i += 6;
|
|
286
|
+
break;
|
|
287
|
+
|
|
288
|
+
case G:
|
|
289
|
+
i += 9;
|
|
290
|
+
break;
|
|
291
|
+
|
|
292
|
+
case F:
|
|
293
|
+
i += 5;
|
|
294
|
+
break;
|
|
295
|
+
|
|
296
|
+
case O:
|
|
297
|
+
i += 7;
|
|
298
|
+
break;
|
|
299
|
+
|
|
300
|
+
case P:
|
|
301
|
+
i += 4;
|
|
302
|
+
break;
|
|
303
|
+
|
|
304
|
+
case U:
|
|
305
|
+
if (count === 1 || i + 6 === len) copyPoints(data, last, now, i + 1);
|
|
306
|
+
i += 6;
|
|
307
|
+
break;
|
|
235
308
|
}
|
|
236
309
|
count++;
|
|
237
|
-
if (count === 1 && command !== M)
|
|
238
|
-
|
|
239
|
-
if (count === 2 && useStartArrow)
|
|
240
|
-
copy(second, command === L ? now : last);
|
|
310
|
+
if (count === 1 && command !== M) return;
|
|
311
|
+
if (count === 2 && useStartArrow) copy(second, command === L ? now : last);
|
|
241
312
|
if (i === len) {
|
|
242
|
-
const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
|
|
313
|
+
const path = ui.__.__pathForRender = changeRenderPath ? [ ...data ] : data;
|
|
243
314
|
const pathForArrow = ui.__.__pathForArrow = [];
|
|
244
315
|
if (useStartArrow) {
|
|
245
316
|
const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
|
|
@@ -250,50 +321,57 @@ const PathArrowModule = {
|
|
|
250
321
|
path[2] = second.y;
|
|
251
322
|
}
|
|
252
323
|
}
|
|
253
|
-
if (endArrow && endArrow !==
|
|
324
|
+
if (endArrow && endArrow !== "none") {
|
|
254
325
|
const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
|
|
255
326
|
dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
|
|
256
327
|
if (connectPoint.x) {
|
|
257
328
|
getDistancePoint(now, last, -connectPoint.x, true);
|
|
258
329
|
let index;
|
|
259
330
|
switch (command) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
331
|
+
case L:
|
|
332
|
+
index = i - 3 + 1;
|
|
333
|
+
break;
|
|
334
|
+
|
|
335
|
+
case C:
|
|
336
|
+
index = i - 7 + 5;
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
case Q:
|
|
340
|
+
index = i - 5 + 3;
|
|
341
|
+
break;
|
|
342
|
+
|
|
343
|
+
case U:
|
|
344
|
+
index = i - 6 + 3;
|
|
345
|
+
break;
|
|
272
346
|
}
|
|
273
|
-
if (index)
|
|
274
|
-
setPoint(path, last, index);
|
|
347
|
+
if (index) setPoint(path, last, index);
|
|
275
348
|
}
|
|
276
349
|
}
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
350
|
+
} else {
|
|
279
351
|
copy(last, now);
|
|
280
352
|
}
|
|
281
353
|
}
|
|
282
354
|
}
|
|
283
355
|
};
|
|
356
|
+
|
|
284
357
|
function copyPoints(data, from, to, startIndex) {
|
|
285
358
|
copyFrom(from, data[startIndex], data[startIndex + 1]);
|
|
286
359
|
copyFrom(to, data[startIndex + 2], data[startIndex + 3]);
|
|
287
360
|
}
|
|
361
|
+
|
|
288
362
|
function setPoint(data, point, startIndex) {
|
|
289
363
|
data[startIndex] = point.x;
|
|
290
364
|
data[startIndex + 1] = point.y;
|
|
291
365
|
}
|
|
292
366
|
|
|
293
|
-
draw.Plugin.add(
|
|
294
|
-
|
|
295
|
-
draw.UI.addAttr(
|
|
367
|
+
draw.Plugin.add("arrow");
|
|
368
|
+
|
|
369
|
+
draw.UI.addAttr("startArrow", "none", arrowType);
|
|
370
|
+
|
|
371
|
+
draw.UI.addAttr("endArrow", "none", arrowType);
|
|
372
|
+
|
|
296
373
|
Object.assign(draw.PathArrow, PathArrowModule);
|
|
374
|
+
|
|
297
375
|
Object.assign(draw.Paint, {
|
|
298
376
|
strokeArrow(_stroke, ui, canvas) {
|
|
299
377
|
if (ui.__.dashPattern) {
|
|
@@ -306,6 +384,9 @@ Object.assign(draw.Paint, {
|
|
|
306
384
|
});
|
|
307
385
|
|
|
308
386
|
exports.ArrowData = ArrowData;
|
|
387
|
+
|
|
309
388
|
exports.PathArrowModule = PathArrowModule;
|
|
389
|
+
|
|
310
390
|
exports.PathMatrixHelper = PathMatrixHelper;
|
|
391
|
+
|
|
311
392
|
exports.arrowType = arrowType;
|