Skip to content

Commit 7d3c7a2

Browse files
committed
evaluate segment at t as euclidean distance. fix.
1 parent b38b4d9 commit 7d3c7a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ pub fn sample_points_on_bezpath(bezpath: BezPath, spacing: f64, start_offset: f6
6363
let mut next_segment_length = segments_length[next_segment_index];
6464

6565
// Keep moving to the next segment while the next sample point length is less or equals to the length up to that segment.
66-
while next_length > next_segment_length && (next_length - next_segment_length) > POSITION_ACCURACY {
66+
while next_length > next_segment_length {
67+
if next_segment_index == segments_length.len() - 1 {
68+
break;
69+
}
6770
length_up_to_previous_segment += next_segment_length;
6871
next_length = length_up_to_next_sample_point - length_up_to_previous_segment;
6972
next_segment_index += 1;
@@ -72,7 +75,9 @@ pub fn sample_points_on_bezpath(bezpath: BezPath, spacing: f64, start_offset: f6
7275

7376
let t = (next_length / next_segment_length).clamp(0., 1.);
7477

75-
let point = bezpath.get_seg(next_segment_index + 1).unwrap().eval(t);
78+
let segment = bezpath.get_seg(next_segment_index + 1).unwrap();
79+
let t = eval_pathseg_euclidean(segment, t, POSITION_ACCURACY);
80+
let point = segment.eval(t);
7681

7782
if sample_bezpath.elements().is_empty() {
7883
sample_bezpath.move_to(point)

0 commit comments

Comments
 (0)