From 9a060cfbf7e5dfa9fb06e98aa8a66b873e65411d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 11:17:57 -0800 Subject: [PATCH] Smooth Bridge: a stretched circle is not called an ellipse of unequal width and height A transform that stretches an ellipse keeps its stored width and height, so a circle stretched into an oval still stores equal ones. The refusal now names unequal width and height only when the stored values differ, and gives the general message otherwise. docs/mcp.md notes that more than 2,000 objects are refused by the circle limit before any object is checked. --- crates/engine/src/cmd/addons/pathtools/bridge.rs | 4 +++- .../engine/src/cmd/addons/pathtools/bridge/tests.rs | 12 +++++++++++- docs/mcp.md | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/pathtools/bridge.rs b/crates/engine/src/cmd/addons/pathtools/bridge.rs index 449853d683..ea4f940ab9 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge.rs @@ -179,7 +179,9 @@ fn not_a_circle(d: &Document, id: NodeId, editable: bool) -> &'static str { }; match d.node(id).map(|n| &n.kind) { _ if !editable => "a selected object is hidden or locked", - Some(NodeKind::Path { live: Some(live), guide: false, clipping: false, .. }) if matches!(**live, LiveShape::Ellipse { pie, .. } if whole(pie)) => { + // A transform that stretches an ellipse leaves its stored width and height as they were, so one stored with + // equal width and height gets the general message. + Some(NodeKind::Path { live: Some(live), guide: false, clipping: false, .. }) if matches!(**live, LiveShape::Ellipse { w, h, pie, .. } if whole(pie) && w != h) => { "an ellipse whose width and height differ is not a circle: draw it with Shift held, or give it equal width and height" } Some(NodeKind::Compound { .. }) => "a compound path is not a circle: release it first", diff --git a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs index caaa0b1b42..f9b9ea23ef 100644 --- a/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs +++ b/crates/engine/src/cmd/addons/pathtools/bridge/tests.rs @@ -2,7 +2,7 @@ //! gap, many circles joined to their neighbors within reach, and what it refuses. use serde_json::{Value, json}; -use vectorcraft_doc::{NodeId, NodeKind}; +use vectorcraft_doc::{LiveShape, NodeId, NodeKind}; use vectorcraft_geom::kurbo::Shape; use crate::Session; @@ -181,6 +181,8 @@ fn a_refusal_says_why_an_object_is_not_a_circle() { // A hand-drawn ellipse 1 pt taller than wide. let oval = NodeId(s.execute("shape.ellipse", &json!({"x": 200, "y": 80, "width": 40, "height": 41})).unwrap()["id"].as_u64().unwrap()); let square = NodeId(s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let stretched = circle(&mut s, 300.0, 100.0, 20.0); + s.execute("object.transform", &json!({"ids": [stretched.0], "matrix": [2.0, 0.0, 0.0, 1.0, 0.0, 0.0]})).unwrap(); let steps = s.doc().unwrap().history.undo.len(); let e = err(&mut s, json!({"ids": [a.0, oval.0]})); assert!( @@ -191,6 +193,14 @@ fn a_refusal_says_why_an_object_is_not_a_circle() { ); let e = err(&mut s, json!({"ids": [a.0, square.0]})); assert!(e.ends_with("select two or more circles to bridge: a selected object is not a circle"), "{e}"); + // A circle stretched by a transform keeps its equal stored width and height, so it is not called unequal. + let equal = match s.doc().unwrap().doc.node(stretched).map(|n| &n.kind) { + Some(NodeKind::Path { live: Some(live), .. }) => matches!(**live, LiveShape::Ellipse { w, h, .. } if w == h), + _ => false, + }; + assert!(equal, "the stretched circle keeps a live ellipse of equal width and height"); + let e = err(&mut s, json!({"ids": [a.0, stretched.0]})); + assert!(e.ends_with("select two or more circles to bridge: a selected object is not a circle"), "{e}"); let e = err(&mut s, json!({"ids": [a.0]})); assert!(e.ends_with("select two or more circles to bridge"), "one circle: {e}"); select(&mut s, &[b]); diff --git a/docs/mcp.md b/docs/mcp.md index 88a10b3ad0..3797b2b3f6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -16855,7 +16855,9 @@ Commands: third circle the gap from both would sit, as in a triangular grid, so the channels around an empty place in such a grid are one width; in a square grid they are not. Giving both `radius` and `gap` is an error. Overlapping and touching circles are joined at every radius. An object that is not a circle is an error that says why: an ellipse whose - width and height differ, a compound path, an object that is hidden or locked, or another object. One circle inside the + width and height differ, a compound path, an object that is hidden or locked, or another object. More than 2,000 + objects (with groups counted as the objects inside them) are refused as more than 2,000 circles before any of them is + checked, so that error does not say which object is not a circle. One circle inside the other is an error, and so are circles too far apart for the radius or gap: the arcs would not reach both circles, or would cross before they do. The error suggests a larger radius or gap only when the largest (1,000% or 1,000 pt) would bridge the circles. The outline replaces the two