Merge pull request #7949 from dotCooCoo/feat/circle-through-three-points

Shapes: draw the circle through three points
This commit is contained in:
BFlat
2026-11-17 09:49:57 +07:00
committed by GitHub
33 changed files with 786 additions and 21 deletions
+1
View File
@@ -137,6 +137,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
- 2026-11-14: Packaging Tools add-on (Object › Plug-ins › Packaging Tools): fold line roles for dielines (Cut, Crease, Partial Cut, Perforation), each carried by the swatch on a path's top stroke through a per-document role table that native files keep; PDF prints a role line on its swatch's separation when that swatch is a spot color, as the default role swatches are, and SVG, DXF and HP-GL keep the stroke's color. Make Cut Line, Make Crease Line, Make Partial Cut Line and Make Perforation Line give the selected paths a role, overprinting by default, and make a missing role swatch; the Fold Lines panel counts each role in the selection or the document, and its Role Swatches… picks another swatch for a role (`addon.packaging.setRole`, `addon.packaging.roles`, `addon.packaging.setRoleSwatch`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-16: Check Fold Lines in the Packaging Tools add-on (Object › Plug-ins › Packaging Tools, and the Fold Lines panel's Check button): the fold lines of the selection or the document are split into blanks, panels and hinges (cut lines bound the material, and creases, partial cuts and perforations divide it into panels), and 15 kinds of issue are listed, errors and warnings, each naming its lines: cut lines that enclose nothing or end loose, gaps closed within a tolerance, a cut on top of a crease, duplicate lines, creases that end inside a panel, divide nothing, lie outside the blank or are not straight, gaps too narrow to map, fold lines in a hole, panels joined by no crease, and fold lines on a non-printing layer. The panel lists the issues in the interface language; clicking one selects its lines (`addon.packaging.check`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-02: Mouse wheel over a closed font-family field in Character, Properties or Control changes selected text through the family list using saved font filters (excluding search text), one undo step per notch, stopping at the ends (#5253). Scores and estimates unchanged.
- 2026-11-15: Circle through three points: three Shift-clicks with the Ellipse tool, or `shape.circleThroughPoints` with three points or three selected anchor points, draw the circle whose edge passes through them, with the current paint, in one undo step; after two points the tool previews the circle through the pointer, and two points that are the same or three on one line are refused with a message. Scores and estimates unchanged.
- 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`).
- 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
- 2026-11-11: Pattern libraries: Patterns › Optical Effects, a third built-in pattern library, of VectorCraft's own designs, holds eight black wave, moiré and op-art tiles (Sine Bands, Ripple Lines, Interference Rings, Offset Rings, Warped Checks, Pinched Stripes, Chevron Pulse and Radiating Lenses) of 32 to 48 pt, each drawn the same way every time; each tile is one period of its design, and art that reaches past a tile edge continues on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
+94 -7
View File
@@ -57,6 +57,15 @@ pub fn specs() -> Vec<CommandSpec> {
has_doc,
flare
),
cmd!(
"shape.circleThroughPoints",
"Circle Through Points",
[],
None,
"{points?: [[x, y], [x, y], [x, y]] (left out: the three selected anchor points, where a path selected whole counts all its anchors and selected segments' ends do not count)} → {id, cx, cy, radius}: a circle with the current paint whose edge passes through the three points, not pixel-aligned even while Align New Objects to Pixel Grid is on; two points that are the same or three on one line are an error, and nothing is drawn",
has_doc,
circle_through_points
),
cmd!("shape.line", "Line Segment", [], None, "{x1, y1, x2, y2, fill?: bool (Fill Line: the current fill, else none)} → {id}", has_doc, line),
cmd!("shape.spiral", "Spiral", [], None, "{cx, cy, radius, decay=80 (%), segments=10, clockwise?} → {id}", has_doc, spiral),
cmd!(
@@ -131,14 +140,21 @@ pub(crate) fn add_look(s: &mut Session, label: &str, kind: NodeKind, look: NewAr
/// [`add_look`] that selects the new object only when `select` is set; otherwise the selection
/// stays as it was.
pub(crate) fn insert_look(s: &mut Session, label: &str, kind: NodeKind, look: NewArt, name: Option<String>, select: bool) -> Result<Value> {
insert_look_turned(s, label, kind, look, name, select, 0.0)
insert_look_turned(s, label, kind, look, name, select, 0.0, true)
}
/// [`add_art`] for an object made turned by a `rotation` param (degrees, clockwise on the page):
/// its bounding box turns with it, as after the Rotate tool.
fn add_art_turned(s: &mut Session, label: &str, kind: NodeKind, rotation: f64) -> Result<Value> {
let look = s.new_art_look(s.paint.fill.clone(), s.paint.stroke.clone(), s.paint.stroke_width);
insert_look_turned(s, label, kind, look, None, true, bbox_turn(rotation))
insert_look_turned(s, label, kind, look, None, true, bbox_turn(rotation), true)
}
/// [`add_art`] for an object whose geometry must stay where it was computed: it is not
/// pixel-aligned, even while the document's Align New Objects to Pixel Grid is on.
fn add_art_unaligned(s: &mut Session, label: &str, kind: NodeKind) -> Result<Value> {
let look = s.new_art_look(s.paint.fill.clone(), s.paint.stroke.clone(), s.paint.stroke_width);
insert_look_turned(s, label, kind, look, None, true, 0.0, false)
}
/// The bounding-box angle (counter-clockwise, as `Node::bbox_angle` and the Rotate tool keep it)
@@ -162,8 +178,10 @@ fn constrained_turn(s: &Session, rotation: f64) -> f64 {
}
}
/// [`insert_look`] with the new object's bounding box turned to `bbox_angle`. A new path or
/// compound path is pixel-aligned while the document's Align New Objects to Pixel Grid is on.
/// [`insert_look`] with the new object's bounding box turned to `bbox_angle`. With `align`, a new
/// path or compound path is pixel-aligned while the document's Align New Objects to Pixel Grid is
/// on.
#[allow(clippy::too_many_arguments)]
fn insert_look_turned(
s: &mut Session,
label: &str,
@@ -172,6 +190,7 @@ fn insert_look_turned(
name: Option<String>,
select: bool,
bbox_angle: f64,
align: bool,
) -> Result<Value> {
let parent = s.doc()?.target_parent()?;
let mode = s.draw_mode;
@@ -181,7 +200,9 @@ fn insert_look_turned(
let id = d.alloc_id();
let mut n = Node::new(id, kind);
look.apply(d, &mut n);
super::object::align_new_object(d, &mut n);
if align {
super::object::align_new_object(d, &mut n);
}
n.name = name;
n.bbox_angle = bbox_angle;
let mut into = None;
@@ -390,6 +411,71 @@ fn ellipse(s: &mut Session, p: &Value) -> Result<Value> {
add_art_turned(s, "Ellipse", path_kind(live.to_path(), Some(live)), rotation)
}
/// A live ellipse whose edge passes through three points: `points`, or the three selected anchor
/// points ([`selected_anchor_points`]). One undo step, named as an Ellipse tool drag is.
fn circle_through_points(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "shape.circleThroughPoints";
let points = match p.get("points").filter(|v| !v.is_null()) {
Some(v) => three_points(v).ok_or_else(|| bad(C, "`points` must be three [x, y] pairs of numbers"))?,
None => selected_anchor_points(s)?.ok_or_else(|| bad(C, "direct-select three anchor points, or give `points`"))?,
};
let [a, b, c] = points;
let (center, radius) = shapes::circle_through(a, b, c)
.ok_or_else(|| bad(C, "no circle passes through these points: two are the same or all three lie on one line"))?;
let r = Rect::new(center.x - radius, center.y - radius, center.x + radius, center.y + radius);
let live = LiveShape::Ellipse { w: r.width(), h: r.height(), pie: (0.0, 360.0), xf: Affine::translate(r.origin().to_vec2()) };
// Not pixel-aligned: the circle stays through the points.
let mut out = add_art_unaligned(s, "Ellipse", path_kind(live.to_path(), Some(live)))?;
out["cx"] = json!(center.x);
out["cy"] = json!(center.y);
out["radius"] = json!(radius);
Ok(out)
}
/// The three points `[[x, y], [x, y], [x, y]]` holds, each pair two finite numbers.
fn three_points(v: &Value) -> Option<[Point; 3]> {
let pair = |v: &Value| match v.as_array().map(Vec::as_slice) {
Some([x, y]) => x.as_f64().zip(y.as_f64()).filter(|(x, y)| x.is_finite() && y.is_finite()).map(|(x, y)| Point::new(x, y)),
_ => None,
};
match v.as_array().map(Vec::as_slice) {
Some([a, b, c]) => Some([pair(a)?, pair(b)?, pair(c)?]),
_ => None,
}
}
/// The positions of the selected anchor points, when there are exactly three. They are counted as
/// the other anchor commands count them ([`super::path::anchor_targets`]): a selected path with
/// anchors picked by Direct Selection gives those, and a path selected whole gives all of its own.
/// A selected segment's ends are not selected anchor points, so a selection with segments gives
/// none; so does a selection holding an object that is not a path, or an anchor that is gone.
fn selected_anchor_points(s: &Session) -> Result<Option<[Point; 3]>> {
let st = s.doc()?;
if st.selection.segments.values().any(|set| !set.is_empty()) {
return Ok(None);
}
let mut points = Vec::with_capacity(4);
for id in &st.selection.objects {
let Some(pd) = st.doc.node(*id).and_then(|n| n.path_data()) else { return Ok(None) };
match st.selection.anchors.get(id) {
Some(set) => {
for &(si, ai) in set.iter().take(4) {
let Some(a) = pd.subpaths.get(si).and_then(|sp| sp.anchors.get(ai)) else { return Ok(None) };
points.push(a.p);
}
}
None => points.extend(pd.anchors().take(4).map(|(_, _, a)| a.p)),
}
if points.len() > 3 {
return Ok(None);
}
}
Ok(match points.as_slice() {
&[a, b, c] => Some([a, b, c]),
_ => None,
})
}
/// The whole-number count `p` gives for `key` (`5` or `5.0`), or `default` when it is left out or
/// null. A fraction, a negative, a non-finite or a non-number is an error rather than the default.
fn count_or(p: &Value, key: &str, default: u64, cmd: &str) -> Result<u64> {
@@ -651,7 +737,7 @@ fn arc(s: &mut Session, p: &Value) -> Result<Value> {
if s.paint.stroke.is_none() { vectorcraft_color::Paint::solid(vectorcraft_color::Color::BLACK) } else { s.paint.stroke.clone() },
s.paint.stroke_width.max(0.1),
);
insert_look_turned(s, "Arc", path_kind(path, None), look, None, true, bbox_angle)
insert_look_turned(s, "Arc", path_kind(path, None), look, None, true, bbox_angle, true)
}
/// The grid `paths` (bottom first) as one selected group in the new-art stroke, filled with the
@@ -831,7 +917,8 @@ fn text_create(s: &mut Session, p: &Value) -> Result<Value> {
// Lays the text out (and sizes an Auto Size frame).
super::typecmd::refresh_bounds(&mut t);
}
let made = insert_look_turned(s, "Type", NodeKind::Text(Box::new(t)), NewArt::plain(Appearance::default()), None, true, bbox_turn(rotation))?;
let made =
insert_look_turned(s, "Type", NodeKind::Text(Box::new(t)), NewArt::plain(Appearance::default()), None, true, bbox_turn(rotation), true)?;
let id = made.get("id").and_then(Value::as_u64).map(NodeId);
let made = super::typecmd::with_bounds(s, id, made);
let mut made = super::typecmd::with_overflow(s, id.as_slice(), made);
@@ -548,6 +548,7 @@ pub(super) const ALLOWED: &[&str] = &[
"select.toggle",
"select.update",
"shape.arc",
"shape.circleThroughPoints",
"shape.ellipse",
"shape.flare",
"shape.line",
+1
View File
@@ -24,6 +24,7 @@ mod build;
mod cancel;
mod caret_kerning;
mod charstroke;
mod circle_through;
pub(super) mod clip;
mod clipboard;
mod clipflavours;
+209
View File
@@ -0,0 +1,209 @@
//! `shape.circleThroughPoints`: a circle through three given points, or through the three anchor
//! points selected with Direct Selection, and the Ellipse tool's three Shift-clicks that run it.
use serde_json::{Value, json};
use vectorcraft_doc::{LiveShape, Node, NodeKind};
use vectorcraft_geom::Point;
use vectorcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey};
use crate::*;
const C: &str = "shape.circleThroughPoints";
fn session() -> Session {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
s
}
fn node(s: &Session, id: NodeId) -> Node {
s.doc().unwrap().doc.node(id).unwrap().clone()
}
fn undo_len(s: &Session) -> usize {
s.doc().unwrap().history.undo.len()
}
fn object_count(s: &Session) -> usize {
let mut n = 0;
s.doc().unwrap().doc.walk(|_| n += 1);
n
}
fn id_of(v: &Value) -> NodeId {
NodeId(v["id"].as_u64().unwrap())
}
/// Whether the geometric bounds of `id` are `want` to within 10⁻⁹ pt.
fn bounds_are(s: &Session, id: NodeId, want: vectorcraft_geom::Rect) -> bool {
let b = s.doc().unwrap().doc.bounds_of(&[id], false).unwrap();
[(b.x0, want.x0), (b.y0, want.y0), (b.x1, want.x1), (b.y1, want.y1)].iter().all(|(a, w)| (a - w).abs() < 1e-9)
}
/// The largest distance of `points` from the path of `id`.
fn farthest_from_path(s: &Session, id: NodeId, points: &[Point]) -> f64 {
let n = node(s, id);
let path = n.path_data().unwrap();
points.iter().map(|p| path.nearest(*p).unwrap().4).fold(0.0, f64::max)
}
/// (0, 0), (80, 0) and (0, 60) lie on the circle centered at (40, 30) with radius 50 (their
/// right angle stands on the diameter). The circle is a live ellipse with the current paint, is
/// selected, passes through the points to within the four-curve circle's error (about 0.03% of the
/// radius), and one undo removes it.
#[test]
fn the_circle_through_three_given_points_is_exact_and_one_undo_step() {
let mut s = session();
let reference = id_of(&s.execute("shape.ellipse", &json!({"x": 200, "y": 200, "width": 10, "height": 10})).unwrap());
let undo = undo_len(&s);
let points = [Point::new(0.0, 0.0), Point::new(80.0, 0.0), Point::new(0.0, 60.0)];
let out = s.execute(C, &json!({"points": [[0, 0], [80, 0], [0, 60]]})).unwrap();
assert_eq!((out["cx"].as_f64(), out["cy"].as_f64(), out["radius"].as_f64()), (Some(40.0), Some(30.0), Some(50.0)), "{out}");
let id = id_of(&out);
let n = node(&s, id);
match &n.kind {
NodeKind::Path { live: Some(live), .. } => match live.as_ref() {
LiveShape::Ellipse { w, h, pie, .. } => assert_eq!((*w, *h, *pie), (100.0, 100.0, (0.0, 360.0))),
other => panic!("not a live ellipse: {other:?}"),
},
other => panic!("not a live shape: {other:?}"),
}
assert!(bounds_are(&s, id, vectorcraft_geom::Rect::new(-10.0, -20.0, 90.0, 80.0)));
assert!(farthest_from_path(&s, id, &points) < 50.0 * 3e-4, "{}", farthest_from_path(&s, id, &points));
assert_eq!(n.appearance, node(&s, reference).appearance, "the current paint, as the Ellipse tool draws");
assert_eq!(s.doc().unwrap().selection.objects, [id]);
assert_eq!(undo_len(&s), undo + 1);
s.execute("edit.undo", &json!({})).unwrap();
assert!(s.doc().unwrap().doc.node(id).is_none());
}
/// Two points that are the same, or three on one line, are refused with a message; nothing is
/// drawn and no undo step is recorded. Points nearly on one line still give their circle.
#[test]
fn coincident_or_collinear_points_are_refused() {
let mut s = session();
let (undo, count) = (undo_len(&s), object_count(&s));
for points in [json!([[10, 10], [10, 10], [50, 80]]), json!([[0, 0], [50, 50], [100, 100]]), json!([[5, 5], [5, 5], [5, 5]])] {
let e = s.execute(C, &json!({ "points": points })).unwrap_err().to_string();
assert!(e.contains("no circle passes through these points"), "{points}: {e}");
assert_eq!((undo_len(&s), object_count(&s)), (undo, count), "{points}");
}
// 0.01 pt off a chord 200 pt long: the sagitta formula r = (h² + (L/2)²) / 2h.
let out = s.execute(C, &json!({"points": [[100, 200], [300, 200], [200, 199.99]]})).unwrap();
let want = (0.01f64 * 0.01 + 100.0 * 100.0) / 0.02;
let (cx, cy, r) = (out["cx"].as_f64().unwrap(), out["cy"].as_f64().unwrap(), out["radius"].as_f64().unwrap());
assert!((r - want).abs() / want < 1e-9 && (cx - 200.0).abs() < 1e-6 && (cy - (199.99 + want)).abs() / want < 1e-9, "{out}");
}
/// Points that are not three pairs of finite numbers are an error, not a fallback.
#[test]
fn malformed_points_are_refused() {
let mut s = session();
let undo = undo_len(&s);
for points in [
json!([[0, 0], [10, 0]]),
json!([[0, 0], [10, 0], [0, 10], [5, 5]]),
json!([[0, 0], [10, 0], [0]]),
json!([[0, 0], [10, 0], ["0", 10]]),
json!("0,0 10,0 0,10"),
json!([[0, 0], [10, 0], [0, 10, 3]]),
] {
let e = s.execute(C, &json!({ "points": points })).unwrap_err().to_string();
assert!(e.contains("`points` must be three [x, y] pairs of numbers"), "{points}: {e}");
}
assert_eq!(undo_len(&s), undo);
}
/// With `points` left out, the three anchor points selected with Direct Selection give the
/// circle, from one path or several; any other number of them is an error.
#[test]
fn three_direct_selected_anchor_points_give_the_circle() {
let mut s = session();
let anchors: Vec<Value> = [(0, 0), (80, 0), (0, 60), (50, 120)].iter().map(|(x, y)| json!({"x": x, "y": y})).collect();
let path = id_of(&s.execute("path.create", &json!({ "anchors": anchors })).unwrap());
s.execute("select.anchors", &json!({"id": path.0, "anchors": [[0, 0], [0, 1], [0, 2]], "mode": "set"})).unwrap();
let out = s.execute(C, &json!({})).unwrap();
assert_eq!((out["cx"].as_f64(), out["cy"].as_f64(), out["radius"].as_f64()), (Some(40.0), Some(30.0), Some(50.0)), "{out}");
// Anchors of two paths.
let other = id_of(&s.execute("path.create", &json!({"anchors": [{"x": 0, "y": 60}, {"x": 0, "y": 200}]})).unwrap());
s.execute("select.anchors", &json!({"id": path.0, "anchors": [[0, 0], [0, 1]], "mode": "set"})).unwrap();
s.execute("select.anchors", &json!({"id": other.0, "anchors": [[0, 0]], "mode": "add"})).unwrap();
let out = s.execute(C, &json!({"points": null})).unwrap();
assert_eq!((out["cx"].as_f64(), out["cy"].as_f64()), (Some(40.0), Some(30.0)), "{out}");
// Two or four anchors, or a path of four anchors selected whole.
for picked in [json!([[0, 0], [0, 1]]), json!([[0, 0], [0, 1], [0, 2], [0, 3]])] {
s.execute("select.anchors", &json!({"id": path.0, "anchors": picked, "mode": "set"})).unwrap();
let e = s.execute(C, &json!({})).unwrap_err().to_string();
assert!(e.contains("direct-select three anchor points, or give `points`"), "{picked}: {e}");
}
s.execute("select.set", &json!({"ids": [path.0]})).unwrap();
assert!(s.execute(C, &json!({})).is_err());
// A path of three anchors selected whole counts all three, as the other anchor commands count
// them; with an object that is not a path also selected, there is no circle.
let triangle = id_of(&s.execute("path.create", &json!({"anchors": [{"x": 0, "y": 0}, {"x": 80, "y": 0}, {"x": 0, "y": 60}]})).unwrap());
s.execute("select.set", &json!({"ids": [triangle.0]})).unwrap();
let out = s.execute(C, &json!({})).unwrap();
assert_eq!((out["cx"].as_f64(), out["cy"].as_f64(), out["radius"].as_f64()), (Some(40.0), Some(30.0), Some(50.0)), "{out}");
s.execute("edit.undo", &json!({})).unwrap();
let text = id_of(&s.execute("text.create", &json!({"x": 300, "y": 300, "text": "A"})).unwrap());
s.execute("select.set", &json!({"ids": [triangle.0, text.0]})).unwrap();
assert!(s.execute(C, &json!({})).is_err());
let undo = undo_len(&s);
// Two selected segments hold three ends, which are not selected anchor points.
s.execute("select.segments", &json!({"id": path.0, "segments": [[0, 0], [0, 1]], "mode": "set"})).unwrap();
assert_eq!(s.doc().unwrap().selection.anchors.get(&path).map(|a| a.len()), Some(3));
let e = s.execute(C, &json!({})).unwrap_err().to_string();
assert!(e.contains("direct-select three anchor points, or give `points`"), "{e}");
assert_eq!(undo_len(&s), undo);
}
/// With Align New Objects to Pixel Grid on, the circle is still drawn through the points: it is
/// not pixel-aligned, so the grid does not move it.
#[test]
fn the_circle_is_not_moved_onto_the_pixel_grid() {
let mut s = session();
s.execute("document.setup", &json!({"alignNewObjectsToPixelGrid": true})).unwrap();
let points = [Point::new(0.3, 0.2), Point::new(80.6, 0.1), Point::new(0.4, 60.7)];
let pairs: Vec<Value> = points.iter().map(|p| json!([p.x, p.y])).collect();
let id = id_of(&s.execute(C, &json!({ "points": pairs })).unwrap());
assert!(farthest_from_path(&s, id, &points) < 51.0 * 3e-4, "{}", farthest_from_path(&s, id, &points));
assert!(!node(&s, id).extras().pixel_aligned);
}
fn view() -> ViewInfo {
ViewInfo { smart_guides: false, ..ViewInfo::default() }
}
fn click(s: &mut Session, mods: Mods, x: f64, y: f64) {
for k in [PointerKind::Down, PointerKind::Up] {
s.pointer(&PointerEvent::new(k, x, y).with_mods(mods), view()).unwrap();
}
}
/// With the Ellipse tool, three Shift-clicks draw the circle through the three points, in one
/// undo step; Escape drops the points placed so far.
#[test]
fn three_shift_clicks_with_the_ellipse_tool_draw_the_circle_through_them() {
let mut s = session();
s.select_tool("ellipse", view()).unwrap();
let shift = Mods { shift: true, ..Mods::default() };
let (undo, count) = (undo_len(&s), object_count(&s));
click(&mut s, shift, 100.0, 100.0);
click(&mut s, shift, 180.0, 100.0);
assert_eq!((undo_len(&s), object_count(&s)), (undo, count), "two points draw nothing yet");
click(&mut s, shift, 100.0, 160.0);
assert_eq!(undo_len(&s), undo + 1);
let id = *s.doc().unwrap().selection.objects.first().unwrap();
assert!(bounds_are(&s, id, vectorcraft_geom::Rect::new(90.0, 80.0, 190.0, 180.0)));
// Escape after two points: the next three clicks start afresh.
click(&mut s, shift, 0.0, 0.0);
click(&mut s, shift, 10.0, 300.0);
s.tool_key(ToolKey::Escape, Mods::default(), view()).unwrap();
click(&mut s, shift, 200.0, 200.0);
click(&mut s, shift, 280.0, 200.0);
let undo = undo_len(&s);
click(&mut s, shift, 200.0, 260.0);
assert_eq!(undo_len(&s), undo + 1);
let id = *s.doc().unwrap().selection.objects.first().unwrap();
assert!(bounds_are(&s, id, vectorcraft_geom::Rect::new(190.0, 180.0, 290.0, 280.0)));
}
+68
View File
@@ -328,6 +328,33 @@ fn contour_with_rounding(pts: &[Point], rounded: f64) -> PathData {
PathData::single(SubPath::new(anchors, true))
}
/// The circle through the points `a`, `b` and `c`: its center and radius. `None` when two of the
/// points are the same or the three lie on one line, which this takes to be when twice the
/// triangle's area is at most 10⁻¹⁰ of its longest side squared.
pub fn circle_through(a: Point, b: Point, c: Point) -> Option<(Point, f64)> {
// The corner opposite the longest side is the origin, so the two shorter sides are used.
let (ab, bc, ca) = ((b - a).hypot2(), (c - b).hypot2(), (a - c).hypot2());
let (o, p, q, longest) = if bc >= ab && bc >= ca {
(a, b, c, bc)
} else if ca >= ab {
(b, c, a, ca)
} else {
(c, a, b, ab)
};
let (u, v) = (p - o, q - o);
let cross = u.cross(v);
// Not a number, or nearly zero: no circle (a not-a-number side fails the finite check below).
if cross.is_nan() || cross.abs() <= 1e-10 * longest {
return None;
}
let (uu, vv) = (u.hypot2(), v.hypot2());
let d = 2.0 * cross;
let offset = Vec2::new((v.y * uu - u.y * vv) / d, (u.x * vv - v.x * uu) / d);
let center = o + offset;
let radius = offset.hypot();
(center.is_finite() && radius.is_finite()).then_some((center, radius))
}
/// Regular polygon with `sides` (≥ 3), first vertex straight up from the centre.
pub fn polygon(center: Point, radius: f64, sides: u32, rotation_deg: f64) -> PathData {
let n = sides.max(3);
@@ -702,6 +729,47 @@ mod tests {
assert!(ellipse_pie(r, f64::NAN, 10.0).anchor_count() == 4, "not a number: the whole ellipse");
}
/// The circle through three points against the closed form: (0, 0), (8, 0) and (0, 6) lie on
/// the circle with the hypotenuse (8, 0)–(0, 6) as its diameter, center (4, 3) and radius 5.
#[test]
fn the_circle_through_three_points_has_the_closed_form_center_and_radius() {
let (o, a, b) = (Point::ORIGIN, Point::new(8.0, 0.0), Point::new(0.0, 6.0));
for (p, q, r) in [(o, a, b), (a, b, o), (b, o, a), (b, a, o)] {
let (c, radius) = circle_through(p, q, r).unwrap();
assert!(c.distance(Point::new(4.0, 3.0)) < 1e-12 && (radius - 5.0).abs() < 1e-12, "{c:?} {radius}");
}
// Moved far from the origin, the answer moves with the points.
let far = Vec2::new(3.0e6, -2.0e6);
let (c, radius) = circle_through(o + far, a + far, b + far).unwrap();
assert!(c.distance(Point::new(4.0, 3.0) + far) < 1e-6 && (radius - 5.0).abs() < 1e-6, "{c:?} {radius}");
}
/// Two points that are the same, or three on one line, give no circle.
#[test]
fn coincident_or_collinear_points_give_no_circle() {
let (a, b) = (Point::new(1.0, 2.0), Point::new(5.0, 7.0));
assert_eq!(circle_through(a, a, b), None);
assert_eq!(circle_through(a, b, b), None);
assert_eq!(circle_through(a, a, a), None);
assert_eq!(circle_through(a, b, a.midpoint(b)), None);
assert_eq!(circle_through(a, b, a + (b - a) * 3.0), None);
assert_eq!(circle_through(a, b, Point::new(f64::NAN, 0.0)), None);
}
/// Nearly on one line: a point 10⁻⁴ off a chord 2000 long still gives the circle (its sagitta
/// formula `r = (h² + (L/2)²) / 2h`), and its center sits on the chord's perpendicular
/// bisector; a point 10⁻¹² off it does not.
#[test]
fn nearly_collinear_points_give_a_stable_circle() {
let (a, b) = (Point::new(-1000.0, 0.0), Point::new(1000.0, 0.0));
let h = 1e-4;
let (c, radius) = circle_through(a, b, Point::new(0.0, h)).unwrap();
let want = (h * h + 1000.0 * 1000.0) / (2.0 * h);
assert!((radius - want).abs() / want < 1e-9, "{radius} vs {want}");
assert!(c.x.abs() < 1e-6 && (c.y - (h - want)).abs() / want < 1e-9, "{c:?}");
assert_eq!(circle_through(a, b, Point::new(0.0, 1e-12)), None);
}
#[test]
fn rect_is_4_corners_clockwise() {
let p = rectangle(Rect::new(0.0, 0.0, 100.0, 50.0));
+111 -14
View File
@@ -14,6 +14,14 @@
//! release keeps the copies and the last shape as one undo step
//! (<https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=469>).
//!
//! With the Ellipse tool, three Shift-clicks draw the circle through the three points clicked
//! (`shape.circleThroughPoints`). Once a point is placed, a Shift-click on the selection's handles
//! or widgets places a point too. Escape, a click without Shift, a drag, a press without Shift on the
//! selection or a shape widget, and an edit, Undo or Redo made outside the tool drop the points
//! placed so far.
//! While the perspective grid shows with an active plane, a Shift-click opens the size dialog, as a
//! click does, and the shape goes on the plane.
//!
//! The selection keeps its bounding box and its Live Shape widgets on show with the Rectangle,
//! Rounded Rectangle, Ellipse, Polygon and Star tools, so a shape just drawn can be adjusted at
//! once: a drag on a live rectangle's or polygon's corner widget rounds its corners and a drag on
@@ -142,6 +150,26 @@ pub struct ShapeTool {
/// While Backtick is held in a drag, the pointer position the next copy is measured from: where
/// the last copy was left, or where the drag first had the key down.
copy_from: Option<Point>,
/// Ellipse tool: the points placed by Shift-clicks so far (fewer than three); the third
/// Shift-click draws the circle through them ([`circle_through_points`]).
through: Vec<Point>,
/// Where the pointer was last seen while `through` holds points, for the circle's preview.
hover: Option<Point>,
/// The press in progress came with Shift held, with the Ellipse tool and no active perspective
/// plane: a click places a point.
places_point: bool,
}
/// Whether the perspective grid shows with an active plane: shapes then go on the plane.
fn perspective_plane_shown(cx: &ToolContext) -> bool {
let g = crate::distort::perspective::PerspectiveGrid::current(cx.doc);
g.visible && g.plane != crate::distort::perspective::Plane::None
}
/// The command three Shift-clicks with the Ellipse tool run: the circle through their points.
fn circle_through_points(points: &[Point]) -> (String, Value) {
let pairs: Vec<Value> = points.iter().map(|p| json!([p.x, p.y])).collect();
("shape.circleThroughPoints".into(), json!({ "points": pairs }))
}
/// The options that keys and Ctrl/Cmd change while a shape is dragged out.
@@ -195,11 +223,20 @@ impl ShapeTool {
guides: vec![],
measure: None,
snapped: false,
through: vec![],
hover: None,
places_point: false,
copies: vec![],
copy_from: None,
}
}
/// Whether a press with `m` places another point for a circle: Shift with the Ellipse tool once
/// a point is placed. Such a press skips the selection's handles and widgets.
fn placing_point(&self, m: Mods) -> bool {
self.id == "ellipse" && m.shift && !self.through.is_empty()
}
/// With Backtick `held` at pointer `raw`, leave a copy of the shape the drag shows (`cmd` and
/// `params`) once the pointer is [`COPY_SPACING`] screen points from the last copy, or from
/// where the key was first held. A shape with no width, height or length, one the same as the
@@ -644,24 +681,33 @@ impl Tool for ShapeTool {
match ev.kind {
PointerKind::Move => {
// Over a widget a press would drag, no Smart Guide for a new shape's start.
if self.over_widget(cx, ev.pos)
|| self.over_handle(cx, ev.pos).is_some()
|| self.over_center(cx, ev.pos)
|| self.over_rotate(cx, ev.pos).is_some()
if !self.placing_point(ev.mods)
&& (self.over_widget(cx, ev.pos)
|| self.over_handle(cx, ev.pos).is_some()
|| self.over_center(cx, ev.pos)
|| self.over_rotate(cx, ev.pos).is_some())
{
self.snap.clear();
// A press there drags the widget or the selection, which drops the points.
self.hover = None;
} else {
self.snap.hover(cx, ev.pos, &[], None);
// The snapped point: the third Shift-click lands where the press snaps.
let p = self.snap.hover(cx, ev.pos, &[], None);
self.hover = (!self.through.is_empty()).then_some(p);
}
vec![]
}
PointerKind::Down => {
if self.press_widget(cx, ev) {
self.snap.clear();
return vec![];
}
if let Some(out) = self.press_selection(cx, ev) {
return out;
if !self.placing_point(ev.mods) {
if self.press_widget(cx, ev) {
self.snap.clear();
self.through.clear();
return vec![];
}
if let Some(out) = self.press_selection(cx, ev) {
self.through.clear();
return out;
}
}
let p = self.snap.press(cx, ev.pos, &[], None);
if self.id == "lineSegment" {
@@ -673,6 +719,7 @@ impl Tool for ShapeTool {
self.start = Some(p);
self.last = ev.pos;
self.began = false;
self.places_point = self.id == "ellipse" && ev.mods.shift && !perspective_plane_shown(cx);
self.inner = None;
self.before_drag = None;
self.clear_copies();
@@ -749,8 +796,20 @@ impl Tool for ShapeTool {
self.clear_copies();
if self.began {
self.began = false;
self.through.clear();
vec![Action::Commit]
} else if self.places_point {
// A Shift-click places a point; the third draws the circle through the three.
self.through.push(s);
self.hover = None;
if self.through.len() < 3 {
return vec![];
}
let (c, v) = circle_through_points(&self.through);
self.through.clear();
vec![Action::Exec(c, v)]
} else {
self.through.clear();
// Alt (draw from centre) is passed on, so the size dialog can centre the shape on the click.
let args = if ev.mods.alt { json!({ "x": s.x, "y": s.y, "alt": true }) } else { json!({ "x": s.x, "y": s.y }) };
vec![Action::Dialog(self.id.into(), args)]
@@ -779,6 +838,17 @@ impl Tool for ShapeTool {
_ => vec![],
};
}
// Escape drops the points Shift-clicks placed for a circle; the document stays as it is. A
// press that has not begun a drag is dropped too, so its release places no point.
if key == ToolKey::Escape && !self.began && !self.through.is_empty() {
self.through.clear();
self.hover = None;
if self.start.take().is_some() {
self.places_point = false;
self.snap.clear();
}
return vec![];
}
let Some(s) = self.start.filter(|_| self.began) else { return vec![] };
let changed = match (self.id, key) {
("polygon", ToolKey::Up) => {
@@ -813,6 +883,7 @@ impl Tool for ShapeTool {
} else if key == ToolKey::Escape {
self.start = None;
self.began = false;
self.through.clear();
self.inner = None;
self.clear_copies();
if let Some(o) = self.before_drag.take() {
@@ -857,9 +928,23 @@ impl Tool for ShapeTool {
match (&self.widget, &self.selection) {
(Some(WidgetDrag::Corner(_)), _) => matches!(key, ToolKey::Up | ToolKey::Down),
(_, Some(_)) => key == ToolKey::Escape,
_ => false,
_ => key == ToolKey::Escape && !self.through.is_empty(),
}
}
/// Points placed by Shift-clicks for a circle: Escape drops them.
fn ends_on_escape(&self, _cx: &ToolContext) -> bool {
!self.through.is_empty()
}
/// The pointer left the canvas: the circle's preview through it goes.
fn hover_ended(&mut self, _cx: &ToolContext) {
self.hover = None;
}
/// An edit, Undo or Redo made outside the tool, or another document, drops the points placed
/// for a circle.
fn history_moved(&mut self) {
self.through.clear();
self.hover = None;
}
/// The widget being dragged, the Smart Guides of the shape being drawn or the selection being
/// moved, and its size, angle or offset label.
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
@@ -872,6 +957,17 @@ impl Tool for ShapeTool {
let tangent = self.tangent_line.line().filter(|_| self.start.is_some());
let mut o = if tangent.is_some() { self.tangent_line.guides(cx) } else { self.snap.guides().to_vec() };
o.extend(self.guides.iter().cloned());
// The points Shift-clicks placed, and after two of them the circle through them and the
// pointer, dashed.
for p in &self.through {
o.push(Overlay::Anchor { p: *p, color: crate::draw2::FEEDBACK, filled: true, size: 6.0 });
}
if let ([a, b], Some(h)) = (self.through.as_slice(), self.hover)
&& let Some((c, r)) = vectorcraft_geom::shapes::circle_through(*a, *b, h)
{
let path = vectorcraft_geom::shapes::ellipse(Rect::new(c.x - r, c.y - r, c.x + r, c.y + r)).to_bezpath();
o.push(Overlay::Path { path, color: crate::draw2::FEEDBACK, width: 1.0, dashed: true });
}
if let Some((p, text)) = &self.measure {
o.push(Overlay::Measure { p: *p, text: text.clone() });
}
@@ -930,8 +1026,9 @@ impl Tool for ShapeTool {
None => {}
}
// A press takes the corner and pie widgets first, then the box's handles, then the centre
// point, then the zone just outside a corner; everywhere else it draws a new shape.
if idle {
// point, then the zone just outside a corner; everywhere else it draws a new shape. A
// Shift-press that places another point for a circle skips them all.
if idle && !self.placing_point(m) {
if shows_shape_widgets(self.id) && corners::over_widget(cx, p, false) {
return Cursor::CornerRadius;
}
+206
View File
@@ -601,6 +601,212 @@ fn click_opens_dialog() {
assert_eq!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 10.0, 10.0)), vec![Action::Dialog("star".into(), json!({"x": 10.0, "y": 10.0}))]);
}
/// With the Ellipse tool, the first two Shift-clicks place points (shown as marks, and with two
/// placed, the circle through them and the pointer is previewed); the third runs the circle
/// command through the three. A Shift-click with another shape tool still opens its dialog.
#[test]
fn three_shift_clicks_with_the_ellipse_tool_run_the_circle_through_them() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
let click = |t: &mut ShapeTool, x: f64, y: f64| {
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift))
};
assert_eq!(click(&mut t, 10.0, 10.0), vec![]);
assert_eq!(click(&mut t, 90.0, 10.0), vec![]);
assert!(t.ends_on_escape(&cx) && t.claims_key(&cx, ToolKey::Escape));
t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 10.0, 70.0));
let o = t.overlays(&cx);
assert_eq!(o.iter().filter(|o| matches!(o, Overlay::Anchor { .. })).count(), 2, "{o:?}");
let preview = o.iter().find_map(|o| match o {
Overlay::Path { path, dashed: true, .. } => Some(path.clone()),
_ => None,
});
let b = vectorcraft_geom::Shape::bounding_box(&preview.expect("the circle is previewed"));
assert!(b.x0.abs() < 1e-9 && (b.y0 + 10.0).abs() < 1e-9 && (b.x1 - 100.0).abs() < 1e-9 && (b.y1 - 90.0).abs() < 1e-9, "{b:?}");
assert_eq!(
click(&mut t, 10.0, 70.0),
vec![Action::Exec("shape.circleThroughPoints".into(), json!({"points": [[10.0, 10.0], [90.0, 10.0], [10.0, 70.0]]}))]
);
assert!(!t.ends_on_escape(&cx) && t.overlays(&cx).is_empty());
// Another shape tool keeps its dialog on a Shift-click.
let mut r = ShapeTool::new("rectangle");
assert_eq!(click(&mut r, 10.0, 10.0), vec![Action::Dialog("rectangle".into(), json!({"x": 10.0, "y": 10.0}))]);
}
/// With Smart Guides on, the preview passes through the point the pointer snaps to, which is where
/// the third Shift-click lands.
#[test]
fn the_circle_preview_passes_through_the_snapped_pointer() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let cx = cx(&d, &s, &p);
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
for (x, y) in [(300.0, 0.0), (300.0, 200.0)] {
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift));
}
// Near the rectangle's corner anchor at (100, 100): the circle through (300, 0), (300, 200)
// and (100, 100) has its center at (225, 100) and radius 125.
t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 98.0, 102.0));
let preview = t.overlays(&cx).into_iter().find_map(|o| match o {
Overlay::Path { path, dashed: true, .. } => Some(path),
_ => None,
});
let b = vectorcraft_geom::Shape::bounding_box(&preview.expect("the circle is previewed"));
let want = [100.0, -25.0, 350.0, 225.0];
assert!([b.x0, b.y0, b.x1, b.y1].iter().zip(want).all(|(a, w)| (a - w).abs() < 1e-9), "{b:?}");
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 98.0, 102.0).with_mods(shift));
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 98.0, 102.0).with_mods(shift));
assert!(matches!(&a[..], [Action::Exec(_, v)] if v["points"][2] == json!([100.0, 100.0])), "{a:?}");
}
/// Escape, a plain click and a drag drop the points Shift-clicks placed, so the next Shift-click
/// starts a new circle.
#[test]
fn escape_a_click_or_a_drag_drops_the_shift_clicked_points() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
let shift_click = |t: &mut ShapeTool, x: f64, y: f64| {
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift))
};
shift_click(&mut t, 10.0, 10.0);
shift_click(&mut t, 90.0, 10.0);
assert_eq!(t.key(&cx, ToolKey::Escape, Mods::default()), vec![]);
assert!(!t.ends_on_escape(&cx));
shift_click(&mut t, 10.0, 10.0);
shift_click(&mut t, 90.0, 10.0);
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 50.0, 50.0));
assert_eq!(
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 50.0, 50.0)),
vec![Action::Dialog("ellipse".into(), json!({"x": 50.0, "y": 50.0}))]
);
assert!(!t.ends_on_escape(&cx), "a plain click drops them");
shift_click(&mut t, 10.0, 10.0);
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 50.0, 50.0).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 90.0, 90.0).with_mods(shift));
assert_eq!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 90.0, 90.0).with_mods(shift)), vec![Action::Commit]);
assert!(!t.ends_on_escape(&cx), "a Shift-drag draws a circle and drops them");
// A move of the selection by its centre point drops them too.
let (d, s) = unfilled_live_rect();
let c = ToolContext { smart_guides: false, ..crate::testutil::cx(&d, &s, &p) };
let mut t = ShapeTool::new("ellipse");
for (x, y) in [(10.0, 10.0), (90.0, 10.0)] {
t.pointer(&c, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&c, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift));
}
assert!(t.ends_on_escape(&c));
t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 150.0));
t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 170.0, 160.0));
assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 170.0, 160.0)), vec![Action::Commit]);
assert!(!t.ends_on_escape(&c), "a move of the selection drops them");
}
/// Escape pressed while the third Shift-click is held drops the points and the press, so the
/// release draws no circle.
#[test]
fn escape_during_the_third_shift_click_drops_the_points_and_the_press() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
for (x, y) in [(10.0, 10.0), (90.0, 10.0)] {
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift));
}
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 10.0, 70.0).with_mods(shift));
assert!(t.claims_key(&cx, ToolKey::Escape));
assert_eq!(t.key(&cx, ToolKey::Escape, shift), vec![]);
assert!(!t.ends_on_escape(&cx) && t.overlays(&cx).is_empty());
assert_eq!(t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 10.0, 70.0).with_mods(shift)), vec![]);
assert!(!t.ends_on_escape(&cx), "the release places no point");
}
/// Once a point is placed, a Shift-click on the selection's side handle or centre point places a
/// point instead of scaling or moving the selection, and the cursor over them is the crosshair.
#[test]
fn shift_clicks_on_the_selection_place_points_once_one_is_placed() {
let (d, s) = unfilled_live_rect();
let p = paint();
let c = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
let centre = Point::new(150.0, 150.0);
assert_eq!(t.cursor(&c, centre, shift), Cursor::Move, "no point placed yet: the centre point moves");
let click = |t: &mut ShapeTool, x: f64, y: f64| {
t.pointer(&c, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&c, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift))
};
assert_eq!(click(&mut t, 10.0, 10.0), vec![]);
assert_eq!(t.cursor(&c, centre, shift), Cursor::Crosshair);
assert_eq!(t.cursor(&c, centre, Mods::default()), Cursor::Move, "without Shift a press still moves the selection");
assert_eq!(click(&mut t, 100.0, 150.0), vec![], "the left side handle");
assert!(!t.busy());
assert_eq!(
click(&mut t, centre.x, centre.y),
vec![Action::Exec("shape.circleThroughPoints".into(), json!({"points": [[10.0, 10.0], [100.0, 150.0], [150.0, 150.0]]}))]
);
}
/// The pointer leaving the canvas removes the circle's preview, and an edit, Undo or Redo made
/// outside the tool drops the points placed so far.
#[test]
fn leaving_the_canvas_or_an_outside_edit_clears_the_circle_in_progress() {
let (d, _) = doc_with_rect();
let s = Selection::default();
let p = paint();
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
let click = |t: &mut ShapeTool, x: f64, y: f64| {
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, x, y).with_mods(shift));
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, x, y).with_mods(shift))
};
let dashed = |t: &ShapeTool| t.overlays(&cx).iter().any(|o| matches!(o, Overlay::Path { dashed: true, .. }));
click(&mut t, 10.0, 10.0);
click(&mut t, 90.0, 10.0);
t.pointer(&cx, &PointerEvent::new(PointerKind::Move, 10.0, 70.0));
assert!(dashed(&t));
t.hover_ended(&cx);
assert!(!dashed(&t), "no preview through a pointer off the canvas");
assert!(t.ends_on_escape(&cx), "the points stay");
t.history_moved();
assert!(!t.ends_on_escape(&cx) && t.overlays(&cx).is_empty());
assert_eq!(click(&mut t, 10.0, 70.0), vec![], "the next Shift-click starts a new circle");
}
/// While the perspective grid shows with an active plane, a Shift-click with the Ellipse tool opens
/// the size dialog, whose shape goes on the plane, as before.
#[test]
fn a_shift_click_on_an_active_perspective_plane_opens_the_dialog() {
let (mut d, _) = doc_with_rect();
crate::distort::perspective::PerspectiveGrid::preset(2, Rect::new(0.0, 0.0, 612.0, 792.0)).store(&mut d);
let s = Selection::default();
let p = paint();
let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) };
let shift = Mods { shift: true, ..Default::default() };
let mut t = ShapeTool::new("ellipse");
t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 10.0, 10.0).with_mods(shift));
assert_eq!(
t.pointer(&cx, &PointerEvent::new(PointerKind::Up, 10.0, 10.0).with_mods(shift)),
vec![Action::Dialog("ellipse".into(), json!({"x": 10.0, "y": 10.0}))]
);
assert!(!t.ends_on_escape(&cx));
}
#[test]
fn alt_click_passes_draw_from_centre_to_the_dialog() {
let (d, _) = doc_with_rect();
+3
View File
@@ -6056,6 +6056,9 @@ liquify-list-end {0}, {1} {0} i {1}
@msg no active document no hi ha cap document actiu
@msg no active perspective plane no hi ha cap pla de perspectiva actiu
@msg no anchor points selected no hi ha cap punt d’ancoratge seleccionat
@msg `points` must be three [x, y] pairs of numbers `points` han de ser tres parells de nombres [x, y]
@msg direct-select three anchor points, or give `points` seleccioneu directament tres punts d’ancoratge o indiqueu `points`
@msg no circle passes through these points: two are the same or all three lie on one line cap cercle no passa per aquests punts: dos són iguals o tots tres són en una mateixa recta
@msg no app to open files here aquí no hi ha cap aplicació per obrir fitxers
@msg no artboard no hi ha tauler
@msg no artboard {i} (0-based; the document has {_1}) no hi ha el tauler {i} (basat en 0; el document en té {_1})
Can't render this file because it contains an unexpected character in line 2 and column 73.
+3
View File
@@ -5216,6 +5216,9 @@ liquify-list-end {0}, {1} {0} a {1}
@msg no active document žádný aktivní dokument
@msg no active perspective plane žádná aktivní perspektivní rovina
@msg no anchor points selected nejsou vybrány žádné kotevní body
@msg `points` must be three [x, y] pairs of numbers `points` musí být tři dvojice čísel [x, y]
@msg direct-select three anchor points, or give `points` vyberte přímým výběrem tři kotevní body, nebo zadejte `points`
@msg no circle passes through these points: two are the same or all three lie on one line těmito body neprochází žádná kružnice: dva jsou stejné nebo všechny tři leží na jedné přímce
@msg no app to open files here zde chybí aplikace pro otevírání souborů
@msg no artboard žádná pracovní plocha
@msg no artboard {i} (0-based; the document has {_1}) pracovní plocha {i} neexistuje (číslováno od 0; dokument jich má {_1})
Can't render this file because it is too large.
+3
View File
@@ -7399,6 +7399,9 @@ imageTrace Outline Kontur
@msg no active document intet aktivt dokument
@msg no active perspective plane intet aktivt perspektivplan
@msg no anchor points selected ingen ankerpunkter er markeret
@msg `points` must be three [x, y] pairs of numbers `points` skal være tre talpar [x, y]
@msg direct-select three anchor points, or give `points` direkte markér tre ankerpunkter, eller angiv `points`
@msg no circle passes through these points: two are the same or all three lie on one line ingen cirkel går gennem disse punkter: to er ens, eller alle tre ligger på én linje
@msg no app to open files here ingen app til at åbne filer her
@msg no artboard ingen tegneflade
@msg no artboard {i} (0-based; the document has {_1}) ingen tegneflade {i} (0-baseret; dokumentet har {_1})
Can't render this file because it is too large.
+3
View File
@@ -4815,6 +4815,9 @@ liquify-list-end {0}, {1} {0} und {1}
@msg no active document kein aktives Dokument
@msg no active perspective plane keine aktive Perspektivebene
@msg no anchor points selected keine Ankerpunkte ausgewählt
@msg `points` must be three [x, y] pairs of numbers `points` muss aus drei Zahlenpaaren [x, y] bestehen
@msg direct-select three anchor points, or give `points` wählen Sie drei Ankerpunkte direkt aus oder geben Sie `points` an
@msg no circle passes through these points: two are the same or all three lie on one line durch diese Punkte verläuft kein Kreis: zwei sind gleich oder alle drei liegen auf einer Linie
@msg no app to open files here hier gibt es keine App zum Öffnen von Dateien
@msg no artboard keine Zeichenfläche
@msg no artboard {i} (0-based; the document has {_1}) keine Zeichenfläche {i} (Zählung ab 0; das Dokument hat {_1})
Can't render this file because it is too large.
+3
View File
@@ -4875,6 +4875,9 @@ digits Malayalam Μαλαγιάλαμ
@msg no active document δεν υπάρχει ενεργό έγγραφο
@msg no active perspective plane δεν υπάρχει ενεργό επίπεδο προοπτικής
@msg no anchor points selected δεν έχουν επιλεγεί σημεία αγκύρωσης
@msg `points` must be three [x, y] pairs of numbers το `points` πρέπει να είναι τρία ζεύγη αριθμών [x, y]
@msg direct-select three anchor points, or give `points` επιλέξτε άμεσα τρία σημεία αγκύρωσης ή δώστε `points`
@msg no circle passes through these points: two are the same or all three lie on one line κανένας κύκλος δεν περνά από αυτά τα σημεία: δύο είναι ίδια ή και τα τρία βρίσκονται σε μία ευθεία
@msg no app to open files here δεν υπάρχει εφαρμογή για άνοιγμα αρχείων εδώ
@msg no artboard δεν υπάρχει πίνακας σχεδίασης
@msg no artboard {i} (0-based; the document has {_1}) δεν υπάρχει πίνακας σχεδίασης {i} (αρίθμηση από 0· το έγγραφο περιέχει {_1})
Can't render this file because it is too large.
+3
View File
@@ -4921,6 +4921,9 @@ liquify-list-end {0}, {1} {0}, {1}
@msg no active document no hay ningún documento activo
@msg no active perspective plane no hay ningún plano de perspectiva activo
@msg no anchor points selected no hay puntos de ancla seleccionados
@msg `points` must be three [x, y] pairs of numbers `points` debe ser tres pares de números [x, y]
@msg direct-select three anchor points, or give `points` seleccione directamente tres puntos de ancla o indique `points`
@msg no circle passes through these points: two are the same or all three lie on one line ningún círculo pasa por estos puntos: dos son iguales o los tres están en una misma línea
@msg no app to open files here aquí no hay ninguna aplicación para abrir archivos
@msg no artboard no hay mesa de trabajo
@msg no artboard {i} (0-based; the document has {_1}) no existe la mesa de trabajo {i} (contando desde 0; el documento tiene {_1})
Can't render this file because it contains an unexpected character in line 2 and column 73.
+3
View File
@@ -5145,6 +5145,9 @@ liquify-list-end {0}, {1} {0} ja {1}
@msg no active document ei aktiivista asiakirjaa
@msg no active perspective plane ei aktiivista perspektiivitasoa
@msg no anchor points selected ankkuripisteitä ei ole valittu
@msg `points` must be three [x, y] pairs of numbers `points` on annettava kolmena lukuparina [x, y]
@msg direct-select three anchor points, or give `points` valitse suoraan kolme ankkuripistettä tai anna `points`
@msg no circle passes through these points: two are the same or all three lie on one line näiden pisteiden kautta ei kulje ympyrää: kaksi pisteistä on samoja tai kaikki kolme ovat samalla suoralla
@msg no app to open files here täällä ei ole sovellusta tiedostojen avaamiseen
@msg no artboard ei piirtoalustaa
@msg no artboard {i} (0-based; the document has {_1}) ei piirtoalustaa {i} (0-pohjainen; asiakirjassa on {_1})
Can't render this file because it contains an unexpected character in line 2 and column 73.
+3
View File
@@ -4883,6 +4883,9 @@ liquify-list-end {0}, {1} {0} et {1}
@msg no active document aucun document actif
@msg no active perspective plane aucun plan de perspective actif
@msg no anchor points selected aucun point d’ancrage sélectionné
@msg `points` must be three [x, y] pairs of numbers `points` doit contenir trois paires de nombres [x, y]
@msg direct-select three anchor points, or give `points` sélectionnez trois points d’ancrage avec l’outil Sélection directe, ou indiquez `points`
@msg no circle passes through these points: two are the same or all three lie on one line aucun cercle ne passe par ces points : deux sont identiques ou les trois sont alignés
@msg no app to open files here aucune application pour ouvrir des fichiers ici
@msg no artboard aucun plan de travail
@msg no artboard {i} (0-based; the document has {_1}) aucun plan de travail {i} (numérotation à partir de 0 ; le document en a {_1})
Can't render this file because it is too large.
+3
View File
@@ -7539,6 +7539,9 @@ liquify-list-end {0}, {1} {0} और {1}
@msg no active document कोई सक्रिय डॉक्यूमेंट
@msg no active perspective plane कोई सक्रिय पर्सपेक्टिव विमान नहीं
@msg no anchor points selected कोई एंकर पॉइंट सिलेक्ट नहीं है
@msg `points` must be three [x, y] pairs of numbers `points` में संख्याओं के तीन [x, y] जोड़े होने चाहिए
@msg direct-select three anchor points, or give `points` तीन एंकर पॉइंट्स डायरेक्ट-सिलेक्ट करें, या `points` दें
@msg no circle passes through these points: two are the same or all three lie on one line इन पॉइंट्स से होकर कोई वृत्त नहीं गुज़रता: दो एक जैसे हैं या तीनों एक ही रेखा पर हैं
@msg no app to open files here यहां फ़ाइलों को ओपन करने के लिए कोई ऐप नहीं है
@msg no appearance item {index} कोई उपस्थिति आइटम {index}
@msg no artboard कोई आर्टबोर्ड नहीं
Can't render this file because it is too large.
+3
View File
@@ -5589,6 +5589,9 @@ liquify-list-end {0}, {1} {0} és {1}
@msg no active document nincs aktív dokumentum
@msg no active perspective plane nincs aktív perspektivikus sík
@msg no anchor points selected nincs kijelölt horgonypont
@msg `points` must be three [x, y] pairs of numbers a `points` három [x, y] számpár legyen
@msg direct-select three anchor points, or give `points` jelölj ki közvetlen kijelöléssel három horgonypontot, vagy add meg a `points` értéket
@msg no circle passes through these points: two are the same or all three lie on one line ezeken a pontokon nem halad át kör: kettő egybeesik, vagy mindhárom egy egyenesen van
@msg no app to open files here itt nincs fájlmegnyitó alkalmazás
@msg no artboard nincs rajztábla
@msg no artboard {i} (0-based; the document has {_1}) nincs ilyen sorszámú rajztábla: {i} (0-tól számozva; a dokumentumban ennyi van: {_1})
Can't render this file because it is too large.
+3
View File
@@ -4949,6 +4949,9 @@ liquify-list-end {0}, {1} {0} e {1}
@msg no active document nessun documento attivo
@msg no active perspective plane nessun piano prospettico attivo
@msg no anchor points selected nessun punto di ancoraggio selezionato
@msg `points` must be three [x, y] pairs of numbers `points` deve essere composto da tre coppie di numeri [x, y]
@msg direct-select three anchor points, or give `points` seleziona con Selezione diretta tre punti di ancoraggio oppure indica `points`
@msg no circle passes through these points: two are the same or all three lie on one line nessun cerchio passa per questi punti: due coincidono oppure tutti e tre sono allineati
@msg no app to open files here nessuna app per aprire file qui
@msg no artboard nessuna tavola da disegno
@msg no artboard {i} (0-based; the document has {_1}) nessuna tavola da disegno {i} (a partire da 0; il documento ne ha {_1})
Can't render this file because it is too large.
+3
View File
@@ -4748,6 +4748,9 @@ swatch Bright Violet ビビッドバイオレット
@msg image would be too large; lower the resolution 画像が大きくなりすぎるため、解像度を下げてください
@msg clipboard is empty クリップボードが空です
@msg no anchor points selected アンカーポイントが選択されていません
@msg `points` must be three [x, y] pairs of numbers `points` は 3 組の数値 [x, y] にしてください
@msg direct-select three anchor points, or give `points` アンカーポイントを 3 つダイレクト選択するか、`points` を指定してください
@msg no circle passes through these points: two are the same or all three lie on one line これらの点を通る円はありません: 2 つの点が同じか、3 点すべてが一直線上にあります
@msg select at least two objects オブジェクトを 2 つ以上選択してください
@msg exit isolation mode first 先に分離モードを終了してください
@msg no saved presets 保存したプリセットはありません
Can't render this file because it is too large.
+3
View File
@@ -6731,6 +6731,9 @@ font-technology Variable ცვლადი
@msg no active document აქტიური დოკუმენტი არ არის
@msg no active perspective plane აქტიური პერსპექტივის სიბრტყე არ არის
@msg no anchor points selected საყრდენი წერტილები მონიშნული არ არის
@msg `points` must be three [x, y] pairs of numbers `points` უნდა იყოს რიცხვების სამი [x, y] წყვილი
@msg direct-select three anchor points, or give `points` პირდაპირი მონიშვნით მონიშნეთ სამი საყრდენი წერტილი ან მიუთითეთ `points`
@msg no circle passes through these points: two are the same or all three lie on one line ამ წერტილებზე წრეწირი არ გადის: ორი ერთნაირია ან სამივე ერთ წრფეზე მდებარეობს
@msg no app to open files here აქ ფაილების გასახსნელი აპი არ არის
@msg no artboard სამუშაო დაფა არ არის
@msg no artboard {i} (0-based; the document has {_1}) სამუშაო დაფა {i} არ არსებობს (0-დან ითვლება; დოკუმენტს აქვს {_1})
Can't render this file because it is too large.
+3
View File
@@ -4675,6 +4675,9 @@ theme Appearance 외관
@msg image would be too large; lower the resolution 이미지가 너무 커집니다. 해상도를 낮추세요
@msg clipboard is empty 클립보드가 비어 있습니다
@msg no anchor points selected 선택한 앵커 포인트가 없습니다
@msg `points` must be three [x, y] pairs of numbers `points`는 숫자 쌍 [x, y] 세 개여야 합니다
@msg direct-select three anchor points, or give `points` 앵커 포인트 세 개를 직접 선택하거나 `points`를 지정하세요
@msg no circle passes through these points: two are the same or all three lie on one line 이 점들을 지나는 원이 없습니다: 두 점이 같거나 세 점이 모두 한 직선 위에 있습니다
@msg select at least two objects 개체를 두 개 이상 선택하세요
@msg exit isolation mode first 먼저 격리 모드를 종료하세요
@msg no saved presets 저장된 프리셋이 없습니다
Can't render this file because it is too large.
+3
View File
@@ -5273,6 +5273,9 @@ imageTrace Outline Contour
@msg no active document geen actief document
@msg no active perspective plane geen actief perspectiefvlak
@msg no anchor points selected geen ankerpunten geselecteerd
@msg `points` must be three [x, y] pairs of numbers `points` moet uit drie getallenparen [x, y] bestaan
@msg direct-select three anchor points, or give `points` selecteer met directe selectie drie ankerpunten of geef `points` op
@msg no circle passes through these points: two are the same or all three lie on one line er gaat geen cirkel door deze punten: twee zijn gelijk of alle drie liggen op één lijn
@msg no app to open files here hier is geen app om bestanden mee te openen
@msg no artboard geen tekengebied
@msg no artboard {i} (0-based; the document has {_1}) geen tekengebied {i} (vanaf 0; het document heeft er {_1})
Can't render this file because it is too large.
+3
View File
@@ -5039,6 +5039,9 @@ liquify-list-end {0}, {1} {0} i {1}
@msg no active document brak aktywnego dokumentu
@msg no active perspective plane brak aktywnej płaszczyzny perspektywy
@msg no anchor points selected nie zaznaczono punktów kontrolnych
@msg `points` must be three [x, y] pairs of numbers `points` musi zawierać trzy pary liczb [x, y]
@msg direct-select three anchor points, or give `points` zaznacz bezpośrednio trzy punkty kontrolne lub podaj `points`
@msg no circle passes through these points: two are the same or all three lie on one line przez te punkty nie przechodzi żaden okrąg: dwa są takie same albo wszystkie trzy leżą na jednej prostej
@msg no app to open files here brak aplikacji do otwierania plików
@msg no artboard brak obszaru kompozycji
@msg no artboard {i} (0-based; the document has {_1}) brak obszaru kompozycji {i} (numeracja od 0; dokument ma {_1})
Can't render this file because it is too large.
+3
View File
@@ -4225,6 +4225,9 @@ axis Both Ambos
@msg no active document nenhum documento ativo
@msg no active perspective plane nenhum plano de perspectiva ativo
@msg no anchor points selected nenhum ponto de ancoragem selecionado
@msg `points` must be three [x, y] pairs of numbers `points` deve ter três pares de números [x, y]
@msg direct-select three anchor points, or give `points` selecione diretamente três pontos de ancoragem ou informe `points`
@msg no circle passes through these points: two are the same or all three lie on one line nenhum círculo passa por esses pontos: dois são iguais ou os três estão na mesma reta
@msg no app to open files here nenhum aplicativo para abrir arquivos aqui
@msg no artboard nenhuma prancheta
@msg no artboard {i} (0-based; the document has {_1}) nenhuma prancheta {i} (base 0; o documento tem {_1})
Can't render this file because it is too large.
+3
View File
@@ -4945,6 +4945,9 @@ liquify-list-end {0}, {1} {0} и {1}
@msg no active document нет активного документа
@msg no active perspective plane нет активной плоскости перспективы
@msg no anchor points selected опорные точки не выделены
@msg `points` must be three [x, y] pairs of numbers `points` должен содержать три пары чисел [x, y]
@msg direct-select three anchor points, or give `points` выделите прямым выделением три опорные точки или задайте `points`
@msg no circle passes through these points: two are the same or all three lie on one line через эти точки не проходит ни одна окружность: две точки совпадают или все три лежат на одной прямой
@msg no app to open files here здесь нет приложения для открытия файлов
@msg no artboard нет монтажной области
@msg no artboard {i} (0-based; the document has {_1}) нет монтажной области {i} (счёт с 0; в документе {_1})
Can't render this file because it is too large.
+3
View File
@@ -4818,6 +4818,9 @@ liquify-list-end {0}, {1} {0} och {1}
@msg no active document inget aktivt dokument
@msg no active perspective plane inget aktivt perspektivplan
@msg no anchor points selected inga ankarpunkter är markerade
@msg `points` must be three [x, y] pairs of numbers `points` måste vara tre talpar [x, y]
@msg direct-select three anchor points, or give `points` direktmarkera tre ankarpunkter eller ange `points`
@msg no circle passes through these points: two are the same or all three lie on one line ingen cirkel går genom de här punkterna: två är samma punkt eller så ligger alla tre på en linje
@msg no app to open files here det finns ingen app för att öppna filer här
@msg no artboard ingen rityta
@msg no artboard {i} (0-based; the document has {_1}) ingen rityta {i} (räknat från 0; dokumentet har {_1})
Can't render this file because it is too large.
+3
View File
@@ -4638,6 +4638,9 @@ liquify-list-end {0}, {1} {0} ve {1}
@msg no active document etkin belge yok
@msg no active perspective plane aktif perspektif düzlemi yok
@msg no anchor points selected bağlantı noktası seçilmedi
@msg `points` must be three [x, y] pairs of numbers `points` üç [x, y] sayı çifti olmalıdır
@msg direct-select three anchor points, or give `points` üç bağlantı noktasını doğrudan seçin veya `points` verin
@msg no circle passes through these points: two are the same or all three lie on one line bu noktalardan geçen bir çember yok: ikisi aynı ya da üçü de aynı doğru üzerinde
@msg no app to open files here burada dosyaları açacak uygulama yok
@msg no artboard çalışma yüzeyi yok
@msg no artboard {i} (0-based; the document has {_1}) çalışma yüzeyi yok {i} (0 tabanlı; belgede {_1} var)
Can't render this file because it is too large.
+3
View File
@@ -4933,6 +4933,9 @@ liquify-list-end {0}, {1} {0} і {1}
@msg no active document немає активного документа
@msg no active perspective plane немає активної площини перспективи
@msg no anchor points selected опорні точки не виділені
@msg `points` must be three [x, y] pairs of numbers `points` має містити три пари чисел [x, y]
@msg direct-select three anchor points, or give `points` виділіть три опорні точки прямим виділенням або задайте `points`
@msg no circle passes through these points: two are the same or all three lie on one line через ці точки не проходить жодне коло: дві точки збігаються або всі три лежать на одній прямій
@msg no app to open files here тут немає програми для відкриття файлів
@msg no artboard немає монтажної області
@msg no artboard {i} (0-based; the document has {_1}) немає монтажної області {i} (рахунок з 0; у документі {_1})
Can't render this file because it is too large.
+3
View File
@@ -5270,6 +5270,9 @@ liquify-list-end {0}, {1} {0} và {1}
@msg no active document không có tài liệu đang hoạt động
@msg no active perspective plane không có mặt phẳng phối cảnh đang hoạt động
@msg no anchor points selected chưa chọn điểm neo
@msg `points` must be three [x, y] pairs of numbers `points` phải là ba cặp số [x, y]
@msg direct-select three anchor points, or give `points` hãy chọn trực tiếp ba điểm neo hoặc cung cấp `points`
@msg no circle passes through these points: two are the same or all three lie on one line không có đường tròn nào đi qua các điểm này: hai điểm trùng nhau hoặc cả ba điểm thẳng hàng
@msg no app to open files here không có ứng dụng để mở tệp ở đây
@msg no artboard không có bảng vẽ
@msg no artboard {i} (0-based; the document has {_1}) không có bảng vẽ {i} (bắt đầu từ 0; tài liệu có {_1})
Can't render this file because it contains an unexpected character in line 205 and column 5.
+3
View File
@@ -4446,6 +4446,9 @@ imageTrace Outline 轮廓
@msg image would be too large; lower the resolution 图像将过大;请降低分辨率
@msg clipboard is empty 剪贴板为空
@msg no anchor points selected 未选择锚点
@msg `points` must be three [x, y] pairs of numbers `points` 必须是三对数字 [x, y]
@msg direct-select three anchor points, or give `points` 请直接选择三个锚点,或提供 `points`
@msg no circle passes through these points: two are the same or all three lie on one line 没有圆经过这些点:有两点相同,或三点共线
@msg select at least two objects 请至少选择两个对象
@msg exit isolation mode first 请先退出隔离模式
@msg no saved presets 没有已保存的预设
Can't render this file because it is too large.
+3
View File
@@ -2066,6 +2066,9 @@ file-filter Templates 範本
@msg image would be too large; lower the resolution 影像會過大;請降低解析度
@msg clipboard is empty 剪貼簿是空的
@msg no anchor points selected 未選取錨點
@msg `points` must be three [x, y] pairs of numbers `points` 必須是三組數字 [x, y]
@msg direct-select three anchor points, or give `points` 請以直接選取方式選取三個錨點,或提供 `points`
@msg no circle passes through these points: two are the same or all three lie on one line 沒有圓通過這些點:有兩點相同,或三點共線
@msg select at least two objects 請選取至少兩個物件
@msg exit isolation mode first 請先結束隔離模式
@msg no saved presets 沒有已儲存的預設集
Can't render this file because it is too large.
+23
View File
@@ -6136,6 +6136,29 @@ slider (`ui.menuDialog {command: "object.path.smooth"}`, dialog `smoothSlider` w
Auto-Smooth level, and the slider previews the result until `ui.dialog.confirm`; `ui.smoothAuto` moves the open
slider back to the Auto-Smooth level.
## Circle through three points
`shape.circleThroughPoints {points?: [[x, y], [x, y], [x, y]]}` draws the circle whose edge passes through three
points, as a live ellipse with the current paint, and selects it. Without `points`, it uses the three selected anchor
points, from one path or several: anchor points selected with Direct Selection, or all the anchor points of a path
selected whole, such as a triangle. The ends of selected segments do not count. The result is `{id, cx, cy, radius}`,
and one undo removes the circle. The circle is not pixel-aligned, even while the document's
[Align New Objects to Pixel Grid](#align-new-objects-to-pixel-grid) is on, so it stays through the points. The command
returns an error and draws nothing when two points are the same or the three lie on one line (twice the triangle's area
at most 10⁻¹⁰ of its longest side squared), when `points` is not three pairs of numbers, and when `points` is left out
and the selection does not hold exactly three anchor points of paths.
With the Ellipse tool, the first two Shift-clicks place points, and the third draws the circle through the three with
this command. After two points the tool previews the circle through them and the pointer as a dashed outline. Once a
point is placed, a Shift-click on the selection's handles, center point or shape widgets places a point too. Escape, a
click without Shift, a drag, a press without Shift on the selection or a shape widget, and an edit, Undo or Redo made
outside the tool remove the points placed so far. A Shift-drag still draws a circle from corner to corner. While the
perspective grid shows with an active plane, a Shift-click opens the size dialog, as a click does.
```json
{"name":"run_command","arguments":{"command":"shape.circleThroughPoints","params":{"points":[[0,0],[80,0],[0,60]]}}}
```
## Editing a path with the Curvature tool
The Curvature tool edits any selected path, whatever drew it, keeping its shape except where edited (#798). Each edit