Fill Area: a left-out path cuts an area only when one of its segments reaches it

A path with too many segments for a window's map is left out of it. The finder treated such a path as cutting the area whenever its bounding box met the area, so a path made of subpaths far apart on either side of an area made the finder map every path, which fails past the segment limit, and the area could not be filled. The finder now checks the path's segments.
This commit is contained in:
dotCooCoo
2026-11-17 18:53:58 -08:00
parent 94fee63cc1
commit af868f2de6
2 changed files with 37 additions and 1 deletions
+11 -1
View File
@@ -2,6 +2,8 @@
//! closed path of that area with the current fill and stroke (`shapeBuilder.copyRegion`). The
//! paths around the area stay as they are, and nothing needs to be selected.
use vectorcraft_geom::path::segment_bounds;
use super::lookup::path_contains;
use super::*;
@@ -63,6 +65,13 @@ fn meet(a: &Rect, b: &Rect) -> bool {
a.x0 <= b.x1 && b.x0 <= a.x1 && a.y0 <= b.y1 && b.y0 <= a.y1
}
/// Does a segment of `path` (closing segments included) meet `zone`? A path whose box meets the zone
/// may still lie wholly outside it, as a path of subpaths far apart does.
fn reaches(path: &PathData, zone: &Rect) -> bool {
let bez = path.to_bezpath();
vectorcraft_geom::kurbo::segments(bez.elements().iter().copied()).any(|seg| meet(&segment_bounds(seg), zone))
}
/// Does `outer` hold all of `inner`?
fn within(inner: &Rect, outer: &Rect) -> bool {
inner.x0 >= outer.x0 && inner.x1 <= outer.x1 && inner.y0 >= outer.y0 && inner.y1 <= outer.y1
@@ -159,7 +168,8 @@ impl AreaFinder {
// path holds both.
Some(rb) if within(&rb, &window) => {
let reached = rb.inflate(reach, reach);
let cut = any_left_out && self.inputs.iter().zip(&left_out).any(|((_, b, _), out)| *out && meet(b, &reached));
let cut = any_left_out
&& self.inputs.iter().zip(&left_out).any(|((s, b, _), out)| *out && meet(b, &reached) && reaches(&s.path, &reached));
if !cut {
return self.area_in(&map, &picked, p);
}