-
Notifications
You must be signed in to change notification settings - Fork 7
Description
I'm guessing that this is not so much a bug, as much as "missing functionality", so bear with me.
I'm using flo_curves to manipulate paths in an application where whether paths are clockwise or counterclockwise is significant (specifically I'm manipulating overlapping glyph contours in OpenType), and path_remove_interior_points() seems to correctly handle overlapping lines correctly.
However, it doesn't seem to preserve the direction in the results. I've hacked together a unit test to illustrate:
#[test]
fn path_remove_interior_points_preserves_direction() {
// This is a counter clockwise path roughly like a triangle, but with the addition of weird "prongs", roughly like this:
// __
// \/
// /\
// / \
// / \
// / \
// __/________\__
// \/ \/
let triangle_with_prongs = BezierPathBuilder::<SimpleBezierPath>::start(Coord2(584.0, 46.0))
.line_to(Coord2(327.0, 639.0))
.line_to(Coord2(409.0, 628.0))
.line_to(Coord2(147.0, 37.0))
.line_to(Coord2(94.0, 93.0))
.line_to(Coord2(634.0, 93.0))
.line_to(Coord2(584.0, 46.0))
.build();
// This path is counter clockwise
assert!(!triangle_with_prongs.is_clockwise());
// We want to use path_remove_interior_points() to break this up into four triangles
let split_triangles = path_remove_interior_points::<SimpleBezierPath, SimpleBezierPath>(
&vec![triangle_with_prongs],
0.01,
);
// And it succeeds - we have four triangles
assert_eq!(4, split_triangles.len());
// However, we also want to ensure that the directions are preserved in the split triangles. Since we started with a counter clockwise
// shape, we'd expect the "main" triangle in the results to be counter clockwise, and the "prong triangles" to be clockwise. However
// we're not getting those results
assert_eq!(
3,
split_triangles.iter().filter(|x| x.is_clockwise()).count() // ERROR - seems to return '1'
);
}
I realize that that working with shapes where clockwise and counterclockwise paths are interpreted differently is not something flo_curves does by default, and for the most part I was able to do the handling on my side, with this exception.
Thanks in advance!