@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.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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
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 !==
|
|
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() {
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
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 = {
|
|
167
|
+
const mark = {
|
|
168
|
+
offset: half,
|
|
169
|
+
path: [ 1, 0, -2, 2, 0, 2 ]
|
|
170
|
+
};
|
|
138
171
|
const arrows = {
|
|
139
|
-
angle,
|
|
140
|
-
|
|
141
|
-
arrow,
|
|
142
|
-
triangle,
|
|
143
|
-
|
|
144
|
-
circle,
|
|
145
|
-
|
|
146
|
-
square,
|
|
147
|
-
|
|
148
|
-
diamond,
|
|
149
|
-
|
|
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 } = (
|
|
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
|
-
|
|
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 ===
|
|
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 {
|
|
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
|
|
184
|
-
let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !==
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 !==
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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.
|
|
294
|
-
draw.UI.addAttr(
|
|
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);
|
package/dist/arrow.min.cjs
CHANGED
|
@@ -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,
|
|
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
|