mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
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.
This commit is contained in:
1 parent
53ec5af6c8
commit
9a060cfbf7
3 files changed
+17
-3
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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]);
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user