|
@@ -102,6 +102,8 @@ const arrow = registerShapeUtils<ArrowShape>({
|
102
|
102
|
|
103
|
103
|
const strokeWidth = +styles.strokeWidth
|
104
|
104
|
|
|
105
|
+ const sw = strokeWidth * (style.dash === DashStyle.Solid ? 1 : 1.618)
|
|
106
|
+
|
105
|
107
|
const arrowDist = vec.dist(start.point, end.point)
|
106
|
108
|
|
107
|
109
|
let shaftPath: JSX.Element
|
|
@@ -126,7 +128,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
126
|
128
|
}
|
127
|
129
|
: getPerfectDashProps(
|
128
|
130
|
arrowDist,
|
129
|
|
- strokeWidth * 1.618,
|
|
131
|
+ sw,
|
130
|
132
|
shape.style.dash === DashStyle.Dotted ? 'dotted' : 'dashed',
|
131
|
133
|
2
|
132
|
134
|
)
|
|
@@ -149,9 +151,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
149
|
151
|
<path
|
150
|
152
|
d={path}
|
151
|
153
|
fill="none"
|
152
|
|
- strokeWidth={
|
153
|
|
- strokeWidth * (style.dash === DashStyle.Solid ? 1 : 1.618)
|
154
|
|
- }
|
|
154
|
+ strokeWidth={sw}
|
155
|
155
|
strokeDasharray={strokeDasharray}
|
156
|
156
|
strokeDashoffset={strokeDashoffset}
|
157
|
157
|
strokeLinecap="round"
|
|
@@ -176,7 +176,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
176
|
176
|
start.point,
|
177
|
177
|
end.point
|
178
|
178
|
) - 1,
|
179
|
|
- strokeWidth * 1.618,
|
|
179
|
+ sw,
|
180
|
180
|
shape.style.dash === DashStyle.Dotted ? 'dotted' : 'dashed',
|
181
|
181
|
2
|
182
|
182
|
)
|
|
@@ -205,7 +205,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
205
|
205
|
<path
|
206
|
206
|
d={path}
|
207
|
207
|
fill="none"
|
208
|
|
- strokeWidth={strokeWidth * 2}
|
|
208
|
+ strokeWidth={sw}
|
209
|
209
|
strokeDasharray={strokeDasharray}
|
210
|
210
|
strokeDashoffset={strokeDashoffset}
|
211
|
211
|
strokeLinecap="round"
|
|
@@ -395,35 +395,31 @@ const arrow = registerShapeUtils<ArrowShape>({
|
395
|
395
|
const handle = handles[id]
|
396
|
396
|
|
397
|
397
|
shape.handles[handle.id] = handle
|
|
398
|
+ }
|
398
|
399
|
|
|
400
|
+ if ('bend' in handles) {
|
399
|
401
|
const { start, end, bend } = shape.handles
|
400
|
402
|
|
401
|
403
|
const dist = vec.dist(start.point, end.point)
|
402
|
404
|
|
403
|
|
- if (handle.id === 'bend') {
|
404
|
|
- const midPoint = vec.med(start.point, end.point)
|
405
|
|
- const u = vec.uni(vec.vec(start.point, end.point))
|
406
|
|
- const ap = vec.add(midPoint, vec.mul(vec.per(u), dist / 2))
|
407
|
|
- const bp = vec.sub(midPoint, vec.mul(vec.per(u), dist / 2))
|
|
405
|
+ const midPoint = vec.med(start.point, end.point)
|
|
406
|
+ const u = vec.uni(vec.vec(start.point, end.point))
|
|
407
|
+ const ap = vec.add(midPoint, vec.mul(vec.per(u), dist / 2))
|
|
408
|
+ const bp = vec.sub(midPoint, vec.mul(vec.per(u), dist / 2))
|
408
|
409
|
|
409
|
|
- bend.point = vec.nearestPointOnLineSegment(ap, bp, bend.point, true)
|
410
|
|
- shape.bend = vec.dist(bend.point, midPoint) / (dist / 2)
|
|
410
|
+ bend.point = vec.nearestPointOnLineSegment(ap, bp, bend.point, true)
|
|
411
|
+ shape.bend = vec.dist(bend.point, midPoint) / (dist / 2)
|
411
|
412
|
|
412
|
|
- const sa = vec.angle(end.point, start.point)
|
413
|
|
- const la = sa - Math.PI / 2
|
414
|
|
- if (isAngleBetween(sa, la, vec.angle(end.point, bend.point))) {
|
415
|
|
- shape.bend *= -1
|
416
|
|
- }
|
|
413
|
+ const sa = vec.angle(end.point, start.point)
|
|
414
|
+ const la = sa - Math.PI / 2
|
|
415
|
+
|
|
416
|
+ if (isAngleBetween(sa, la, vec.angle(end.point, bend.point))) {
|
|
417
|
+ shape.bend *= -1
|
417
|
418
|
}
|
418
|
419
|
}
|
419
|
420
|
|
420
|
421
|
shape.handles.bend.point = getBendPoint(shape)
|
421
|
422
|
|
422
|
|
- // const newBounds = this.getRotatedBounds(shape)
|
423
|
|
- // const newCenter = getBoundsCenter(newBounds)
|
424
|
|
-
|
425
|
|
- // shape.point = vec.add(shape.point, vec.neg(vec.sub(newCenter, prevCenter)))
|
426
|
|
-
|
427
|
423
|
return this
|
428
|
424
|
},
|
429
|
425
|
|