@@ -69,18 +69,18 @@ const { scale, offset, invScale } = useGraphContext();
69
69
const { colors } = useColors ();
70
70
const color = computed (() => props .color ?? colors .value .stroke );
71
71
72
+ const pixelVector = computed (() =>
73
+ Vector2 .wrap (props .to ).sub (props .from ).mul (scale .value ),
74
+ );
72
75
const from = computed (() =>
73
76
new Vector2 (props .from )
74
77
.mul (new Vector2 (1 , - 1 ))
75
78
.mul (scale .value )
76
79
.add (offset .value ),
77
80
);
78
81
const to = computed (() => {
79
- const toVector = new Vector2 (props .to );
80
-
81
- const pixelVector = toVector .sub (Vector2 .wrap (props .from )).mul (scale .value );
82
- const angle = pixelVector .angle ;
83
- const magnitude = pixelVector .length ();
82
+ const angle = pixelVector .value .angle ;
83
+ const magnitude = pixelVector .value .length ();
84
84
const newMagnitude = magnitude - arrowSize .value ;
85
85
86
86
return new Vector2 (
@@ -89,12 +89,15 @@ const to = computed(() => {
89
89
);
90
90
});
91
91
const labelPosition = computed (() => {
92
- const toVector = Vector2 .wrap (props .to ).sub (Vector2 .wrap (props .from ));
93
92
const fromVector = Vector2 .wrap (props .from );
93
+ const toVector = Vector2 .wrap (props .to ).sub (fromVector );
94
94
return fromVector .add (toVector .normalized ().scale (toVector .length () / 2 ));
95
95
});
96
96
const dashArray = computed (() =>
97
97
props .dashed ? [6 * invScale .value , 4 * invScale .value ].join (" ," ) : " 0,0" ,
98
98
);
99
- const arrowSize = computed (() => props .arrowSize * invScale .value );
99
+ const arrowSize = computed (
100
+ () =>
101
+ Math .min (props .arrowSize , pixelVector .value .length () / 2 ) * invScale .value ,
102
+ );
100
103
</script >
0 commit comments