fix(pathfinder): Divide splits shapes with an open cutting line (#1307)

This commit is contained in:
Ikki Nishihara
2026-10-12 15:16:57 +07:00
committed by bflatastic
parent 6ab08dd407
commit 18e538ec94
7 changed files with 186 additions and 3 deletions
+8 -1
View File
@@ -313,10 +313,17 @@ fn run_pf(s: &mut Session, op: PathfinderOp) -> Result<Value> {
// Build the stack (back → front) with a style per entry.
let mut styles: Vec<Style> = vec![];
let mut shapes: Vec<po::Shape> = vec![];
let mut push = |path: PathData, rule: FillRule, st: Style| {
let mut push = |mut path: PathData, rule: FillRule, st: Style| {
if path.is_empty() {
return;
}
if op == PathfinderOp::Divide && st.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Fill(f) if !f.paint.is_none())) {
// Filled open contours keep their implicit closing edge. A zero-area line
// stays a cutter; normalised area also catches zero-signed-area self crossings.
for sub in path.subpaths.iter_mut().filter(|sp| !sp.closed) {
sub.closed = po::encloses_area(sub) || po::area(&PathData::single(sub.clone()), rule) > 0.0;
}
}
let key = match styles.iter().position(|x| *x == st) {
Some(k) => k,
None => {