diff --git a/crates/engine/src/cmd/draw2/common.rs b/crates/engine/src/cmd/draw2/common.rs index 3b5022ff64..89a0f44007 100644 --- a/crates/engine/src/cmd/draw2/common.rs +++ b/crates/engine/src/cmd/draw2/common.rs @@ -319,9 +319,9 @@ pub(super) fn target_paths(doc: &Document, sel: &Selection, area: Rect) -> Vec bool { - n.appearance.items.iter().any(|item| item.is_fill() && !item.paint().is_none()) + n.appearance.items.iter().any(|item| item.is_fill() && item.visible() && !item.paint().is_none()) } /// [`target_paths`] for tools that cut fills, with geometry and fill rule. Closed compound paths diff --git a/crates/engine/src/cmd/draw2/cut.rs b/crates/engine/src/cmd/draw2/cut.rs index 287b850b71..34a8501a9c 100644 --- a/crates/engine/src/cmd/draw2/cut.rs +++ b/crates/engine/src/cmd/draw2/cut.rs @@ -327,7 +327,12 @@ pub(super) fn erase_region(s: &mut Session, p: &Value) -> Result { if !lines.is_empty() { if let Some(rest) = erase_outline(&lines, short / 2.0, &under) { changed = true; - pieces.extend(rest); + // Partitioning must not turn one compound outline into independently filled objects. + if single { + pieces.extend(rest); + } else if !rest.is_empty() { + pieces.push(PathData::new(rest.into_iter().flat_map(|path| path.subpaths).collect())); + } } else { pieces.push(lines); } diff --git a/crates/engine/tests/eraser_open_fill.rs b/crates/engine/tests/eraser_open_fill.rs index 19e73c125f..5d8a2b0895 100644 --- a/crates/engine/tests/eraser_open_fill.rs +++ b/crates/engine/tests/eraser_open_fill.rs @@ -284,3 +284,93 @@ fn eraser_cuts_the_outline_when_even_odd_cancels_an_open_paths_fill() { let length: f64 = paths(&s).iter().map(PathData::length).sum(); assert!((length - 760.0).abs() < 0.1, "both laps lose their crossed stroke portions: {length}"); } + +/// Hidden fills retain open outlines, while a lower visible fill beneath None still paints. +#[test] +fn eraser_hidden_fill_keeps_only_the_explicit_open_outline() { + let render = |s: &Session| { + vectorcraft_render::Renderer::new().render(&s.doc().unwrap().doc, 300, 300, vectorcraft_geom::Affine::IDENTITY, &Default::default()) + }; + for lower_fill in [false, true] { + let mut s = session(); + let id = NodeId( + s.execute( + "path.create", + &json!({"anchors": [ + {"x": 100, "y": 100}, {"x": 200, "y": 100}, {"x": 200, "y": 200}, {"x": 100, "y": 200} + ]}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": "#000000"})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [id.0], "color": "#ff0000"})).unwrap(); + s.execute("stroke.set", &json!({"ids": [id.0], "weight": 2})).unwrap(); + if lower_fill { + // The basic black Fill remains visible underneath this added top Fill set to None. + s.execute("appearance.addFill", &json!({"ids": [id.0]})).unwrap(); + s.execute("appearance.setItem", &json!({"ids": [id.0], "index": 2, "none": true})).unwrap(); + } else { + // Basic appearance order is Fill 0, Stroke 1; hiding Fill 0 leaves only open strokes. + s.execute("appearance.setItem", &json!({"ids": [id.0], "index": 0, "visible": false})).unwrap(); + } + s.execute("select.none", &json!({})).unwrap(); + let before = render(&s); + if lower_fill { + assert!(before.pixel(150, 125)[3] > 240, "the lower black fill remains visible under top None"); + } else { + assert_eq!(before.pixel(150, 125)[3], 0, "hidden fill leaves the interior empty"); + assert_eq!(before.pixel(100, 125)[3], 0, "the open path has no implicit left stroke"); + } + assert!(before.pixel(200, 125)[0] > 200 && before.pixel(200, 125)[1] < 60, "the explicit right stroke is visible"); + + s.execute("path.eraseRegion", &json!({"points": [[50, 150], [250, 150]], "size": 10})).unwrap(); + let after = render(&s); + if lower_fill { + assert!(after.pixel(150, 125)[3] > 240, "visible lower fill survives above the erased band"); + assert!(after.pixel(150, 175)[3] > 240, "visible lower fill survives below the erased band"); + assert_eq!(after.pixel(150, 150)[3], 0, "the Eraser band is empty"); + } else { + let survivors = paths(&s); + assert!(survivors.iter().all(|path| !path.is_closed()), "unfilled survivors remain open"); + let length: f64 = survivors.iter().map(PathData::length).sum(); + assert!((length - 290.0).abs() < 0.1, "only the crossed explicit right edge loses 10 pt: {length}"); + assert_eq!(after.pixel(150, 125)[3], 0, "hidden fill leaves the interior empty"); + assert_eq!(after.pixel(100, 125)[3], 0, "the missing implicit left stroke remains absent"); + } + } +} + +/// The original compound's cancelled outline stays grouped beside its filled contour. +#[test] +fn eraser_even_odd_cancellation_survives_beside_a_filled_subpath() { + let mut s = session(); + let id = NodeId( + s.execute("path.create", &json!({"d": "M100 100H200V200H100V100H200V200H100V100 M230 100H280V200H230"})).unwrap()["id"].as_u64().unwrap(), + ); + s.execute("paint.setFill", &json!({"ids": [id.0], "color": "#000000"})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [id.0], "color": "#ff0000"})).unwrap(); + s.execute("stroke.set", &json!({"ids": [id.0], "weight": 2})).unwrap(); + s.execute("path.setFillRule", &json!({"ids": [id.0], "rule": "evenOdd"})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + assert_eq!(path(&s, id).subpaths.len(), 2, "one node holds both open subpaths"); + assert!(path(&s, id).subpaths.iter().all(|subpath| !subpath.closed)); + let render = |s: &Session| { + vectorcraft_render::Renderer::new().render(&s.doc().unwrap().doc, 300, 300, vectorcraft_geom::Affine::IDENTITY, &Default::default()) + }; + let before = render(&s); + assert_eq!(before.pixel(150, 125)[3], 0, "the twice-traced open subpath cancels under Even-Odd"); + assert_eq!(before.pixel(150, 175)[3], 0, "the cancelled lower run is empty before Eraser"); + assert!(before.pixel(250, 125)[3] > 240, "the disjoint open rectangle fills"); + + s.execute("path.eraseRegion", &json!({"points": [[50, 150], [290, 150]], "size": 10})).unwrap(); + let after = render(&s); + assert_eq!(after.pixel(150, 175)[3], 0, "the cancelled interior stays empty below the sweep"); + assert!(after.pixel(250, 125)[3] > 240, "the disjoint filled subpath survives"); + assert_eq!(after.pixel(250, 150)[3], 0, "the swept band through the filled subpath is empty"); + for (x, y) in [(100, 125), (200, 125), (230, 125), (280, 125)] { + let pixel = after.pixel(x, y); + assert!(pixel[0] > 200 && pixel[1] < 60 && pixel[2] < 60 && pixel[3] > 200, "open outline survivor ({x},{y}): {pixel:?}"); + } +} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index b4d9403719..2e907ea477 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -217,7 +217,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Area | Weight | Done | Main gaps | One agent (h) | Kind | |---|---:|---:|---|---:|---| | Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); deletion splits an ordinary contour into selected sibling objects with bounds-fitted gradients kept in place (#3380, deletion only; `crates/engine/tests/it/delete_path_pieces.rs`); open-path anchor Delete keeps gaps; Select › Start Global Edit finds the paths, compound paths and symbol instances of the selected object's shape (Appearance, Size and artboard options) and gives an edit of one to all of them in proportion, as one undo step (#3521), and on a group the groups like it, an edit inside one reaching the same object in the others (#4939), and a Shift-click on a highlighted match leaves it out; the Align panel menu's Align to Glyph Bounds › Point Text and Area Text measure type by its glyphs' ink for Align and Distribute (#4231); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of rotated copies, transform nuances (no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | estimated; Global Edit regression-tested (`crates/engine/src/tests/globaledit.rs`; Quick Action, menu label and Escape in `panels::properties::tests::start_global_edit_quick_action_and_escape`) | -| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options, Touch Type, Dimension tool; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged | +| Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options, Touch Type, Dimension tool; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; Eraser preserves filled open-path area outside its sweep, including compound holes and mixed stroked lines (#6582; `crates/engine/tests/eraser_open_fill.rs`), score and hours unchanged | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 80% | Shape Builder on the reporter's file (#937: art past 4,096 segments is cut by lines again; unconfirmed on the file itself); gap detection shares Live Paint’s finder, with a 72 pt custom cap and the existing options; Live Paint Gap Options | 4–8 | estimated; Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog (lowered from 86%: open issues); compound attributes regression-tested (#1197); single-result source names survive SVG export/import (#1293), with [SVG ID semantics](https://www.w3.org/TR/SVG2/struct.html#IDAttribute) and original-shape tests; Simplify component selection and preview regression-tested (#1272); Simplify of a Direct Selection part of a path regression-tested (`tests/simplify_part.rs`); Divide open-cutting-path geometry and appearance regression-tested (#1307); the Shape Builder's edge-source grid is bounded in memory and files a segment once per cell (`planar.rs` test `rect_index_holds_a_bounded_number_of_references`); live compound shapes (Make, Alt-click, member Shape Modes, Release, Expand, saved and exported) regression-tested (#4522) | | Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors | 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged | | Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (five generated libraries including Game Trails, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) |