mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Improve stability of the 'Sample Points' node (#3119)
improve perimeter calculation of the path bezier segments when it is very close to linear bezier curve Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -1331,6 +1331,14 @@ async fn poisson_disk_points(
|
||||
|
||||
#[node_macro::node(category(""), path(graphene_core::vector))]
|
||||
async fn subpath_segment_lengths(_: impl Ctx, content: Table<Vector>) -> Vec<f64> {
|
||||
let pathseg_perimeter = |segment: PathSeg| {
|
||||
if is_linear(segment) {
|
||||
Line::new(segment.start(), segment.end()).perimeter(DEFAULT_ACCURACY)
|
||||
} else {
|
||||
segment.perimeter(DEFAULT_ACCURACY)
|
||||
}
|
||||
};
|
||||
|
||||
content
|
||||
.into_iter()
|
||||
.flat_map(|vector| {
|
||||
@@ -1340,7 +1348,7 @@ async fn subpath_segment_lengths(_: impl Ctx, content: Table<Vector>) -> Vec<f64
|
||||
.stroke_bezpath_iter()
|
||||
.flat_map(|mut bezpath| {
|
||||
bezpath.apply_affine(Affine::new(transform.to_cols_array()));
|
||||
bezpath.segments().map(|segment| segment.perimeter(DEFAULT_ACCURACY)).collect::<Vec<f64>>()
|
||||
bezpath.segments().map(pathseg_perimeter).collect::<Vec<f64>>()
|
||||
})
|
||||
.collect::<Vec<f64>>()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user