Skip to content

Commit 5ef41ba

Browse files
committed
Improve comments
1 parent 15b2918 commit 5ef41ba

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,27 +1147,33 @@ async fn sample_points(_: impl Ctx, vector_data: VectorDataTable, spacing: f64,
11471147
let spacing = spacing.max(0.01);
11481148

11491149
let vector_data_transform = vector_data.transform();
1150-
// Using [stroke_bezpath_iter] so that the [subpath_segment_lengths] is aligned to the segments of each bezpaths.
1151-
// So we can index into [subpath_segment_lengths] to get the length of the segments.
1152-
// NOTE: [subpath_segment_lengths] has precalulated lengths with transformation applied.
1150+
1151+
// Using `stroke_bezpath_iter` so that the `subpath_segment_lengths` is aligned to the segments of each bezpath.
1152+
// So we can index into `subpath_segment_lengths` to get the length of the segments.
1153+
// NOTE: `subpath_segment_lengths` has precalulated lengths with transformation applied.
11531154
let bezpaths = vector_data.one_instance_ref().instance.stroke_bezpath_iter();
11541155

11551156
// Initialize the result VectorData with the same transformation as the input.
11561157
let mut result = VectorDataTable::default();
11571158
*result.transform_mut() = vector_data_transform;
11581159

1159-
// To keep the index of the first segment of the next bezpath to get lengths of segments.
1160+
// Keeps track of the index of the first segment of the next bezpath in order to get lengths of all segments.
11601161
let mut next_segment_index = 0;
11611162

11621163
for mut bezpath in bezpaths {
11631164
let mut sample_bezpath = BezPath::new();
1165+
11641166
// Apply the tranformation to the current bezpath to calculate points after transformation.
11651167
bezpath.apply_affine(Affine::new(vector_data_transform.to_cols_array()));
1168+
11661169
let segment_count = bezpath.segments().count();
1167-
// For the current bezpath the get its segments length by calculating the start index and end index.
1170+
1171+
// For the current bezpath we get its segment's length by calculating the start index and end index.
11681172
let lengths = &subpath_segment_lengths[next_segment_index..next_segment_index + segment_count];
1169-
// Increment the segment index by the number of segments in the current bezpath to calculate the next bezpath segments length.
1173+
1174+
// Increment the segment index by the number of segments in the current bezpath to calculate the next bezpath segment's length.
11701175
next_segment_index += segment_count;
1176+
11711177
// Calculate the total length of the collected segments.
11721178
let total_length: f64 = lengths.iter().sum();
11731179

@@ -1203,9 +1209,9 @@ async fn sample_points(_: impl Ctx, vector_data: VectorDataTable, spacing: f64,
12031209
let fraction = c as f64 / count;
12041210
let current_length = fraction * used_length + start_offset;
12051211
let t = current_length / total_length;
1206-
let point = position_on_bezpath(&bezpath, t, true, Some(&lengths));
1212+
let point = position_on_bezpath(&bezpath, t, true, Some(lengths));
12071213

1208-
if sample_bezpath.elements().len() == 0 {
1214+
if sample_bezpath.elements().is_empty() {
12091215
sample_bezpath.move_to(point)
12101216
} else {
12111217
sample_bezpath.line_to(point)
@@ -1214,6 +1220,7 @@ async fn sample_points(_: impl Ctx, vector_data: VectorDataTable, spacing: f64,
12141220

12151221
// Reverse the transformation applied to the bezpath as the `result` already has the transformation set.
12161222
sample_bezpath.apply_affine(Affine::new(vector_data_transform.to_cols_array()).inverse());
1223+
12171224
// Append the bezpath (subpath) that connects generated points by lines.
12181225
result.one_instance_mut().instance.append_bezpath(sample_bezpath);
12191226
}

0 commit comments

Comments
 (0)