mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 10:27:00 -06:00
Keep open subpaths open in ReverseSubpaths::reverse_subpaths
Found while testing crates/geom/src/lib.rs:287 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
d9c924c3ba
commit
2e12bdfd91
@@ -284,7 +284,9 @@ impl ReverseSubpaths for BezPath {
|
||||
kurbo::PathSeg::Cubic(c) => out.curve_to(c.p1, c.p2, c.p3),
|
||||
}
|
||||
}
|
||||
out.close_path();
|
||||
if matches!(seg_path.elements().last(), Some(kurbo::PathEl::ClosePath)) {
|
||||
out.close_path();
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
@@ -108,3 +108,18 @@ fn set_rotation_keeps_center() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reverse_subpaths_preserves_open_and_closed() {
|
||||
let mut open = BezPath::new();
|
||||
open.move_to((0.0, 0.0));
|
||||
open.line_to((10.0, 0.0));
|
||||
open.line_to((10.0, 10.0));
|
||||
let r = <BezPath as ReverseSubpaths>::reverse_subpaths(&open);
|
||||
assert!(!r.elements().iter().any(|e| matches!(e, kurbo::PathEl::ClosePath)), "{:?}", r.elements());
|
||||
|
||||
let mut closed = open.clone();
|
||||
closed.close_path();
|
||||
let r = <BezPath as ReverseSubpaths>::reverse_subpaths(&closed);
|
||||
assert!(matches!(r.elements().last(), Some(kurbo::PathEl::ClosePath)), "{:?}", r.elements());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user