diff --git a/ROADMAP.md b/ROADMAP.md index 7ad95b59da..4336c13037 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -146,6 +146,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap - 2026-11-01: Document Tools, a built-in add-on (Object › Plug-ins › Document Tools), starts with Save a Timestamped Copy: a copy of the document named `_YYYY-MM-DD_HH-MM` (UTC; `-2`, `-3`… when that name is taken) goes next to it, or into a folder picked for a document never saved, written as File › Save a Copy writes it, so the document keeps its path, title and modified state. Off on the web, which has no clock. A VectorCraft addition: headline numbers unchanged. - 2026-11-01: Divide into Dashes joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the selected paths, or only their direct-selected segments, are cut into separate open paths of a dash length measured along the curve, with an optional gap (left empty, or kept as pieces), each keeping the path's appearance; Fit to Corners and Ends stretches or squeezes the lengths so every run starts and ends on a dash. A dialog with Preview, one undo step, at most 100000 pieces. A VectorCraft addition: headline numbers unchanged. - 2026-11-15: Common Tangents in the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the straight lines that touch two selected convex closed paths (ellipses at any rotation and scale, or convex Bézier paths) without crossing either are added as open paths with the current stroke: external, internal or all, and the line joining the centers if asked; a path inside the other has none unless the two touch, and a message says why; a dialog with Preview, one undo step (`addon.pathtools.commonTangents`, #7845). A VectorCraft addition: headline numbers unchanged. +- 2026-11-15: With Smart Guides and Snap to Tangent on, a Line Segment drag pressed on one convex curved path and dragged near another lands on a common tangent of the two: both ends move to where the line touches the paths, each labeled "tangent" (#7845). A VectorCraft addition: headline numbers unchanged. - 2026-11-03: Text Tweaker, the first tool of the Type Tools add-on (Object › Plug-ins › Type Tools): one character attribute (size, baseline shift, rotation, horizontal or vertical scale, tracking, leading or stroke weight) goes letter by letter from a start value to an end value along a straight ramp, an ease, a bow, a spike or at random with a seed, set as the Character panel sets it, while the text stays live; a dialog with Preview, one undo step (`addon.type.textTweaker`, #4924). A VectorCraft addition: headline numbers unchanged. - 2026-11-01: Group Overlapping Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects whose visual bounds overlap or touch, chains included, go into one group each, within their own layer or group, at the stacking place of their frontmost member; objects that overlap nothing stay as they are. One undo step, a sweep along x so thousands of loose pieces group quickly (at most 20000 objects). A VectorCraft addition: headline numbers unchanged. - 2026-10-31: Export for Screens works as the reference app's dialog: Artboards and Assets tabs with a grid or list of thumbnails, Clear Selection and Prefix, Create Sub-folders by Scale or Format (on by default), Export PDFs As Single File (the chosen artboards as one PDF's pages, `pdfs: "single"`) or Multiple Files, iOS and Android rows, format presets in a ☰ menu, and a count of the files the export writes (#4895). About 55 community PRs and fixes landed the same day: Find Font, Replace Font, Outline Stroke and Expand leave hidden and locked art alone (with a warning); DXF export writes LINE and ELLIPSE entities and outlines only the strokes a CAD line can't draw; Blob Brush Angle and Roundness; Shift-constrained Perspective Selection; Grid Repeat Options Preview; a gradient mesh from a file budgeted at about a million quads; width-profile strokes keep their shape zoomed out; `.ai`/EPS import fidelity (area type, envelopes, transparency in dictionaries, character styles); PDF import finds hyphenated and CMap-suffixed font names; Windows renders follow the process's core affinity; Enter or Escape in a floating panel's field no longer reaches the canvas (#4803); Properties shows Blend Options for any selected blend (#4817); Artwork Cleanup finds doubled type (#4835) and joins stacked lines into one object (Join Point Text, #4826). Headline numbers unchanged. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 1b420d7805..91aea0b140 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -196,6 +196,7 @@ mod symbol_nine_slice; mod symbolbounds; mod symboledit; mod symbollib; +mod tangent_line; mod targeting; mod textcombos; mod textedit; diff --git a/crates/engine/src/tests/tangent_line.rs b/crates/engine/src/tests/tangent_line.rs new file mode 100644 index 0000000000..78511d766b --- /dev/null +++ b/crates/engine/src/tests/tangent_line.rs @@ -0,0 +1,40 @@ +//! Snap to Tangent with the Line Segment tool: a line dragged from one circle to another lands on +//! their common tangent, drawn by `shape.line` as one undo step. + +use serde_json::json; +use vectorcraft_doc::NodeKind; +use vectorcraft_geom::{Point, Vec2}; +use vectorcraft_tools::{PointerEvent, PointerKind}; + +use crate::*; + +use PointerKind::{Down, Drag, Up}; + +#[test] +fn a_line_segment_drag_draws_the_common_tangent_as_one_undo_step() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 500, "height": 500})).unwrap(); + s.execute("shape.ellipse", &json!({"x": 60, "y": 210, "width": 80, "height": 80})).unwrap(); + s.execute("shape.ellipse", &json!({"x": 240, "y": 190, "width": 120, "height": 120})).unwrap(); + s.execute("select.none", &json!({})).unwrap(); + let count = |s: &Session| s.doc().unwrap().doc.layers[0].children().map_or(0, |c| c.len()); + assert_eq!(count(&s), 2); + // Circles about (100, 250), radius 40, and (300, 250), radius 60: the outer tangent above them + // has the normal (-0.1, -√0.99) and touches them at center + radius × normal. + let n = Vec2::new(-0.1, -(0.99f64).sqrt()); + let (on_a, on_b) = (Point::new(100.0, 250.0) + n * 40.0, Point::new(300.0, 250.0) + n * 60.0); + s.select_tool("lineSegment", ViewInfo::default()).unwrap(); + let to = on_b + Vec2::new(0.5, 0.7); + for (k, x, y) in [(Down, 100.0, 210.0), (Drag, 200.0, 200.0), (Drag, to.x, to.y), (Up, to.x, to.y)] { + s.pointer(&PointerEvent::new(k, x, y), ViewInfo::default()).unwrap(); + } + assert_eq!(count(&s), 3); + let id = *s.doc().unwrap().selection.objects.first().unwrap(); + let NodeKind::Path { path, .. } = &s.doc().unwrap().doc.node(id).unwrap().kind else { panic!("a path") }; + let ends: Vec = path.subpaths[0].anchors.iter().map(|a| a.p).collect(); + assert_eq!(ends.len(), 2); + // Within what the drawn circles' 0.03% radius error allows. + assert!((ends[0] - on_a).hypot() < 0.15 && (ends[1] - on_b).hypot() < 0.15, "{ends:?}, want {on_a:?} {on_b:?}"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(count(&s), 2, "one undo removes the line"); +} diff --git a/crates/tools/src/context.rs b/crates/tools/src/context.rs index 1e8f57ffc9..8bec1ccc54 100644 --- a/crates/tools/src/context.rs +++ b/crates/tools/src/context.rs @@ -198,9 +198,11 @@ pub struct ToolContext<'a> { /// [`Self::snap_tolerance`]. pub snap_to_point: bool, /// View → Snapping → Snap to Tangent: with Smart Guides on, a line drawn - /// from an anchor lands where it touches a nearby curve. + /// from an anchor lands where it touches a nearby curve, and a Line Segment + /// drag from one convex curved path to another lands on their common tangent. pub snap_tangent: bool, - /// View → Snapping → Snap to Perpendicular: likewise where it meets a nearby segment square. + /// View → Snapping → Snap to Perpendicular: with Smart Guides on, a line drawn from an anchor + /// lands where it meets a nearby segment square. pub snap_perpendicular: bool, /// View → Snap to Glyph: drawn points snap to live-text glyph bounds, and on a single line of type /// to its baseline, x-height, character widths and glyph anchor points (with Smart Guides). diff --git a/crates/tools/src/guides.rs b/crates/tools/src/guides.rs index 614df68917..e9f7bf7318 100644 --- a/crates/tools/src/guides.rs +++ b/crates/tools/src/guides.rs @@ -20,9 +20,11 @@ use vectorcraft_text::{FontDb, layout as layout_text}; use crate::bbox::Handle; use crate::{GlyphSnap, Overlay, ScreenFrame, ToolContext}; +mod bitangent; mod snap; mod targets; +pub(crate) use bitangent::TangentLine; pub(crate) use snap::hold_on_path; pub use snap::{ DEFAULT_CONSTRUCTION_ANGLES, DrawSnap, HandleSnap, Leave, PointSnap, construction_angles, distance_guides, snap_draw, snap_pick, square, diff --git a/crates/tools/src/guides/bitangent.rs b/crates/tools/src/guides/bitangent.rs new file mode 100644 index 0000000000..9d4f9fa05c --- /dev/null +++ b/crates/tools/src/guides/bitangent.rs @@ -0,0 +1,271 @@ +//! Snap to Tangent for a line drawn from one curve to another (the Line Segment tool): when the +//! press lands on a convex closed path with curves and the pointer comes near another one, both +//! ends of the line move onto a common tangent of the two, the start sliding along the first path. +//! The tangents are [`vectorcraft_pathops::addons::pathtools::common_tangents`]'s. +//! +//! The closed subpaths in the window the line may end on are listed once, at the press, by their +//! bounds, up to as many segments as Smart Guides gather. Each pointer move looks only at the +//! [`MAX_NEAR`] nearest of them whose outline lies within the snapping tolerance of the pointer. +//! The tangents of each pair are worked out once, and the last [`MAX_KEPT`] pairs' are kept for +//! the rest of the drag. + +use std::collections::HashSet; + +use vectorcraft_pathops::addons::pathtools::{Outline, Tangent, common_tangents}; + +use super::snap::visible; +use super::targets::{BUDGET, walk_but}; +use super::{Node, NodeId, NodeKind, Overlay, ParamCurveNearest, Point, Rect, SubPath, ToolContext}; +use crate::PixelOp; + +/// Most subpaths a pointer move takes tangents from: the nearest ones whose outline lies within +/// the snapping tolerance of the pointer. +const MAX_NEAR: usize = 16; +/// Most pairs whose tangents are kept during one drag. +const MAX_KEPT: usize = 64; +/// Most segments a subpath the line starts or ends on may have: the tangents of two paths take +/// time that grows with both paths' segment counts, and they are worked out during the drag. +const MAX_SEGMENTS: usize = 512; + +/// A closed subpath with a curve the line may end on: its path, its index in the path, and the +/// bounds of its control points. +#[derive(Clone, Copy)] +struct Listed { + key: (NodeId, usize), + bounds: Rect, +} + +/// The two-ended tangent snap of one Line Segment drag. +#[derive(Default)] +pub(crate) struct TangentLine { + /// The subpath the press landed on and its outline: none when the press was not on a convex + /// closed path with a curve, or the snap is off. + from: Option<((NodeId, usize), Outline)>, + /// The closed subpaths with a curve, listed at the press (none when it found no subpath to + /// start from). + listed: Vec, + /// The common tangents of the press's subpath and each subpath the pointer came near. + kept: Vec<((NodeId, usize), Vec)>, + /// The line of the last snap. + line: Option<(Point, Point)>, +} + +/// The snap applies: Smart Guides and Snap to Tangent on, and neither pixels nor the grid +/// snapping drawn points instead. +fn applies(cx: &ToolContext) -> bool { + cx.smart_guides && cx.snap_tangent && !cx.snaps_to_pixel(PixelOp::Drawing) && !cx.snap_to_grid +} + +/// The subpath `key` of the document in `cx`. +fn subpath<'a>(cx: &'a ToolContext, key: (NodeId, usize)) -> Option<&'a SubPath> { + match &cx.doc.node(key.0)?.kind { + NodeKind::Path { path, .. } => path.subpaths.get(key.1), + _ => None, + } +} + +/// The subpaths of path `id` a line may start or end on, with their indexes: closed, with at most +/// [`MAX_SEGMENTS`] segments. +fn closed_subpaths<'a>(cx: &'a ToolContext, id: NodeId) -> impl Iterator { + let subpaths = match cx.doc.node(id).map(|n| &n.kind) { + Some(NodeKind::Path { path, .. }) => path.subpaths.as_slice(), + _ => &[], + }; + subpaths.iter().enumerate().filter(|(_, sp)| sp.closed && sp.segment_count() <= MAX_SEGMENTS) +} + +/// How far `p` lies from `sp` (its segments whose control bounds come within `reach` of `p`); none +/// when no segment comes that near. +fn distance(sp: &SubPath, p: Point, reach: f64) -> Option { + let mut best: Option = None; + for k in 0..sp.segment_count() { + let c = sp.segment(k); + let b = Rect::from_points(c.p0, c.p3).union_pt(c.p1).union_pt(c.p2); + if !b.inflate(reach, reach).contains(p) { + continue; + } + let d = c.nearest(p, 1e-9).distance_sq.sqrt(); + if best.is_none_or(|e| d < e) { + best = Some(d); + } + } + best +} + +/// Whether `sp` has a curved segment. +fn curved(sp: &SubPath) -> bool { + (0..sp.segment_count()).any(|k| !sp.segment_is_line(k)) +} + +impl TangentLine { + /// Start a drag pressed at `start` (where the pointer went down): the subpath under it, when it + /// is a convex closed path with a curve, and then the closed subpaths with a curve in the window + /// the line may end on, by their bounds. The press looks at the segments of the paths whose + /// bounds reach it only, and lists nothing when it lands on no such subpath, or when `held` (an + /// anchor, center or crossing the press snapped to) lies off that subpath. + pub(crate) fn press(&mut self, cx: &ToolContext, start: Point, held: Option) { + *self = Self::default(); + if !applies(cx) || !start.x.is_finite() || !start.y.is_finite() { + return; + } + let tol = cx.snap_tol(); + // The paths with a closed subpath, by their finite bounds. + let closed = |n: &Node| match &n.kind { + NodeKind::Path { path, .. } if path.subpaths.iter().any(|sp| sp.closed) => { + n.geometric_bounds().filter(|b| [b.x0, b.y0, b.x1, b.y1].iter().all(|v| v.is_finite())) + } + _ => None, + }; + // The subpaths under the press: at most as many segments as Smart Guides gather. + let mut on: Option<(f64, (NodeId, usize))> = None; + let mut budget = BUDGET; + walk_but(&cx.doc.layers, &HashSet::new(), &mut |n| { + if budget == 0 || !closed(n).is_some_and(|b| b.inflate(tol, tol).contains(start)) { + return; + } + for (si, sp) in closed_subpaths(cx, n.id) { + let Some(left) = budget.checked_sub(sp.segment_count()) else { return }; + budget = left; + if let Some(d) = distance(sp, start, tol) + && d <= tol + && curved(sp) + && on.is_none_or(|(e, _)| d < e) + { + on = Some((d, (n.id, si))); + } + } + }); + // A path that bends inward somewhere has no tangent of this kind: the line keeps its start. + let Some(from) = on.and_then(|(_, key)| Some((key, Outline::convex(subpath(cx, key)?).ok()?))) else { return }; + // A press held by an anchor, center or crossing off that path starts the line there. + if let Some(q) = held + && !subpath(cx, from.0).and_then(|sp| distance(sp, q, tol)).is_some_and(|d| d <= 1e-6 * tol.max(1.0)) + { + return; + } + let from_key = from.0; + self.from = Some(from); + // The subpaths the line may end on: closed ones with a curve, of the paths in the window, + // at most as many segments as Smart Guides gather. + let window = visible(cx); + let listed = &mut self.listed; + let mut budget = BUDGET; + walk_but(&cx.doc.layers, &HashSet::new(), &mut |n| { + if budget == 0 || !closed(n).is_some_and(|b| window.is_none_or(|v| b.intersect(v).area() > 0.0 || v.contains(b.center()))) { + return; + } + for (si, sp) in closed_subpaths(cx, n.id) { + let Some(left) = budget.checked_sub(sp.segment_count()) else { return }; + budget = left; + let mut bounds: Option = None; + for k in 0..sp.segment_count() { + let c = sp.segment(k); + let b = Rect::from_points(c.p0, c.p3).union_pt(c.p1).union_pt(c.p2); + bounds = Some(bounds.map_or(b, |r| r.union(b))); + } + if let Some(bounds) = + bounds.filter(|b| curved(sp) && (n.id, si) != from_key && [b.x0, b.y0, b.x1, b.y1].iter().all(|v| v.is_finite())) + { + listed.push(Listed { key: (n.id, si), bounds }); + } + } + }); + } + + /// The line for the pointer at `p`: on the nearest subpath whose outline lies within the + /// snapping tolerance of `p` and that has a common tangent with the press's subpath, the + /// tangent whose touch point on it is nearest `p`; none when there is none. A subpath farther + /// from `p` than `rival` (an anchor, center or crossing the pointer snaps to otherwise) gives + /// way to it; its own anchors, which lie on its outline, do not. + pub(crate) fn snap(&mut self, cx: &ToolContext, p: Point, rival: Option) -> Option<(Point, Point)> { + let line = self.find(cx, p, rival); + self.line = line; + line + } + + fn find(&mut self, cx: &ToolContext, p: Point, rival: Option) -> Option<(Point, Point)> { + if self.from.is_none() || !applies(cx) || !p.x.is_finite() || !p.y.is_finite() { + return None; + } + let tol = cx.snap_tol(); + let mut near: Vec<(f64, (NodeId, usize))> = vec![]; + for l in self.listed.iter().filter(|l| l.bounds.inflate(tol, tol).contains(p)) { + // The nearest `MAX_NEAR`, in order, kept while scanning. + if let Some(d) = subpath(cx, l.key).and_then(|sp| distance(sp, p, tol)).filter(|d| *d <= tol) { + let at = near.partition_point(|(e, _)| *e <= d); + if at < MAX_NEAR { + near.insert(at, (d, l.key)); + near.truncate(MAX_NEAR); + } + } + } + for (d, key) in near { + if rival.is_some_and(|r| r < d - 1e-6 * tol) { + return None; + } + let Some(sp) = subpath(cx, key) else { continue }; + let mut best: Option<(f64, Point, Point)> = None; + for t in self.tangents(cx, key) { + // Where the paths touch each other, the tangent's ends are not both on the paths. + let on_b = distance(sp, t.to, tol).is_some_and(|e| e <= 1e-6 * tol.max(1.0)); + if !on_b || t.from.distance(t.to) <= tol { + continue; + } + let dist = t.to.distance(p); + // On a tie the line of the last move stays, so it does not flicker. + let same = self.line == Some((t.from, t.to)); + if best.is_none_or(|(e, ..)| dist < e - 1e-9 || (same && dist <= e + 1e-9)) { + best = Some((dist, t.from, t.to)); + } + } + if let Some((_, a, b)) = best { + return Some((a, b)); + } + } + None + } + + /// The common tangents of the press's subpath and subpath `key`, worked out on first use. + fn tangents(&mut self, cx: &ToolContext, key: (NodeId, usize)) -> Vec { + if let Some((_, t)) = self.kept.iter().find(|(k, _)| *k == key) { + return t.clone(); + } + let Some((_, from)) = &self.from else { return vec![] }; + let all = subpath(cx, key).and_then(|sp| Outline::convex(sp).ok()).and_then(|o| common_tangents(from, &o).ok()).unwrap_or_default(); + if self.kept.len() >= MAX_KEPT { + self.kept.remove(0); + } + self.kept.push((key, all.clone())); + all + } + + /// The line of the last snap, if it found one. + pub(crate) fn line(&self) -> Option<(Point, Point)> { + self.line + } + + /// Forget the last snap's line for a move that does not snap this way (a modifier is held), + /// keeping the press's subpath for the moves after it. + pub(crate) fn drop_line(&mut self) { + self.line = None; + } + + /// End the drag. + pub(crate) fn clear(&mut self) { + *self = Self::default(); + } + + /// The guides of the last snap: the line, and the "tangent" label at both ends. + pub(crate) fn guides(&self, cx: &ToolContext) -> Vec { + let Some((a, b)) = self.line else { return vec![] }; + let color = cx.smart_guide_color; + let mut out = vec![]; + if cx.alignment_guides { + out.push(Overlay::Line { a, b, color, dashed: false }); + } + if cx.anchor_path_labels { + out.extend([a, b].map(|p| Overlay::Label { p, text: "tangent".into(), color })); + } + out + } +} diff --git a/crates/tools/src/guides/snap.rs b/crates/tools/src/guides/snap.rs index d7ee8ecdd8..4c8a0d189a 100644 --- a/crates/tools/src/guides/snap.rs +++ b/crates/tools/src/guides/snap.rs @@ -365,7 +365,7 @@ impl SnapKey { } /// The part of the document the window shows (none headless: all of it). -fn visible(cx: &ToolContext) -> Option { +pub(super) fn visible(cx: &ToolContext) -> Option { let s = cx.screen?; let (w, h) = s.size; Some(Rect::from_points(s.at(0.0, 0.0), s.at(w, h)).union_pt(s.at(w, 0.0)).union_pt(s.at(0.0, h))) @@ -429,6 +429,35 @@ impl DrawSnap { self.snap(cx, p, from) } + /// How far from `p` the nearest Smart Guides point (an anchor or a center) or crossing of the + /// targets lies, when one is within the snapping tolerance: none otherwise, and none while + /// pixels or the grid snap instead. + pub(crate) fn point_within_reach(&self, cx: &ToolContext, p: Point) -> Option { + let Some((_, PointSnap { targets: Some((t, tol)), .. })) = &self.targets else { return None }; + if !cx.smart_guides { + return None; + } + let tol = cx.tol(*tol); + let point = t.nearest_point(p, tol).map(|(q, _)| q.distance(p)); + let crossing = t.crossing(p, tol).map(|q| q.distance(p)); + match (point, crossing) { + (Some(a), Some(b)) => Some(a.min(b)), + (a, b) => a.or(b), + } + } + + /// Whether `q`, where a point at `p` snapped to, is the nearest Smart Guides point (an anchor or + /// a center) or the nearest crossing of the targets within the snapping tolerance of `p`. + pub(crate) fn snapped_to_point(&self, cx: &ToolContext, p: Point, q: Point) -> bool { + let Some((_, PointSnap { targets: Some((t, tol)), .. })) = &self.targets else { return false }; + if !cx.smart_guides { + return false; + } + let tol = cx.tol(*tol); + let at = |a: Point| a.distance(q) <= 1e-9 * tol.max(1.0); + t.nearest_point(p, tol).is_some_and(|(a, _)| at(a)) || t.crossing(p, tol).is_some_and(at) + } + /// The guides of the last snap. pub fn guides(&self) -> &[Overlay] { &self.guides diff --git a/crates/tools/src/guides/targets.rs b/crates/tools/src/guides/targets.rs index e3e6abeef6..c846f1a55a 100644 --- a/crates/tools/src/guides/targets.rs +++ b/crates/tools/src/guides/targets.rs @@ -64,7 +64,7 @@ pub struct Targets { } /// How many anchors, and how many segments, the targets gather at most. -const BUDGET: usize = 20_000; +pub(super) const BUDGET: usize = 20_000; /// What [`Targets::collect_inner`] gathers from each path besides its anchors and bounds. #[derive(Clone, Copy, PartialEq)] @@ -88,7 +88,7 @@ fn within(sorted: &[T], key: impl Fn(&T) -> f64, v: f64, tol: f64) -> &[T] { /// Visit `nodes` and everything inside them, but the nodes in `skip`, the hidden nodes and /// everything inside those: one pass, however many are skipped. A Shaper Group's original /// shapes, its first child, are not shown and are skipped too. -fn walk_but<'a>(nodes: &'a [Arc], skip: &HashSet, f: &mut impl FnMut(&'a Node)) { +pub(super) fn walk_but<'a>(nodes: &'a [Arc], skip: &HashSet, f: &mut impl FnMut(&'a Node)) { for n in nodes.iter().filter(|n| n.visible && !skip.contains(&n.id)) { f(n); if let Some(ch) = n.children() { @@ -898,7 +898,7 @@ impl Targets { /// Where two target paths, a path and a ruler guide, or two ruler guides cross, the crossing /// nearest `p` within `tol` ("intersect", #1602). - fn crossing(&self, p: Point, tol: f64) -> Option { + pub(super) fn crossing(&self, p: Point, tol: f64) -> Option { self.crossing_with(p, tol, &self.rulers) } diff --git a/crates/tools/src/shape.rs b/crates/tools/src/shape.rs index 66728b4826..67d23be463 100644 --- a/crates/tools/src/shape.rs +++ b/crates/tools/src/shape.rs @@ -5,7 +5,9 @@ //! Illustrator). ↑/↓ during a polygon/star drag change the side/point count; during a star drag, //! Ctrl/Cmd keeps the inner radius where it is while the outer one follows the pointer, and Alt //! keeps the star's shoulders straight (#812). The start point and -//! the dragged corner snap to Smart Guides ([`DrawSnap`]), hovering before the press too. +//! the dragged corner snap to Smart Guides ([`DrawSnap`]), hovering before the press too. With Snap +//! to Tangent on, a line pressed on one convex curved path and dragged near another lands on a +//! common tangent of the two, both its ends moving to the touch points ([`TangentLine`]). //! Escape cancels the drag and puts back the options its keys and Ctrl/Cmd changed. //! //! The selection keeps its bounding box and its Live Shape widgets on show with the Rectangle, @@ -22,7 +24,7 @@ use vectorcraft_geom::{Affine, Point, Rect, Vec2}; use crate::bbox::{Handle, move_delta, rotate_for_drag, scale_for_drag}; use crate::corners::{self, CornerDrag}; -use crate::guides::{DrawSnap, Leave, PointSnap, Targets, square}; +use crate::guides::{DrawSnap, Leave, PointSnap, TangentLine, Targets, square}; use crate::pie::{self, PieDrag}; use crate::select::{MoveSnap, handle_cursor, hit_center, is_area_type, matrix_json, rotate_zone, shown_box}; use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, ToolContext, ToolKey}; @@ -95,6 +97,8 @@ pub struct ShapeTool { pub line_angle: f64, pub fill_line: bool, snap: DrawSnap, + /// Snap to Tangent for a line from one curve to another: both ends on a common tangent. + tangent_line: TangentLine, /// The options a drag's keys and Ctrl/Cmd change, as they were when the drag began: Escape /// puts them back. before_drag: Option, @@ -150,6 +154,7 @@ impl ShapeTool { star_ratio: 0.5, inner: None, snap: DrawSnap::default(), + tangent_line: TangentLine::default(), line_length: 100.0, line_angle: 0.0, fill_line: false, @@ -547,6 +552,12 @@ impl Tool for ShapeTool { return out; } let p = self.snap.press(cx, ev.pos, &[], None); + if self.id == "lineSegment" { + // The pressed spot finds the curve; a press that snapped to an anchor, center + // or crossing off that curve keeps the line's start there. + let held = self.snap.snapped_to_point(cx, ev.pos, p).then_some(p); + self.tangent_line.press(cx, ev.pos, held); + } self.start = Some(p); self.last = ev.pos; self.began = false; @@ -556,6 +567,7 @@ impl Tool for ShapeTool { } PointerKind::Drag => { let Some(mut s) = self.start else { return vec![] }; + let raw = ev.pos; let pos = self.snap.drag(cx, ev.pos, self.leave(cx, s, ev.mods).as_ref()); let ev = &PointerEvent { pos, ..*ev }; // The inner radius of the star the last drag showed, with the ratio it drew with: @@ -564,6 +576,10 @@ impl Tool for ShapeTool { let ratio = if self.mods.alt { straight_ratio(self.points).unwrap_or(self.star_ratio) } else { self.star_ratio }; let shown = (self.last - s).hypot() * ratio; space_moves(&mut s, &mut self.last, ev, self.began); + if ev.mods.space && self.began { + // The start no longer lies on the pressed path. + self.tangent_line.clear(); + } self.start = Some(s); self.mods = ev.mods; if self.id == "star" { @@ -578,13 +594,25 @@ impl Tool for ShapeTool { self.before_drag = Some(self.drag_options()); out.push(Action::Begin(self.label().into())); } - let (c, v) = self.command_at(s, ev.pos, ev.mods, cx.constrain_angle); + // Snap to Tangent: a line pressed on one curve and ending near another moves both + // its ends onto a common tangent of the two, unless Shift, Alt or Space is held or + // an anchor or crossing nearer the pointer pulls it. + let tangent = if self.id == "lineSegment" && !(ev.mods.shift || ev.mods.alt || ev.mods.space) { + let rival = self.snap.point_within_reach(cx, raw); + self.tangent_line.snap(cx, raw, rival) + } else { + self.tangent_line.drop_line(); + None + }; + let (a, b) = tangent.unwrap_or((s, ev.pos)); + let (c, v) = self.command_at(a, b, ev.mods, cx.constrain_angle); out.push(Action::Preview(c, v)); out } PointerKind::Up => { let Some(s) = self.start.take() else { return vec![] }; self.snap.clear(); + self.tangent_line.clear(); self.inner = None; self.before_drag = None; if self.began { @@ -658,6 +686,7 @@ impl Tool for ShapeTool { self.restore_drag_options(o); } self.snap.clear(); + self.tangent_line.clear(); vec![Action::Cancel] } else { vec![] @@ -706,7 +735,9 @@ impl Tool for ShapeTool { Some(WidgetDrag::Pie(d)) => return d.overlays(cx), None => {} } - let mut o = self.snap.guides().to_vec(); + // A line on a common tangent shows that snap's guides, and its length and angle. + 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()); if let Some((p, text)) = &self.measure { o.push(Overlay::Measure { p: *p, text: text.clone() }); @@ -714,7 +745,8 @@ impl Tool for ShapeTool { if let Some(s) = self.start.filter(|_| self.began && cx.measurement_labels) { let p = self.last + Vec2::new(cx.tol(12.0), cx.tol(12.0)); let text = if self.id == "lineSegment" { - cx.segment_measure_label(s, self.last) + let (a, b) = tangent.unwrap_or((s, self.last)); + cx.segment_measure_label(a, b) } else { // A box's size as drawn (from its centre with Alt, square with Shift). match self.id { diff --git a/crates/tools/src/shape/tests.rs b/crates/tools/src/shape/tests.rs index c76eef404e..1a72a0fbbf 100644 --- a/crates/tools/src/shape/tests.rs +++ b/crates/tools/src/shape/tests.rs @@ -430,6 +430,259 @@ fn line_segment_options_and_fill_line() { assert_eq!(t.command(a, b, Mods::default()).1["fill"], json!(true)); } +/// A document holding the closed paths `paths`, unselected. +fn doc_with_paths(paths: Vec) -> vectorcraft_doc::Document { + let mut d = vectorcraft_doc::Document::new(500.0, 500.0); + let l = d.layers[0].id; + for (k, path) in paths.into_iter().enumerate() { + let id = d.alloc_id(); + d.insert(Some(l), k, vectorcraft_doc::Node::path(id, path, vectorcraft_doc::Appearance::default_art())).unwrap(); + } + d +} + +/// The circle of radius `r` about `c`, as the Ellipse tool draws it. +fn circle(c: Point, r: f64) -> vectorcraft_geom::PathData { + vectorcraft_geom::shapes::ellipse(Rect::new(c.x - r, c.y - r, c.x + r, c.y + r)) +} + +/// The ends of the line a Line Segment drag from `press` through `drag` to `to` (with `mods`) +/// previews last, and the drag's actions. +fn line_drag(c: &ToolContext, press: Point, drag: Point, to: Point, mods: Mods) -> ((Point, Point), Vec) { + let mut t = ShapeTool::new("lineSegment"); + t.pointer(c, &PointerEvent::new(PointerKind::Down, press.x, press.y).with_mods(mods)); + let mut all = t.pointer(c, &PointerEvent::new(PointerKind::Drag, drag.x, drag.y).with_mods(mods)); + all.extend(t.pointer(c, &PointerEvent::new(PointerKind::Drag, to.x, to.y).with_mods(mods))); + let Some(Action::Preview(cmd, v)) = all.last().cloned() else { panic!("a preview: {all:?}") }; + assert_eq!(cmd, "shape.line"); + let f = |k: &str| v[k].as_f64().unwrap(); + let line = (Point::new(f("x1"), f("y1")), Point::new(f("x2"), f("y2"))); + all.extend(t.pointer(c, &PointerEvent::new(PointerKind::Up, to.x, to.y).with_mods(mods))); + (line, all) +} + +/// Snap to Tangent: a line pressed on one circle and dragged near another lands on a common +/// tangent of the two, both ends moving to where it touches them. Near the second circle's top it +/// is the outer tangent, near its bottom left the one crossing between them, each against the +/// closed form (the drawn circles are within 0.03% of round). The guides show the line and a +/// "tangent" label at each end, and the length label measures the tangent line. +#[test] +fn a_line_from_one_circle_to_another_lands_on_their_common_tangent() { + let (c1, r1, c2, r2) = (Point::new(100.0, 250.0), 40.0, Point::new(300.0, 250.0), 60.0); + let d = doc_with_paths(vec![circle(c1, r1), circle(c2, r2)]); + let (s, p) = (Selection::default(), paint()); + let c = cx(&d, &s, &p); + // A drawn circle's radius is off by up to 0.03%, which moves the touch points along the line by + // up to about 0.1 pt here; the line's distance from each center stays within 0.03 pt. + let near = |a: Point, b: Point| (a - b).hypot() < 0.15; + let off_by = |(a, b): (Point, Point), c: Point| ((b - a).cross(c - a) / (b - a).hypot()).abs(); + let touches = |line: (Point, Point)| (off_by(line, c1) - r1).abs() < 0.03 && (off_by(line, c2) - r2).abs() < 0.03; + // A normal n with n · (c2 - c1) / |c2 - c1| = k: the line touches the first circle at + // c1 + r1 n, and the second at c2 + r2 n (outer, k = (r1 - r2) / d) or c2 - r2 n (crossing, + // k = (r1 + r2) / d). + let normal = |k: f64, up: bool| Vec2::new(k, if up { -1.0 } else { 1.0 } * (1.0 - k * k).sqrt()); + let outer = normal((r1 - r2) / 200.0, true); + let (on_a, on_b) = (c1 + outer * r1, c2 + outer * r2); + let press = Point::new(100.0, 210.0); + let ((a, b), actions) = line_drag(&c, press, Point::new(200.0, 200.0), on_b + Vec2::new(0.5, 0.7), Mods::default()); + assert!(near(a, on_a) && near(b, on_b) && touches((a, b)), "{a:?} {b:?}, want {on_a:?} {on_b:?}"); + // One gesture: one undo step. + assert_eq!(actions.iter().filter(|a| matches!(a, Action::Begin(_))).count(), 1, "{actions:?}"); + assert_eq!(actions.last(), Some(&Action::Commit)); + let crossing = normal((r1 + r2) / 200.0, false); + let (on_a, on_b) = (c1 + crossing * r1, c2 - crossing * r2); + let ((a, b), _) = line_drag(&c, press, Point::new(200.0, 260.0), on_b + Vec2::new(-0.6, 0.4), Mods::default()); + assert!(near(a, on_a) && near(b, on_b) && touches((a, b)), "{a:?} {b:?}, want {on_a:?} {on_b:?}"); + // The guides and the length label while dragging. + let mut t = ShapeTool::new("lineSegment"); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, press.x, press.y)); + let to = on_b + Vec2::new(-0.6, 0.4); + t.pointer(&c, &PointerEvent::new(PointerKind::Drag, to.x, to.y)); + let o = t.overlays(&c); + let tangents: Vec = o + .iter() + .filter_map(|o| match o { + Overlay::Label { p, text, .. } if text == "tangent" => Some(*p), + _ => None, + }) + .collect(); + assert_eq!(tangents.len(), 2, "{o:?}"); + assert!(near(tangents[0], on_a) && near(tangents[1], on_b), "{o:?}"); + let (a, b) = t.tangent_line.line().unwrap(); + assert!(o.iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text == &c.segment_measure_label(a, b))), "{o:?}"); + // Escape ends it. + assert_eq!(t.key(&c, ToolKey::Escape, Mods::default()), vec![Action::Cancel]); + assert!(t.tangent_line.line().is_none() && t.overlays(&c).is_empty()); +} + +/// The tangent of a turned ellipse and a circle, against the ellipse's own closed form: the +/// support value of the ellipse x = c + M u (|u| = 1) along n is c · n + |Mᵀ n|, touched at +/// c + M Mᵀ n / |Mᵀ n|; the outer tangents are the n where it equals the circle's c₂ · n + r. +#[test] +fn a_line_from_a_turned_ellipse_lands_on_its_tangent_with_a_circle() { + let ce = Point::new(100.0, 250.0); + let turn = Affine::rotate_about(30f64.to_radians(), ce); + let ellipse = vectorcraft_geom::shapes::ellipse(Rect::new(40.0, 220.0, 160.0, 280.0)).transformed(turn); + let (c2, r2) = (Point::new(320.0, 260.0), 40.0); + let d = doc_with_paths(vec![ellipse, circle(c2, r2)]); + let (s, p) = (Selection::default(), paint()); + let c = cx(&d, &s, &p); + // M maps the unit circle onto the ellipse's axes: 60 and 30 long, turned 30°. + let (cos, sin) = (30f64.to_radians().cos(), 30f64.to_radians().sin()); + let m = [[60.0 * cos, -30.0 * sin], [60.0 * sin, 30.0 * cos]]; + let mt_n = |n: Vec2| Vec2::new(m[0][0] * n.x + m[1][0] * n.y, m[0][1] * n.x + m[1][1] * n.y); + let g = |a: f64| { + let n = Vec2::new(a.cos(), a.sin()); + ce.to_vec2().dot(n) + mt_n(n).hypot() - c2.to_vec2().dot(n) - r2 + }; + // The roots of g over the angle, by sampling and bisection; the one with n pointing up. + let mut roots = vec![]; + let steps = 3600; + for k in 0..steps { + let (mut lo, mut hi) = (k as f64 * std::f64::consts::TAU / steps as f64, (k + 1) as f64 * std::f64::consts::TAU / steps as f64); + if g(lo).signum() == g(hi).signum() { + continue; + } + for _ in 0..80 { + let mid = (lo + hi) / 2.0; + if g(mid).signum() == g(lo).signum() { lo = mid } else { hi = mid } + } + roots.push(lo); + } + let n = roots.iter().map(|a| Vec2::new(a.cos(), a.sin())).find(|n| n.y < 0.0).unwrap(); + let w = mt_n(n); + let on_a = ce + Vec2::new(m[0][0] * w.x + m[0][1] * w.y, m[1][0] * w.x + m[1][1] * w.y) / w.hypot(); + let on_b = c2 + n * r2; + // The press on the ellipse's turned top anchor. + let press = turn * Point::new(100.0, 220.0); + let ((a, b), _) = line_drag(&c, press, Point::new(200.0, 200.0), on_b + Vec2::new(0.4, -0.5), Mods::default()); + assert!((a - on_a).hypot() < 0.05 && (b - on_b).hypot() < 0.05, "{a:?} {b:?}, want {on_a:?} {on_b:?}"); +} + +/// The line keeps its start where it was pressed, as before, when Snap to Tangent is off, Smart +/// Guides are off, Shift or Alt is held, or the pressed path bends inward somewhere (it has no +/// tangent of this kind). Where the tangent touches the second circle at one of its anchors, the +/// tangent still wins over that anchor. +#[test] +fn a_line_keeps_its_start_without_a_tangent_snap() { + use vectorcraft_geom::{BezPath, PathData}; + let (c1, c2, r) = (Point::new(100.0, 250.0), Point::new(300.0, 250.0), 50.0); + let d = doc_with_paths(vec![circle(c1, r), circle(c2, r)]); + let (s, p) = (Selection::default(), paint()); + let on = cx(&d, &s, &p); + // The pointer next to the second circle's top anchor, where the outer tangent touches it. + let to = Point::new(300.6, 200.4); + // A press on the first circle 30° round from its top, away from its anchors. + let pressed = c1 + Vec2::new(r * 0.5, -r * 3f64.sqrt() / 2.0); + // With Snap to Tangent on, the start moves to the first circle's top. + let ((a, b), _) = line_drag(&on, pressed, Point::new(200.0, 190.0), to, Mods::default()); + assert!((a - Point::new(100.0, 200.0)).hypot() < 0.05 && (b - Point::new(300.0, 200.0)).hypot() < 0.05, "{a:?} {b:?}"); + let off = [ToolContext { snap_tangent: false, ..cx(&d, &s, &p) }, ToolContext { smart_guides: false, ..cx(&d, &s, &p) }]; + for c in &off { + let ((a, _), _) = line_drag(c, pressed, Point::new(200.0, 190.0), to, Mods::default()); + assert!((a - pressed).hypot() < 0.05, "{a:?}"); + } + for mods in [Mods { shift: true, ..Mods::default() }, Mods { alt: true, ..Mods::default() }] { + let ((a, b), _) = line_drag(&on, pressed, Point::new(200.0, 190.0), to, mods); + // Alt draws the line from its middle. + let start = if mods.alt { a.midpoint(b) } else { a }; + assert!((start - pressed).hypot() < 0.05, "{a:?} {b:?}"); + } + // Space moves the line being drawn, its start off the pressed circle: the snap lets go. + let mut t = ShapeTool::new("lineSegment"); + let space = Mods { space: true, ..Mods::default() }; + t.pointer(&on, &PointerEvent::new(PointerKind::Down, pressed.x, pressed.y)); + t.pointer(&on, &PointerEvent::new(PointerKind::Drag, 200.0, 170.0)); + t.pointer(&on, &PointerEvent::new(PointerKind::Drag, 210.0, 160.0).with_mods(space)); + let a = t.pointer(&on, &PointerEvent::new(PointerKind::Drag, to.x, to.y)); + let Some(Action::Preview(_, v)) = a.last() else { panic!("a preview: {a:?}") }; + let start = Point::new(v["x1"].as_f64().unwrap(), v["y1"].as_f64().unwrap()); + assert!((start - (pressed + Vec2::new(10.0, -10.0))).hypot() < 1.0, "{start:?}"); + // A crescent: closed and curved, but its lower side bends inward. The press on its top + // keeps its start. + let mut bp = BezPath::new(); + bp.move_to((60.0, 250.0)); + bp.curve_to((60.0, 190.0), (140.0, 190.0), (140.0, 250.0)); + bp.curve_to((120.0, 220.0), (80.0, 220.0), (60.0, 250.0)); + bp.close_path(); + let d = doc_with_paths(vec![PathData::from_bezpath(&bp), circle(c2, r)]); + let c = cx(&d, &s, &p); + let crest = Point::new(100.0, 205.0); + let ((a, _), _) = line_drag(&c, crest, Point::new(200.0, 190.0), to, Mods::default()); + assert!((a - crest).hypot() < 1e-6, "{a:?}"); +} + +/// The upper outer common tangent of the circles about `c1` and `c2` with radii `r1` and `r2` +/// (`c2` to the right): where it touches each. +fn upper_outer_tangent(c1: Point, r1: f64, c2: Point, r2: f64) -> (Point, Point) { + let d = c2 - c1; + let u = d / d.hypot(); + let k = (r1 - r2) / d.hypot(); + // n · u = k, with n pointing up (y down). + let n = u * k + Vec2::new(u.y, -u.x) * (1.0 - k * k).sqrt(); + (c1 + n * r1, c2 + n * r2) +} + +/// The pointer only has to come near the second path's outline: anywhere along it, the line takes +/// the tangent whose touch point is nearest the pointer, here one about 30 pt away. A press on a +/// straight side of a convex path with curves (a rounded rectangle's top edge) moves the start +/// onto the corner the tangent touches. +#[test] +fn a_line_near_the_second_path_takes_the_tangent_touching_it_nearest() { + let (c1, r1, c2, r2) = (Point::new(100.0, 250.0), 40.0, Point::new(300.0, 250.0), 60.0); + let d = doc_with_paths(vec![circle(c1, r1), circle(c2, r2)]); + let (s, p) = (Selection::default(), paint()); + let c = cx(&d, &s, &p); + let (on_a, on_b) = upper_outer_tangent(c1, r1, c2, r2); + // On the second circle's outline, 25° round from its top. + let to = c2 + Vec2::new(r2 * 25f64.to_radians().sin(), -r2 * 25f64.to_radians().cos()); + assert!((to - on_b).hypot() > 25.0); + let ((a, b), _) = line_drag(&c, Point::new(100.0, 210.0), Point::new(200.0, 200.0), to, Mods::default()); + assert!((a - on_a).hypot() < 0.15 && (b - on_b).hypot() < 0.15, "{a:?} {b:?}, want {on_a:?} {on_b:?}"); + + // A rounded rectangle whose top right corner is a quarter circle of radius 20 about (140, 220). + let rounded = vectorcraft_geom::shapes::rounded_rectangle(Rect::new(40.0, 200.0, 160.0, 300.0), 20.0); + let (c2, r2) = (Point::new(320.0, 260.0), 40.0); + let d = doc_with_paths(vec![rounded, circle(c2, r2)]); + let c = cx(&d, &s, &p); + let (on_a, on_b) = upper_outer_tangent(Point::new(140.0, 220.0), 20.0, c2, r2); + let press = Point::new(90.0, 200.0); + let ((a, b), _) = line_drag(&c, press, Point::new(200.0, 200.0), Point::new(320.0, 220.5), Mods::default()); + assert!((a - on_a).hypot() < 0.15 && (b - on_b).hypot() < 0.15, "{a:?} {b:?}, want {on_a:?} {on_b:?}"); +} + +/// No tangent snap when the second path bends inward somewhere (a crescent), or when the press +/// snapped to an anchor of other art lying beside the first circle: the start stays where the +/// press put it. +#[test] +fn a_line_to_a_crescent_or_from_an_anchor_beside_the_curve_keeps_its_start() { + use vectorcraft_geom::{BezPath, PathData}; + let (c1, r) = (Point::new(100.0, 250.0), 50.0); + let mut bp = BezPath::new(); + bp.move_to((260.0, 250.0)); + bp.curve_to((260.0, 190.0), (340.0, 190.0), (340.0, 250.0)); + bp.curve_to((320.0, 220.0), (280.0, 220.0), (260.0, 250.0)); + bp.close_path(); + let d = doc_with_paths(vec![circle(c1, r), PathData::from_bezpath(&bp)]); + let (s, p) = (Selection::default(), paint()); + let c = cx(&d, &s, &p); + let pressed = c1 + Vec2::new(r * 0.5, -r * 3f64.sqrt() / 2.0); + // Beside the crescent's top, which lies at (300, 205). + let to = Point::new(300.4, 205.3); + let ((a, b), _) = line_drag(&c, pressed, Point::new(200.0, 190.0), to, Mods::default()); + assert!((a - pressed).hypot() < 0.05 && (b - to).hypot() < 1.0, "{a:?} {b:?}"); + + // A square whose corner (99, 199) lies about 1 pt outside the first circle's top; a second + // circle to the right. The press snaps to that corner and the line starts there. + let (c2, r2) = (Point::new(300.0, 250.0), 50.0); + let square = vectorcraft_geom::shapes::rectangle(Rect::new(80.0, 180.0, 99.0, 199.0)); + let d = doc_with_paths(vec![circle(c1, r), square, circle(c2, r2)]); + let c = cx(&d, &s, &p); + let corner = Point::new(99.0, 199.0); + let ((a, _), _) = line_drag(&c, Point::new(99.3, 199.3), Point::new(200.0, 190.0), Point::new(300.6, 200.4), Mods::default()); + assert!((a - corner).hypot() < 1e-6, "{a:?}"); +} + /// #5477: with a shape tool, a drag on a selected live rectangle's corner widget rounds its /// corners (one undo step) and a drag on a live ellipse's pie widget sets its pie angle, as with /// the Selection tool; the pointer over a widget is the Selection tool's. A press anywhere else, or diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c003439bb4..8499f23a5c 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -611,6 +611,7 @@ since 2026-10-01. **Drawing tools, Dimension tool points on a Smart Guide stay on the guide:** By VectorCraft's own rule, a clicked point that lies on a Smart Guide already, such as one in line with an object's center, stays where the pointer is when no anchor is within 8 pixels and no segment is within the Smart Guides snapping tolerance, instead of moving onto a segment farther than that tolerance and within 8 pixels; with Snap to Grid or Snap to Pixel on, a point stays on the grid or the whole pixel those options give. `a_point_on_a_guide_stays_on_the_guide` covers it. **Drawing tools, Dimension tool second point without construction guides through a first point off the anchors:** By VectorCraft's own rule, with Smart Guides on, the second Linear point does not snap to the construction guides through a first point that is not on an anchor, so a click beside a segment straight below such a first point lands on the segment; after a first point picked on an anchor, the construction guides through it still apply. The second point still snaps to anchors, centers and alignment lines, and with Snap to Perpendicular or Snap to Tangent on, it lands where the line from the first point meets a segment square or grazes a curve. `a_point_on_a_guide_stays_on_the_guide`, `the_second_point_after_an_anchor_lands_on_construction_guides`, `the_second_point_lands_square_to_a_segment_or_grazing_a_curve` and `linear_picks_show_and_snap_to_smart_guides` cover it. **Drawing tools, Dimension tool dimensions selected with their art keep their lines and label:** Object › Expand, Object › Expand Appearance and Object › Path › Outline Stroke leave a dimension selected with art it measures, directly or in selected groups without fills, strokes or effects of their own, as it is and change only the other art; when the new art no longer fits its link, the dimension stays where it was, no longer linked, and undo links it again. `expand_leaves_a_dimension_selected_with_its_art_as_it_is`, `expand_appearance_leaves_a_dimension_selected_with_its_art_as_it_is`, `outline_stroke_leaves_a_dimension_selected_with_its_art_as_it_is`, `a_dimension_selected_with_art_that_has_nothing_to_expand_changes_nothing`, `a_group_effect_expanded_reaches_the_dimension_it_holds`, `expand_keeps_a_dimension_in_its_asset_and_its_variable_binding`, `a_dimension_keeps_no_link_to_the_art_expand_replaced`, `a_dimension_outlasts_the_art_outline_stroke_or_expand_appearance_replaced`, `a_dimension_outlasts_the_stroke_expand_outlined` and `expand_appearance_in_safe_mode_leaves_a_dimension_selected_with_its_art` cover it. +**Drawing tools, Line Segment from one curve onto a common tangent of another:** By VectorCraft's own rule, with Smart Guides and Snap to Tangent on, a Line Segment drag pressed anywhere on a convex closed path with curves and dragged to within the snapping tolerance of another such path lands on a common tangent of the two ([tangent lines to circles](https://en.wikipedia.org/wiki/Tangent_lines_to_circles)): both ends move to where the line touches the paths, the start sliding along the first path, and each end shows the "tangent" label when Anchor/Path Labels is on, with the line drawn as a guide when Alignment Guides is on. The line is the tangent whose touch point on the second path is nearest the pointer, so moving the pointer around the second path switches between the outer tangent and the one crossing between the paths. The start stays where it was pressed when Shift, Alt or Space is held, when an anchor, center or crossing lies nearer the pointer than the second path does, when the press snapped to an anchor, center or crossing off the first path, when Snap to Tangent is off, when Snap to Grid or pixel snapping places drawn points, or when either path bends inward somewhere or has more than 512 segments. `a_line_from_one_circle_to_another_lands_on_their_common_tangent`, `a_line_from_a_turned_ellipse_lands_on_its_tangent_with_a_circle`, `a_line_near_the_second_path_takes_the_tangent_touching_it_nearest`, `a_line_keeps_its_start_without_a_tangent_snap`, `a_line_to_a_crescent_or_from_an_anchor_beside_the_curve_keeps_its_start` and `a_line_segment_drag_draws_the_common_tangent_as_one_undo_step` cover it. **Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views:** `live_trace_result_bounds_exclude_the_retained_bitmap_at_any_angle` checks every TraceView, geometric and visual bounds and rotated result bounds. `live_trace_selection_highlight_excludes_the_retained_source_rectangle` checks result highlights and the existing ordinary-group policy. Shared editing-child traversal also preserves Shaper handling. **Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards:** Shared existing preset definitions are reused; no external preset assets are added. Presets preserve each selected artboard's orientation, and orientation choices apply even when the active board already matches. Fit operations draft bounds until OK, affect only the active artboard and leave artwork in place. Regression coverage checks draft/Cancel, selected-set application, active-only fitting and Undo.