Path Precision Tools: the Tangent Circle Tool draws a circle on two clicked segments

The Tangent Circle Tool (tangentCircle) joins the add-on's tools, in
Object > Plug-ins > Path Precision Tools and the All Tools drawer. A click
on a path segment picks it; a click on a second segment draws the circle
that is tangent to the first segment at the point clicked and touches
the second. The segments beside the second one count with it, and of
the circles found the one touching them nearest the pointer is drawn.

- Shift on the second click uses the tool's radius (36 pt to start, set
  in its options), anywhere along the first segment.
- A drag from the second segment sets the radius to the drag's length;
  Shift steps it by 1, 2 or 5 times a power of 10 pt, at least 4 screen
  pixels, and Cmd/Ctrl pressed during the drag moves it by a tenth.
- Before the click the circle shows with its center, its radii to the
  touch points and its radius, or a translated note says there is none.
  The preview follows a pan, a zoom or an edit under a still pointer.
- The circle is drawn with shape.circleThroughPoints, so Align New
  Objects to Pixel Grid leaves it tangent; one undo step. A circle that
  its three points cannot give back in floating point is not drawn, and
  the first segment stays picked. Escape, an edit outside the tool or
  another document forgets the first segment.

The geometry is circles_through and circles_of_radius in the pathops
crate: the distance to the second segments is sampled along the first
segment's normal (or along the segment, for a radius) and the places
where it equals the radius are taken, including touches between samples.

Part of #7178.

Docs: docs/mcp.md, docs/ui-parity.md, docs/target-app-parity.md, ROADMAP.
This commit is contained in:
dotCooCoo committed 2026-11-17 20:04:15 -08:00
1 parent ef698d76f8
commit a561f666a6
42 files changed
+1177 -11

No files matched your search

+1
View File
@@ -149,6 +149,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
- 2026-11-01: Randomize Opacity joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): each selected object gets its own opacity at random between a minimum and a maximum percent, with a seed that repeats the result, as one undo step (`addon.arrange.randomizeOpacity`, #4925).
- 2026-11-01: Sort Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are sorted by width, height, area, position, opacity or stacking order (small to large, large to small or at random) and take another of those in that order, trading their values or stepping them evenly, as one undo step (`addon.arrange.sort`, #4917).
- 2026-11-15: Tangent Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the circles that touch two selected paths or compound paths at a set radius, or three of them (up to eight for three circles), touching each outline without crossing it; circles, rotated ellipses and other paths alike. A dialog that previews every circle or one picked by number, the current paint, one undo step (`addon.pathtools.tangentCircle`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-17: Tangent Circle Tool joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools, and the All Tools drawer): click a path segment, then another, to draw the circle tangent to the first where it was clicked that touches the second; Shift uses the tool's radius, and a drag from the second segment sets the radius (Shift in round steps, Cmd/Ctrl slowly). The circle shows with its center and radii before the click, one undo step (`tangentCircle`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-01: New Symbols from Layers joins the Document Tools add-on (Object › Plug-ins › Document Tools): one symbol of each top-level layer's art (the layers highlighted in the Layers panel when two or more are, else every layer), named after the layer, made as New Symbol makes one; Convert Layers to Symbols also puts an instance of each in place of its layer's art. Empty layers are skipped and reported; one undo step. A VectorCraft addition: headline numbers unchanged.
- 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 `<name>_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.
+7 -3
View File
@@ -5,8 +5,9 @@
//! where paths cross ([`crossings`]), the stretches between them ([`spans`]), anchors slid along
//! their path ([`slide`]), touching edges merged ([`shared_edge`]), paths divided into dashes
//! ([`divide_dashes`]), the common tangents of two convex outlines ([`common_tangents`]), the
//! Parametric Shape Tool's shapes ([`shapes`]) and the circles that touch two or three shapes
//! ([`tangent_circles`]).
//! Parametric Shape Tool's shapes ([`shapes`]), the circles that touch two or three shapes
//! ([`tangent_circles`]) and the Tangent Circle tool's circles on two segments
//! ([`circles_through`], [`circles_of_radius`]).
mod crossings;
mod dashes;
@@ -32,7 +33,10 @@ pub use shared_edge::{
COINCIDENCE, EndSide, Follow, MAX_COINCIDENCE, MergePlan, MergePreview, Stretch, apply_merge, ends_at, merge_preview, stretches_at,
};
pub use slide::{MAX_SLIDE, slide_anchor, slide_stops, slide_t_at};
pub use tangent_circle::{Circle, MAX_TANGENT_CIRCLE_SEGMENTS, MAX_TANGENT_CIRCLES, TangentCircleError, tangent_circle_segments, tangent_circles};
pub use tangent_circle::{
Circle, MAX_TANGENT_CIRCLE_SEGMENTS, MAX_TANGENT_CIRCLES, SegmentCircle, TangentCircleError, circles_of_radius, circles_through,
tangent_circle_segments, tangent_circles,
};
pub use tangents::{Coincide, MAX_TANGENT_SEGMENTS, Outline, OutlineError, Tangent, TangentKind, common_tangents};
pub use trim::{Span, slice, span_at, spans, without_spans};
@@ -14,9 +14,12 @@
use kurbo::{CubicBez, ParamCurve, Point, Vec2};
use vectorcraft_geom::PathData;
mod on_segments;
#[cfg(test)]
mod tests;
pub use on_segments::{SegmentCircle, circles_of_radius, circles_through};
/// Most segments the shapes may hold together, counted by [`tangent_circle_segments`].
pub const MAX_TANGENT_CIRCLE_SEGMENTS: usize = 2_000;
@@ -0,0 +1,265 @@
//! The circles the Tangent Circle tool draws on two picked segments: the circle tangent to the
//! first segment at a point that also touches the second ([`circles_through`]), or the circles of a
//! radius tangent to the first segment that also touch the second ([`circles_of_radius`]). "The
//! second" is a list of segments (the picked one and those next to it). A circle touches them when
//! the nearest of their points to its center is on the circle, so they lie outside it, and it never
//! crosses the first segment.
//!
//! The roots are found by sampling a distance function along one parameter: samples where it is 0,
//! bisection where it changes sign, and a golden-section search where it comes down to 0 between
//! samples without changing sign.
use kurbo::{CubicBez, ParamCurve, ParamCurveDeriv, ParamCurveNearest, Point, Vec2};
use super::Circle;
/// A circle on two picked segments: the circle, where it touches the first segment and where it
/// touches the second ones.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SegmentCircle {
pub circle: Circle,
pub first: Point,
pub second: Point,
}
/// Samples along the parameter the roots are looked for on.
const SAMPLES: usize = 512;
/// Bisection steps per root.
const BISECTIONS: usize = 64;
/// The largest radius [`circles_through`] looks at, as a multiple of the diagonal of the box around
/// the segments' control points.
const MAX_RADIUS: f64 = 1e4;
/// Below this share of the radius two points of a circle are one.
const SAME: f64 = 1e-7;
/// Below this share of the radius (or, while the radius is looked for, of the gap from the point to
/// the second segments) a circle's distance from the second segments counts as touching.
const CONTACT: f64 = 1e-9;
/// Below this (in units of the first segment's size) a length is rounding.
const ROUNDING: f64 = 1e-12;
/// The diagonal of the box around the control points of `first` and `second`; none when it is 0 or
/// not finite.
fn scale(first: &CubicBez, second: &[CubicBez]) -> Option<f64> {
let pts = std::iter::once(first).chain(second).flat_map(|c| [c.p0, c.p1, c.p2, c.p3]);
let (mut lo, mut hi) = (Point::new(f64::INFINITY, f64::INFINITY), Point::new(f64::NEG_INFINITY, f64::NEG_INFINITY));
for p in pts {
if !(p.x.is_finite() && p.y.is_finite()) {
return None;
}
lo = Point::new(lo.x.min(p.x), lo.y.min(p.y));
hi = Point::new(hi.x.max(p.x), hi.y.max(p.y));
}
let d = (hi - lo).hypot();
(d.is_finite() && d > 0.0).then_some(d)
}
/// The nearest point to `q` on `segs` and its distance.
fn nearest(q: Point, segs: &[CubicBez]) -> Option<(f64, Point)> {
segs.iter()
.map(|c| {
let n = c.nearest(q, 1e-9);
(n.distance_sq.sqrt(), c.eval(n.t))
})
.min_by(|a, b| a.0.total_cmp(&b.0))
}
/// The unit normal of `c` at `t` (its tangent turned a quarter turn). Where the derivative is 0 (a
/// handle lying on its anchor), the direction the curve leaves in: toward the far handle, or the
/// other end. None where the segment does not move by more than rounding in units of `scale`, its
/// size.
fn normal(c: &CubicBez, t: f64, scale: f64) -> Option<Vec2> {
let tiny = ROUNDING * scale;
let d = c.deriv().eval(t).to_vec2();
let d = if d.hypot() > tiny {
d
} else if t < 0.5 {
c.p2 - c.p0
} else {
c.p3 - c.p1
};
let d = if d.hypot() > tiny { d } else { c.p3 - c.p0 };
let len = d.hypot();
(len.is_finite() && len > tiny).then(|| Vec2::new(-d.y / len, d.x / len))
}
/// The parameters where `f` is 0, within `zero`, in order: every sample where it is (a stretch where
/// it stays 0 gives each of its samples), each place between two samples where it changes sign
/// (found by bisection), and, where `f` comes toward 0 between samples and goes back without a
/// sample on the other side, the place it comes nearest (a golden-section search): a touch when it
/// reaches 0 there, and the two places on either side, by bisection, when it passes 0.
fn roots(samples: &[f64], f: impl Fn(f64) -> Option<f64>, zero: f64) -> Vec<f64> {
let mut out = vec![];
let values: Vec<Option<f64>> = samples.iter().map(|s| f(*s)).collect();
let is_zero = |v: f64| v.abs() <= zero;
for (s, v) in samples.iter().zip(&values) {
if v.is_some_and(is_zero) {
out.push(*s);
}
}
for (k, w) in values.windows(3).enumerate() {
let (Some(a), Some(b), Some(c)) = (w[0], w[1], w[2]) else { continue };
let (Some(&lo), Some(&hi)) = (samples.get(k), samples.get(k + 2)) else { continue };
let same_side = (a > 0.0) == (b > 0.0) && (b > 0.0) == (c > 0.0);
// A low point, or one of two equal low samples about a touch half way between them.
let low = b.abs() <= a.abs() && b.abs() <= c.abs() && (b.abs() < a.abs() || b.abs() < c.abs());
if !same_side || is_zero(a) || is_zero(b) || is_zero(c) || !low {
continue;
}
out.extend(near_zero(lo, hi, b > 0.0, &f, zero));
}
// At either end the lowest sample has no sample beyond it: the stretch to the next one.
for (end, next) in [(0, 1), (values.len().saturating_sub(1), values.len().saturating_sub(2))] {
let (Some(Some(a)), Some(Some(b))) = (values.get(end), values.get(next)) else { continue };
let (Some(&s), Some(&t)) = (samples.get(end), samples.get(next)) else { continue };
if (a > &0.0) == (b > &0.0) && !is_zero(*a) && !is_zero(*b) && a.abs() < b.abs() {
out.extend(near_zero(s.min(t), s.max(t), *a > 0.0, &f, zero));
}
}
for (k, w) in values.windows(2).enumerate() {
let (Some(a), Some(b)) = (w[0], w[1]) else { continue };
let (Some(&lo), Some(&hi)) = (samples.get(k), samples.get(k + 1)) else { continue };
if (a > 0.0) == (b > 0.0) || is_zero(a) || is_zero(b) {
continue;
}
out.extend(bisect(lo, hi, &f));
}
out.sort_by(f64::total_cmp);
out
}
/// Where `f`, above 0 (`positive`) or below at the samples `lo` and `hi`, comes nearest 0 between
/// them: that place when it reaches 0 there, the two places on either side where it passes 0, or
/// none.
fn near_zero(lo: f64, hi: f64, positive: bool, f: &impl Fn(f64) -> Option<f64>, zero: f64) -> Vec<f64> {
// Toward 0 is down for a positive `f`, up for a negative one.
let toward = if positive { 1.0 } else { -1.0 };
let Some(m) = smallest(lo, hi, |s| f(s).map(|v| v * toward)) else { return vec![] };
let Some(fm) = f(m) else { return vec![] };
if fm.abs() <= zero {
vec![m]
} else if fm * toward < 0.0 {
bisect(lo, m, f).into_iter().chain(bisect(m, hi, f)).collect()
} else {
vec![]
}
}
/// Where `f` changes sign between `lo` and `hi`, by bisection; none when it does not.
fn bisect(mut lo: f64, mut hi: f64, f: impl Fn(f64) -> Option<f64>) -> Option<f64> {
let (a, b) = (f(lo)?, f(hi)?);
if (a > 0.0) == (b > 0.0) {
return None;
}
let positive_low = a > 0.0;
for _ in 0..BISECTIONS {
let mid = 0.5 * (lo + hi);
match f(mid) {
Some(v) if (v > 0.0) == positive_low => lo = mid,
Some(_) => hi = mid,
None => break,
}
}
Some(0.5 * (lo + hi))
}
/// Where `g` is smallest between `lo` and `hi`, by a golden-section search; none where `g` has no
/// value.
fn smallest(mut lo: f64, mut hi: f64, g: impl Fn(f64) -> Option<f64>) -> Option<f64> {
const INV_PHI: f64 = 0.618_033_988_749_894_9;
let (mut a, mut b) = (hi - INV_PHI * (hi - lo), lo + INV_PHI * (hi - lo));
let (mut ga, mut gb) = (g(a)?, g(b)?);
for _ in 0..BISECTIONS {
if ga < gb {
hi = b;
(b, gb) = (a, ga);
a = hi - INV_PHI * (hi - lo);
ga = g(a)?;
} else {
lo = a;
(a, ga) = (b, gb);
b = lo + INV_PHI * (hi - lo);
gb = g(b)?;
}
}
Some(0.5 * (lo + hi))
}
/// Where the circle about `center` of radius `r` touches `second`: the nearest of their points, when
/// it is on the circle (within a millionth of the radius, plus rounding in units of `scale`). None
/// for a root where the distance only jumps past the radius, as it does where the first segment
/// turns back on itself and its normal flips.
fn touching(center: Point, r: f64, second: &[CubicBez], scale: f64) -> Option<Point> {
nearest(center, second).filter(|(d, _)| (d - r).abs() <= 1e-6 * r + ROUNDING * scale).map(|(_, p)| p)
}
/// `found` without circles that cross `first`, that touch the two at one point, or that repeat an
/// earlier one.
fn keep(found: Vec<SegmentCircle>, first: &CubicBez) -> Vec<SegmentCircle> {
let mut out: Vec<SegmentCircle> = vec![];
for c in found {
let r = c.circle.radius;
let crosses = nearest(c.circle.center, std::slice::from_ref(first)).is_none_or(|(d, _)| d < r * (1.0 - 1e-6));
let one_point = (c.first - c.second).hypot() <= SAME * r;
// The roots come in order along their parameter, so a repeat follows its first.
let repeat = out.last().is_some_and(|o| (o.circle.center - c.circle.center).hypot() <= SAME * r * 10.0);
if !(crosses || one_point || repeat) && r.is_finite() && r > 0.0 {
out.push(c);
}
}
out
}
/// The circles tangent to `first` at parameter `t` (passing through that point, their centers on
/// its normal there) that touch `second`. An empty list when `first` has no direction at `t`, when
/// the point is on `second`, or when no circle touches it; at most two in practice, one on each side.
pub fn circles_through(first: CubicBez, t: f64, second: &[CubicBez]) -> Vec<SegmentCircle> {
if second.is_empty() || !t.is_finite() {
return vec![];
}
let t = t.clamp(0.0, 1.0);
let (Some(scale), Some(own)) = (scale(&first, second), scale(&first, &[])) else { return vec![] };
let Some(n) = normal(&first, t, own) else { return vec![] };
let p = first.eval(t);
// On the second segments (a corner the two share), up to rounding in units of the first
// segment's size: no circle.
let on = ROUNDING * own;
let Some((gap, _)) = nearest(p, second).filter(|(d, _)| *d > on) else { return vec![] };
// Radii spaced evenly in their logarithm, from half the gap from the point to the second
// segments (no smaller circle through the point reaches them) to far past the segments.
let (lo, hi) = (0.5 * gap * (1.0 - 1e-9), MAX_RADIUS * scale.max(gap));
let samples: Vec<f64> = (0..=SAMPLES).map(|k| lo * (hi / lo).powf(k as f64 / SAMPLES as f64)).collect();
let mut found = vec![];
for side in [1.0, -1.0] {
let center = |r: f64| p + n * (side * r);
for r in roots(&samples, |r| nearest(center(r), second).map(|(d, _)| d - r), CONTACT * gap) {
if let Some(touch) = touching(center(r), r, second, own) {
found.push(SegmentCircle { circle: Circle { center: center(r), radius: r }, first: p, second: touch });
}
}
}
keep(found, &first)
}
/// The circles of `radius` tangent to `first` (their centers `radius` from it along its normal)
/// that touch `second`. An empty list when the radius is not above 0 or none is found. Where the
/// segments run twice the radius apart along a stretch, every circle along it touches both, and one
/// is listed for each of the 513 places along `first` that are tried there.
pub fn circles_of_radius(first: CubicBez, second: &[CubicBez], radius: f64) -> Vec<SegmentCircle> {
if second.is_empty() || !radius.is_finite() || radius <= 0.0 {
return vec![];
}
let (Some(_), Some(own)) = (scale(&first, second), scale(&first, &[])) else { return vec![] };
let samples: Vec<f64> = (0..=SAMPLES).map(|k| k as f64 / SAMPLES as f64).collect();
let mut found = vec![];
for side in [1.0, -1.0] {
let center = |t: f64| normal(&first, t, own).map(|n| first.eval(t) + n * (side * radius));
for t in roots(&samples, |t| center(t).and_then(|c| nearest(c, second)).map(|(d, _)| d - radius), CONTACT * radius) {
if let Some(c) = center(t)
&& let Some(touch) = touching(c, radius, second, own)
{
found.push(SegmentCircle { circle: Circle { center: c, radius }, first: first.eval(t), second: touch });
}
}
}
keep(found, &first)
}
@@ -1,4 +1,4 @@
use kurbo::{Affine, Point, Rect};
use kurbo::{Affine, CubicBez, Point, Rect};
use vectorcraft_geom::{PathData, SubPath, shapes};
use super::*;
@@ -485,3 +485,205 @@ fn answers_about_a_tiny_shape_far_away_stay_apart() {
assert!(a.y < b.y - 1e-3 || ((a.y - b.y).abs() <= 1e-3 && a.x < b.x), "{found:?}");
}
}
/// A straight segment from `a` to `b`, its handles at its thirds so that `t` runs evenly along it.
fn line(a: (f64, f64), b: (f64, f64)) -> CubicBez {
let (a, b) = (Point::new(a.0, a.1), Point::new(b.0, b.1));
CubicBez::new(a, a.lerp(b, 1.0 / 3.0), a.lerp(b, 2.0 / 3.0), b)
}
#[test]
fn a_line_with_its_handles_on_its_anchors_has_a_direction_at_its_ends() {
let (a, b) = (Point::new(0.0, 0.0), Point::new(100.0, 0.0));
for t in [0.0, 1.0] {
let p = CubicBez::new(a, a, b, b).eval(t);
let found = circles_through(CubicBez::new(a, a, b, b), t, &[line((-50.0, 40.0), (150.0, 40.0))]);
assert_eq!(found.len(), 1, "{t}: {found:?}");
assert!(near(found[0].circle.center, p.x, 20.0, 1e-6), "{t}: {found:?}");
}
}
fn near(p: Point, x: f64, y: f64, tol: f64) -> bool {
(p - Point::new(x, y)).hypot() <= tol
}
#[test]
fn a_circle_through_a_point_of_one_line_touches_a_parallel_line() {
let found = circles_through(line((0.0, 0.0), (100.0, 0.0)), 0.5, &[line((0.0, 40.0), (100.0, 40.0))]);
// Only toward the other line: away from it, no circle reaches it.
assert_eq!(found.len(), 1, "{found:?}");
let c = found[0];
assert!(near(c.circle.center, 50.0, 20.0, 1e-6) && (c.circle.radius - 20.0).abs() < 1e-6, "{c:?}");
assert!(near(c.first, 50.0, 0.0, 1e-9) && near(c.second, 50.0, 40.0, 1e-6), "{c:?}");
}
#[test]
fn a_crossing_line_gives_a_circle_on_each_side() {
let found = circles_through(line((0.0, 0.0), (100.0, 0.0)), 0.3, &[line((80.0, -100.0), (80.0, 100.0))]);
assert_eq!(found.len(), 2, "{found:?}");
for y in [50.0, -50.0] {
assert!(found.iter().any(|c| near(c.circle.center, 30.0, y, 1e-6) && (c.circle.radius - 50.0).abs() < 1e-6), "{y}: {found:?}");
}
}
#[test]
fn a_circle_that_crosses_the_first_segment_is_left_out() {
// Through (50, 75) on a flat first segment, the circle touching y = -200 has radius 137.5.
let below = [line((-500.0, -200.0), (500.0, -200.0))];
let flat = circles_through(line((0.0, 75.0), (100.0, 75.0)), 0.5, &below);
assert_eq!(flat.len(), 1, "{flat:?}");
assert!((flat[0].circle.radius - 137.5).abs() < 1e-6, "{flat:?}");
// On a hump from (0, 0) up to (50, 75) and back down to (100, 0), the same circle crosses the
// hump's sides (its center (50, -62.5) is 80 from (0, 0)), and none on the other side reaches.
let hump = CubicBez::new(Point::new(0.0, 0.0), Point::new(0.0, 100.0), Point::new(100.0, 100.0), Point::new(100.0, 0.0));
assert!(near(hump.eval(0.5), 50.0, 75.0, 1e-9));
let found = circles_through(hump, 0.5, &below);
assert!(found.is_empty(), "{found:?}");
}
#[test]
fn where_the_first_segment_turns_back_only_circles_that_touch_are_kept() {
// Out to (75, 0) and back: the normal flips at the turn, and the distance to the line jumps there.
let first = CubicBez::new(Point::new(0.0, 0.0), Point::new(100.0, 0.0), Point::new(100.0, 0.0), Point::new(0.0, 0.0));
let second = [line((-100.0, 40.0), (200.0, 40.0))];
let found = circles_of_radius(first, &second, 30.0);
for c in &found {
assert!((c.circle.center.y - 10.0).abs() < 1e-6 || (c.circle.center.y - 70.0).abs() < 1e-6, "{c:?}");
}
assert!(!found.iter().any(|c| (c.circle.center.x - 75.0).abs() < 1.0), "{found:?}");
}
#[test]
fn a_circle_through_a_point_touches_a_curved_segment() {
// The second segments are a Bézier circle of radius 20 about (50, 100): touched from outside,
// |center − (50, 100)| = r + 20 with the center at (50, r), so r = 40.
let ring = circle(50.0, 100.0, 20.0);
let segs: Vec<CubicBez> = (0..4).map(|i| ring.subpaths[0].segment(i)).collect();
let found = circles_through(line((0.0, 0.0), (100.0, 0.0)), 0.5, &segs);
assert_eq!(found.len(), 1, "{found:?}");
let c = found[0];
// Within the Bézier circle's own error (0.0273% of 20).
assert!((c.circle.radius - 40.0).abs() < 0.01 && near(c.circle.center, 50.0, 40.0, 0.01), "{c:?}");
assert!(near(c.second, 50.0, 80.0, 0.01), "{c:?}");
}
#[test]
fn on_a_curved_first_segment_the_center_is_on_the_normal() {
// A quarter of a ring of radius 50 about (0, 0); the second segment a line far off to the right.
let ring = circle(0.0, 0.0, 50.0);
let mut checked = 0;
for i in 0..4 {
let first = ring.subpaths[0].segment(i);
for t in [0.0, 0.3, 0.7, 1.0] {
let found = circles_through(first, t, &[line((300.0, -500.0), (300.0, 500.0))]);
let tangent = kurbo::ParamCurveDeriv::deriv(&first).eval(t).to_vec2();
for c in &found {
let to_center = c.circle.center - c.first;
assert!(to_center.dot(tangent).abs() <= 1e-9 * to_center.hypot() * tangent.hypot(), "{i} {t}: {c:?}");
checked += 1;
}
}
}
assert!(checked >= 8, "{checked}");
}
#[test]
fn a_radius_fills_the_corner_between_two_lines() {
let first = line((0.0, 0.0), (100.0, 0.0));
let found = circles_of_radius(first, &[line((100.0, 0.0), (100.0, 100.0))], 10.0);
// Outside the corner a circle tangent to the first line reaches the second only at the shared
// corner, where it touches both at one point: left out.
assert_eq!(found.len(), 1, "{found:?}");
let c = found[0];
assert!(near(c.circle.center, 90.0, 10.0, 1e-6) && c.circle.radius == 10.0, "{c:?}");
assert!(near(c.first, 90.0, 0.0, 1e-6) && near(c.second, 100.0, 10.0, 1e-6), "{c:?}");
}
#[test]
fn lines_twice_the_radius_apart_give_circles_all_along() {
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &[line((0.0, 40.0), (100.0, 40.0))], 20.0);
assert!(found.len() > 100, "{}", found.len());
assert!(found.iter().all(|c| (c.circle.center.y - 20.0).abs() < 1e-9 && c.circle.radius == 20.0), "{found:?}");
let xs: Vec<f64> = found.iter().map(|c| c.circle.center.x).collect();
assert!(xs.iter().any(|x| *x < 1.0) && xs.iter().any(|x| *x > 99.0), "from end to end: {xs:?}");
}
#[test]
fn a_circle_that_touches_a_curve_between_the_places_tried_is_found() {
// A ring of radius 20 about (50.3, 60): a circle of radius 20 on the line y = 0 reaches it only
// at x = 50.3, between the places tried along the line, without the distance changing sign.
let ring = circle(50.3, 60.0, 20.0);
let segs: Vec<CubicBez> = (0..4).map(|i| ring.subpaths[0].segment(i)).collect();
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &segs, 20.0);
assert_eq!(found.len(), 1, "{found:?}");
assert!(near(found[0].circle.center, 50.3, 20.0, 1e-3) && near(found[0].second, 50.3, 40.0, 1e-3), "{found:?}");
}
#[test]
fn a_touch_half_way_between_two_places_tried_is_found() {
// A point half way between the places tried at x = 50 and x = 50.1953125: the two samples
// either side are equally far from a touch.
let dot = line((50.097_656_25, 40.0), (50.097_656_25, 40.0));
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &[dot], 20.0);
assert_eq!(found.len(), 1, "{found:?}");
assert!(near(found[0].circle.center, 50.097_656_25, 20.0, 1e-6), "{found:?}");
}
#[test]
fn a_touch_between_the_end_and_the_next_place_tried_is_found() {
for x in [0.05, 99.95] {
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &[line((x, 40.0), (x, 40.0))], 20.0);
assert_eq!(found.len(), 1, "{x}: {found:?}");
assert!(near(found[0].circle.center, x, 20.0, 1e-6), "{x}: {found:?}");
}
}
#[test]
fn two_circles_between_the_same_two_places_tried_are_both_found() {
// A point a hair less than twice the radius from the line: two circles, about 0.02 pt either
// side of x = 50.05, both between the places tried at 50 and 50.1953125.
let (x, y) = (50.05, 39.99999);
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &[line((x, y), (x, y))], 20.0);
assert_eq!(found.len(), 2, "{found:?}");
let dx = (400.0 - (y - 20.0) * (y - 20.0)).sqrt();
assert!(near(found[0].circle.center, x - dx, 20.0, 1e-6) && near(found[1].circle.center, x + dx, 20.0, 1e-6), "{found:?}");
}
#[test]
fn a_tiny_circle_between_long_lines_close_together_is_found() {
let found = circles_through(line((0.0, 0.0), (100.0, 0.0)), 0.5, &[line((0.0, 1e-4), (100.0, 1e-4))]);
assert_eq!(found.len(), 1, "{found:?}");
assert!((found[0].circle.radius - 5e-5).abs() < 1e-12 && near(found[0].circle.center, 50.0, 5e-5, 1e-12), "{found:?}");
// A short line near a very long one: the long one's size does not hide the gap.
let found = circles_through(line((0.0, 0.0), (100.0, 0.0)), 0.5, &[line((-5e9, 1e-3), (5e9, 1e-3))]);
assert_eq!(found.len(), 1, "{found:?}");
assert!((found[0].circle.radius - 5e-4).abs() < 1e-9, "{found:?}");
// Lines 1e-5 pt apart moved 1e9 pt to the right.
let found = circles_through(line((1e9, 0.0), (1e9 + 100.0, 0.0)), 0.5, &[line((1e9, 1e-5), (1e9 + 100.0, 1e-5))]);
assert_eq!(found.len(), 1, "{found:?}");
assert!((found[0].circle.radius - 5e-6).abs() < 1e-9, "{found:?}");
}
#[test]
fn long_segments_far_apart_give_no_circle_of_a_small_radius() {
// Lines 1e10 pt long and 1450 pt apart: a circle of radius 500 on one stays 950 pt from the other.
let found = circles_of_radius(line((0.0, 0.0), (1e10, 0.0)), &[line((0.0, 1450.0), (1e10, 1450.0))], 500.0);
assert!(found.is_empty(), "{:?}", found.first());
// A radius of 1,000,000 pt and lines 0.05 pt more than twice that apart: no touch.
let found = circles_of_radius(line((0.0, 0.0), (100.0, 0.0)), &[line((0.0, 2_000_000.05), (100.0, 2_000_000.05))], 1e6);
assert!(found.is_empty(), "{:?}", found.first());
}
#[test]
fn no_circle_when_the_radius_is_too_small_or_the_point_is_on_the_second() {
let (first, other) = (line((0.0, 0.0), (100.0, 0.0)), line((0.0, 40.0), (100.0, 40.0)));
assert!(circles_of_radius(first, &[other], 5.0).is_empty());
for r in [0.0, -1.0, f64::NAN, f64::INFINITY] {
assert!(circles_of_radius(first, &[other], r).is_empty(), "{r}");
}
assert!(circles_through(first, 1.0, &[line((100.0, 0.0), (100.0, 100.0))]).is_empty(), "the point is on the second");
assert!(circles_through(first, 0.5, &[]).is_empty());
assert!(circles_through(first, f64::NAN, &[other]).is_empty());
let dot = line((5.0, 5.0), (5.0, 5.0));
assert!(circles_through(dot, 0.5, &[other]).is_empty(), "no direction");
}
+3
View File
@@ -17,6 +17,7 @@ pub mod polygonal_lasso;
pub mod shared_edge;
pub mod slide_anchor;
pub mod smart_pen;
pub mod tangent_circle;
pub mod trim;
use crate::{Tool, ToolInfo};
@@ -31,6 +32,7 @@ pub const PATH_TOOLS: &[ToolInfo] = &[
ToolInfo { id: corner_tool::ID, label: "Corner Tool", shortcut: None, icon: "dc-rounded-rect" },
ToolInfo { id: slide_anchor::ID, label: "Slide Anchor Along Path", shortcut: None, icon: "dc-anchor" },
ToolInfo { id: shared_edge::ID, label: "Shared Edge Merge Tool", shortcut: None, icon: "dc-join" },
ToolInfo { id: tangent_circle::ID, label: "Tangent Circle Tool", shortcut: None, icon: "circle" },
];
/// Smart Pen's tool, a flyout group of its own.
@@ -66,6 +68,7 @@ pub fn create(id: &str) -> Option<Box<dyn Tool>> {
shared_edge::ID => Box::new(shared_edge::SharedEdgeTool::default()),
slide_anchor::ID => Box::new(slide_anchor::SlideAnchorTool::default()),
smart_pen::ID => Box::new(smart_pen::SmartPenTool::default()),
tangent_circle::ID => Box::new(tangent_circle::TangentCircleTool::default()),
trim::ID => Box::new(trim::TrimTool::default()),
enclosing_lasso::ID => Box::new(enclosing_lasso::EnclosingLassoTool::default()),
contour::ID => Box::new(contour::ContourTool::default()),
+587
View File
@@ -0,0 +1,587 @@
//! Tangent Circle tool (Path Precision Tools): click a path segment, then another, selected or
//! not, to draw the circle that is tangent to the first segment where it was clicked and touches the
//! second ([`circles_through`]). With Shift held over the second segment the circle has the tool's
//! `radius` instead, anywhere along the first segment ([`circles_of_radius`]). A drag from the
//! second segment sets the radius to the drag's length: Shift steps it by a round number of points
//! about 4 screen pixels long, and Cmd/Ctrl pressed during the drag moves it by a tenth of the
//! pointer's movement (held at the press, Cmd/Ctrl lends the selection tool as it does for every
//! tool). The segments on either side of the second one count with it (the first one excepted),
//! and of the circles found the one touching them nearest the pointer is drawn. While the pointer
//! is over the second segment the circle shows with its center and radii; where there is none, a
//! note says so. The circle is a new ellipse with the current paint, drawn with
//! `shape.circleThroughPoints` in one undo step, so Align New Objects to Pixel Grid leaves it in
//! place. Escape, an edit or Undo outside the tool, or another document forgets the first segment.
use kurbo::{CubicBez, Shape};
use serde_json::{Value, json};
use vectorcraft_doc::NodeId;
use vectorcraft_geom::{BezPath, ParamCurve, Point};
use vectorcraft_pathops::addons::pathtools::{SegmentCircle, circles_of_radius, circles_through};
use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, ToolContext, ToolKey};
/// The tool's id.
pub const ID: &str = "tangentCircle";
/// The radius Shift asks for to start with (pt).
pub const RADIUS: f64 = 36.0;
/// The radius the `radius` option takes (pt).
pub const RADIUS_RANGE: (f64, f64) = (0.01, 1e6);
/// How far (screen pixels) the pointer moves from the second click before a drag sets the radius.
const DRAG_PX: f64 = 3.0;
/// About how long (screen pixels) one step of a Shift drag is.
const STEP_PX: f64 = 4.0;
/// How much of the pointer's movement a Cmd/Ctrl drag gives the radius.
const SLOW: f64 = 0.1;
/// The note shown over a second segment that gives no circle.
pub const NO_CIRCLE: &str = "No tangent circle here";
const BLUE: [u8; 3] = [0x4f, 0x9d, 0xff];
const RED: [u8; 3] = [0xe0, 0x3c, 0x3c];
const GREY: [u8; 3] = [0x80, 0x80, 0x80];
/// A segment under the pointer: where on it, and the segment itself.
#[derive(Clone, Debug, PartialEq)]
struct Pick {
id: NodeId,
subpath: usize,
segment: usize,
t: f64,
p: Point,
curve: CubicBez,
}
/// A press on the second segment, kept while the button is down.
#[derive(Clone, Debug, PartialEq)]
struct Press {
/// The segments a circle may touch.
second: Vec<CubicBez>,
/// Where the press was.
at: Point,
/// How far the pointer was from the press last time, and the radius the drag set (none until
/// the pointer moves far enough).
reach: f64,
radius: Option<f64>,
}
pub struct TangentCircleTool {
radius: f64,
first: Option<Pick>,
hover: Option<Pick>,
press: Option<Press>,
/// The circle the second segment gives, and whether one was looked for.
found: Option<SegmentCircle>,
looked: bool,
pointer: Point,
/// The circles the last second segment gave (its path, subpath and segment, and the radius
/// asked for), so that moving along it only picks among them.
cache: Option<(CacheKey, Vec<SegmentCircle>)>,
}
type CacheKey = (NodeId, usize, usize, Option<u64>);
impl Default for TangentCircleTool {
fn default() -> Self {
Self { radius: RADIUS, first: None, hover: None, press: None, found: None, looked: false, pointer: Point::ZERO, cache: None }
}
}
/// The path segment under `p`, of any editable path.
fn pick_at(cx: &ToolContext, p: Point) -> Option<Pick> {
let (id, subpath, segment, t) = crate::draw2::hit_segment(cx, p, cx.pick_tol())?;
let sp = cx.doc.node(id)?.path_data()?.subpaths.get(subpath)?;
if segment >= sp.segment_count() {
return None;
}
let curve = sp.segment(segment);
Some(Pick { id, subpath, segment, t, p: curve.eval(t), curve })
}
/// The segments a circle may touch when `second` is picked: it and the segments on either side of
/// it, without `first`. None when `second` is the first segment again.
fn second_set(cx: &ToolContext, first: &Pick, second: &Pick) -> Vec<CubicBez> {
if (first.id, first.subpath, first.segment) == (second.id, second.subpath, second.segment) {
return vec![];
}
let Some(sp) = cx.doc.node(second.id).and_then(|n| n.path_data()).and_then(|p| p.subpaths.get(second.subpath)) else { return vec![] };
let n = sp.segment_count();
let i = second.segment;
let mut indices = vec![i];
if i > 0 || sp.closed {
indices.push((i + n - 1) % n);
}
if i + 1 < n || sp.closed {
indices.push((i + 1) % n);
}
indices.sort_unstable();
indices.dedup();
let is_first = |k: usize| first.id == second.id && first.subpath == second.subpath && first.segment == k;
indices.into_iter().filter(|k| *k < n && !is_first(*k)).map(|k| sp.segment(k)).collect()
}
/// Of `circles`, the one touching the second segments nearest `at`.
fn nearest_to(circles: Vec<SegmentCircle>, at: Point) -> Option<SegmentCircle> {
circles.into_iter().min_by(|a, b| (a.second - at).hypot().total_cmp(&(b.second - at).hypot()))
}
/// The circles on `first` and `second`: tangent at the first pick, or of `radius`.
fn circles(first: &Pick, second: &[CubicBez], radius: Option<f64>) -> Vec<SegmentCircle> {
match radius {
Some(r) => circles_of_radius(first.curve, second, r),
None => circles_through(first.curve, first.t, second),
}
}
/// The step a Shift drag rounds the radius to: 1, 2 or 5 times a power of 10, at least `least`.
fn round_step(least: f64) -> f64 {
if !(least.is_finite() && least > 0.0) {
return 1.0;
}
let e = 10f64.powf(least.log10().floor());
[1.0, 2.0, 5.0, 10.0].into_iter().map(|m| m * e).find(|s| *s >= least).unwrap_or(10.0 * e)
}
/// Draw circle `c`: through three points spread around it, with `shape.circleThroughPoints`, which
/// leaves it where it is with Align New Objects to Pixel Grid on, so that it stays tangent. None
/// when the three points do not give the circle back to within `tol` (a circle too small for its
/// distance from the origin, or too large, in floating point).
fn draw(c: &SegmentCircle, tol: f64) -> Option<Action> {
let (at, r) = (c.circle.center, c.circle.radius);
let points: Vec<Point> = [90.0f64, 210.0, 330.0]
.iter()
.map(|deg| {
let (s, k) = deg.to_radians().sin_cos();
Point::new(at.x + r * k, at.y + r * s)
})
.collect();
let (back, rb) = vectorcraft_geom::shapes::circle_through(points[0], points[1], points[2])?;
if !(back.distance(at) <= tol && (rb - r).abs() <= tol) {
return None;
}
let points: Vec<[f64; 2]> = points.iter().map(|p| [p.x, p.y]).collect();
Some(Action::Exec("shape.circleThroughPoints".into(), json!({ "points": points })))
}
fn segment_path(c: &CubicBez) -> BezPath {
let mut bp = BezPath::new();
bp.move_to(c.p0);
bp.curve_to(c.p1, c.p2, c.p3);
bp
}
impl TangentCircleTool {
/// The radius a drag gives, with Shift in round steps.
fn shown_radius(cx: &ToolContext, r: f64, shift: bool) -> f64 {
if !shift {
return r;
}
let step = round_step(cx.tol(STEP_PX));
// Less than half a step rounds to 0: no circle, as without Shift.
(r / step).round() * step
}
/// The circles `pick` gives as the second segment, with Shift's `radius`: worked out again only
/// when the segment or the radius changes.
fn circles_on(&mut self, cx: &ToolContext, pick: &Pick, radius: Option<f64>) -> Vec<SegmentCircle> {
let key = (pick.id, pick.subpath, pick.segment, radius.map(f64::to_bits));
if let Some((k, found)) = &self.cache
&& *k == key
{
return found.clone();
}
let Some(first) = &self.first else { return vec![] };
let found = circles(first, &second_set(cx, first, pick), radius);
self.cache = Some((key, found.clone()));
found
}
/// Look for the circle the pointer at `p` would give over `hover`, before any press.
fn look(&mut self, cx: &ToolContext, p: Point, mods: Mods) {
self.found = None;
self.looked = false;
let Some(hover) = self.hover.clone().filter(|_| self.first.is_some()) else { return };
let found = self.circles_on(cx, &hover, mods.shift.then_some(self.radius));
self.found = nearest_to(found, p);
self.looked = true;
}
/// The pointer at `ev` during a press on the second segment: once it is far enough from the
/// press, the radius follows it (Cmd/Ctrl: a tenth of its movement; Shift: round steps).
fn drag_to(&mut self, cx: &ToolContext, ev: &PointerEvent) {
let (Some(first), Some(press)) = (&self.first, &mut self.press) else { return };
let reach = ev.pos.distance(press.at);
let gear = if ev.mods.cmd { SLOW } else { 1.0 };
let r = match press.radius {
None if reach <= cx.tol(DRAG_PX) => return,
None => reach * gear,
Some(r) => (r + (reach - press.reach) * gear).max(0.0),
};
press.reach = reach;
press.radius = Some(r);
let shown = Self::shown_radius(cx, r, ev.mods.shift);
// Dragged back to the press: a radius of 0, and no circle.
self.found = if shown > 0.0 { nearest_to(circles(first, &press.second, Some(shown)), press.at) } else { None };
}
fn forget(&mut self) {
self.first = None;
self.press = None;
self.found = None;
self.looked = false;
self.cache = None;
}
}
impl Tool for TangentCircleTool {
fn id(&self) -> &'static str {
ID
}
fn busy(&self) -> bool {
self.press.is_some()
}
fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec<Action> {
self.pointer = ev.pos;
match ev.kind {
PointerKind::Move => {
self.hover = pick_at(cx, ev.pos);
self.look(cx, ev.pos, ev.mods);
vec![]
}
PointerKind::Down => {
let Some(pick) = pick_at(cx, ev.pos) else { return vec![] };
let Some(first) = self.first.clone() else {
self.first = Some(pick);
self.hover = None;
self.found = None;
self.looked = false;
return vec![];
};
let second = second_set(cx, &first, &pick);
let found = self.circles_on(cx, &pick, ev.mods.shift.then_some(self.radius));
self.found = nearest_to(found, ev.pos);
self.looked = true;
self.hover = None;
self.press = Some(Press { second, at: ev.pos, reach: 0.0, radius: None });
vec![]
}
PointerKind::Drag => {
self.drag_to(cx, ev);
vec![]
}
// The second click of a double-click releases with `DoubleClick` instead of `Up`.
PointerKind::Up | PointerKind::DoubleClick => {
// The release's own position and keys set the radius of a drag.
self.drag_to(cx, ev);
if self.press.take().is_none() {
return vec![];
}
// No circle, or one the three points cannot draw: the first segment stays picked,
// for another try.
let Some(action) = self.found.take().and_then(|c| draw(&c, cx.tol(0.05))) else { return vec![] };
self.forget();
vec![action]
}
PointerKind::TripleClick => vec![],
}
}
fn key(&mut self, _cx: &ToolContext, key: ToolKey, _mods: Mods) -> Vec<Action> {
if key == ToolKey::Escape && self.first.is_some() {
self.forget();
}
vec![]
}
fn claims_key(&self, _cx: &ToolContext, key: ToolKey) -> bool {
key == ToolKey::Escape && self.first.is_some()
}
/// An edit, Undo or Redo outside the tool, or another document: the first segment may be gone.
fn history_moved(&mut self) {
self.forget();
self.hover = None;
}
/// The segment and the circle shown depend on what lies under the pointer, which panning,
/// zooming or an edit changes.
fn wants_rehover(&self) -> bool {
true
}
fn hover_ended(&mut self, _cx: &ToolContext) {
self.hover = None;
if self.press.is_none() {
self.found = None;
self.looked = false;
}
}
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
let mut out = vec![];
if let Some(first) = &self.first {
out.push(Overlay::Path { path: segment_path(&first.curve), color: BLUE, width: 2.0, dashed: false });
out.push(Overlay::Anchor { p: first.p, color: BLUE, filled: true, size: 7.0 });
}
if let Some(hover) = &self.hover {
out.push(Overlay::Path { path: segment_path(&hover.curve), color: BLUE, width: 1.0, dashed: false });
out.push(Overlay::Anchor { p: hover.p, color: BLUE, filled: false, size: 7.0 });
}
if let Some(press) = &self.press
&& press.radius.is_some()
{
out.push(Overlay::Line { a: press.at, b: self.pointer, color: GREY, dashed: false });
}
if let Some(c) = &self.found {
let (at, r) = (c.circle.center, c.circle.radius);
// A tolerance of at least a ten-thousandth of the radius keeps a huge circle to a few
// dozen segments.
let tol = cx.tol(0.1).max(r * 1e-4);
out.push(Overlay::Path { path: kurbo::Circle::new(at, r).to_path(tol), color: RED, width: 1.0, dashed: false });
let arm = cx.tol(4.0);
out.push(Overlay::Line { a: at - kurbo::Vec2::new(arm, 0.0), b: at + kurbo::Vec2::new(arm, 0.0), color: RED, dashed: false });
out.push(Overlay::Line { a: at - kurbo::Vec2::new(0.0, arm), b: at + kurbo::Vec2::new(0.0, arm), color: RED, dashed: false });
out.push(Overlay::Line { a: at, b: c.first, color: RED, dashed: true });
out.push(Overlay::Line { a: at, b: c.second, color: RED, dashed: true });
out.push(Overlay::Measure { p: self.pointer, text: format!("R: {}", cx.len(r)) });
} else if self.looked {
// A label, which the canvas shows in the interface language.
out.push(Overlay::Label { p: self.pointer, text: NO_CIRCLE.into(), color: RED });
}
out
}
fn cursor(&self, _cx: &ToolContext, _p: Point, _mods: Mods) -> Cursor {
Cursor::Crosshair
}
fn options(&self) -> Value {
json!({ "radius": self.radius })
}
fn set_option(&mut self, key: &str, v: &Value) {
if key == "radius"
&& let Some(r) = v.as_f64().filter(|r| (RADIUS_RANGE.0..=RADIUS_RANGE.1).contains(r))
{
self.radius = r;
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::testutil::*;
use vectorcraft_doc::{Appearance, Document, Node, Selection};
use vectorcraft_geom::{PathData, SubPath};
/// Two open lines, (100, 100)–(300, 100) and (100, 140)–(300, 140), and an L from (100, 300)
/// over to (300, 300) and down to (300, 400).
fn doc() -> Document {
let mut d = Document::new(500.0, 500.0);
let l = d.layers[0].id;
let lines: [&[(f64, f64)]; 3] =
[&[(100.0, 100.0), (300.0, 100.0)], &[(100.0, 140.0), (300.0, 140.0)], &[(100.0, 300.0), (300.0, 300.0), (300.0, 400.0)]];
for pts in lines {
let id = d.alloc_id();
let pts: Vec<Point> = pts.iter().map(|(x, y)| Point::new(*x, *y)).collect();
d.insert(Some(l), 0, Node::path(id, PathData::single(SubPath::polyline(&pts, false)), Appearance::default_art())).unwrap();
}
d
}
fn ev(kind: PointerKind, x: f64, y: f64) -> PointerEvent {
PointerEvent::new(kind, x, y)
}
fn shifted(kind: PointerKind, x: f64, y: f64) -> PointerEvent {
let mut e = ev(kind, x, y);
e.mods.shift = true;
e
}
/// The circle an action list draws, as the box around it: (x, y, width, height).
fn drawn(actions: &[Action]) -> (f64, f64, f64, f64) {
let [Action::Exec(cmd, p)] = actions else { panic!("{actions:?}") };
assert_eq!(cmd, "shape.circleThroughPoints");
let pts: Vec<Point> = p["points"].as_array().unwrap().iter().map(|q| Point::new(q[0].as_f64().unwrap(), q[1].as_f64().unwrap())).collect();
let (at, r) = vectorcraft_geom::shapes::circle_through(pts[0], pts[1], pts[2]).unwrap();
(at.x - r, at.y - r, 2.0 * r, 2.0 * r)
}
fn close(a: (f64, f64, f64, f64), b: (f64, f64, f64, f64)) -> bool {
[(a.0, b.0), (a.1, b.1), (a.2, b.2), (a.3, b.3)].iter().all(|(x, y)| (x - y).abs() < 1e-4)
}
#[test]
fn two_clicks_draw_the_circle_tangent_at_the_first_click() {
let d = doc();
let (sel, p) = (Selection::default(), paint());
let cx = cx(&d, &sel, &p);
let mut t = TangentCircleTool::default();
assert_eq!(t.cursor(&cx, Point::ZERO, Mods::default()), Cursor::Crosshair);
assert!(t.pointer(&cx, &ev(PointerKind::Down, 150.0, 101.0)).is_empty(), "the first segment");
assert!(t.pointer(&cx, &ev(PointerKind::Up, 150.0, 101.0)).is_empty());
// Over the second line: the circle through (150, 100) touching it shows, 20 pt in radius.
t.pointer(&cx, &ev(PointerKind::Move, 200.0, 139.0));
let ov = t.overlays(&cx);
assert!(ov.iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text.starts_with("R: 20.00"))), "{ov:?}");
assert!(ov.iter().filter(|o| matches!(o, Overlay::Line { dashed: true, .. })).count() == 2, "the radii: {ov:?}");
// Moving along the same segment picks among the circles already found.
let kept = t.cache.clone();
assert!(kept.as_ref().is_some_and(|(_, c)| c.len() == 1));
t.pointer(&cx, &ev(PointerKind::Move, 250.0, 139.0));
assert_eq!(t.cache, kept);
assert!(t.pointer(&cx, &ev(PointerKind::Down, 200.0, 139.0)).is_empty());
let up = t.pointer(&cx, &ev(PointerKind::Up, 200.0, 139.0));
assert!(close(drawn(&up), (130.0, 100.0, 40.0, 40.0)), "{up:?}");
assert!(t.first.is_none() && t.overlays(&cx).is_empty(), "ready for the next circle");
// A quick second click on the second segment releases with a double-click: the same circle.
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 101.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 101.0));
t.pointer(&cx, &ev(PointerKind::Down, 200.0, 139.0));
let up = t.pointer(&cx, &ev(PointerKind::DoubleClick, 200.0, 139.0));
assert!(close(drawn(&up), (130.0, 100.0, 40.0, 40.0)) && !t.busy(), "{up:?}");
}
#[test]
fn shift_uses_the_radius_and_a_corner_takes_its_fillet() {
let d = doc();
let (sel, p) = (Selection::default(), paint());
let cx = cx(&d, &sel, &p);
let mut t = TangentCircleTool::default();
t.set_option("radius", &json!(10));
t.set_option("radius", &json!(0));
t.set_option("radius", &json!(f64::NAN));
assert_eq!(t.options()["radius"], json!(10.0));
// The L's two segments: the circle of radius 10 in its corner.
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 300.0));
t.pointer(&cx, &shifted(PointerKind::Down, 300.0, 350.0));
let up = t.pointer(&cx, &shifted(PointerKind::Up, 300.0, 350.0));
assert!(close(drawn(&up), (280.0, 300.0, 20.0, 20.0)), "{up:?}");
}
#[test]
fn a_drag_sets_the_radius_with_shift_steps_and_a_slow_drag() {
let d = doc();
let (sel, p) = (Selection::default(), paint());
let cx = cx(&d, &sel, &p);
let mut t = TangentCircleTool::default();
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Down, 300.0, 350.0));
assert!(t.busy());
// A drag 12.3 pt long asks for that radius; Shift rounds it (4 px at 100%: steps of 5).
assert!(t.pointer(&cx, &ev(PointerKind::Drag, 300.0, 362.3)).is_empty());
assert!(t.overlays(&cx).iter().any(|o| matches!(o, Overlay::Line { dashed: false, color, .. } if *color == GREY)));
assert!((t.found.unwrap().circle.radius - 12.3).abs() < 1e-6);
t.pointer(&cx, &shifted(PointerKind::Drag, 300.0, 362.3));
assert!((t.found.unwrap().circle.radius - 10.0).abs() < 1e-9);
// Cmd/Ctrl: 10 pt more of drag adds 1 pt.
let mut slow = ev(PointerKind::Drag, 300.0, 372.3);
slow.mods.cmd = true;
t.pointer(&cx, &slow);
assert!((t.found.unwrap().circle.radius - 13.3).abs() < 1e-6, "{:?}", t.found);
let up = t.pointer(&cx, &ev(PointerKind::Up, 300.0, 372.3));
assert!(close(drawn(&up), (286.7 - 13.3, 300.0, 26.6, 26.6)), "{up:?}");
// A drag back past its press asks for no radius: no circle, not one through the first click.
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Down, 300.0, 350.0));
t.pointer(&cx, &ev(PointerKind::Drag, 300.0, 360.0));
t.pointer(&cx, &ev(PointerKind::Drag, 300.0, 350.0));
assert!(t.found.is_none(), "{:?}", t.found);
t.pointer(&cx, &shifted(PointerKind::Drag, 300.0, 350.0));
assert!(t.found.is_none(), "with Shift too: {:?}", t.found);
assert!(t.pointer(&cx, &ev(PointerKind::Up, 300.0, 350.0)).is_empty());
// A release away from the last drag event: the release sets the radius.
t.pointer(&cx, &ev(PointerKind::Down, 300.0, 350.0));
t.pointer(&cx, &ev(PointerKind::Drag, 300.0, 360.0));
let up = t.pointer(&cx, &ev(PointerKind::Up, 300.0, 365.0));
assert!(close(drawn(&up), (300.0 - 30.0, 300.0, 30.0, 30.0)), "{up:?}");
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 300.0));
// Cmd/Ctrl held from the start: a 20 pt drag gives 2 pt.
t.pointer(&cx, &ev(PointerKind::Down, 300.0, 350.0));
let mut slow = ev(PointerKind::Drag, 300.0, 370.0);
slow.mods.cmd = true;
t.pointer(&cx, &slow);
assert!((t.found.unwrap().circle.radius - 2.0).abs() < 1e-6, "{:?}", t.found);
assert_eq!(round_step(2.0), 2.0);
assert_eq!(round_step(0.3), 0.5);
assert_eq!(round_step(7.0), 10.0);
}
#[test]
fn no_circle_says_so_and_escape_forgets_the_first_segment() {
let d = doc();
let (sel, p) = (Selection::default(), paint());
let cx = cx(&d, &sel, &p);
let mut t = TangentCircleTool::default();
// The first segment again (on the L, whose other segment is beside it): no circle.
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 300.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 300.0));
t.pointer(&cx, &shifted(PointerKind::Move, 200.0, 300.0));
assert!(t.found.is_none() && t.looked, "{:?}", t.found);
t.key(&cx, ToolKey::Escape, Mods::default());
// Nothing under the pointer: nothing picked.
assert!(t.pointer(&cx, &ev(PointerKind::Down, 50.0, 50.0)).is_empty());
assert!(t.first.is_none());
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 100.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 100.0));
// Shift with a radius of 5: no circle reaches the line 40 pt away.
t.set_option("radius", &json!(5));
t.pointer(&cx, &shifted(PointerKind::Move, 200.0, 140.0));
assert!(t.overlays(&cx).iter().any(|o| matches!(o, Overlay::Label { text, .. } if text == NO_CIRCLE)));
assert!(t.wants_rehover(), "the note follows what lies under a still pointer");
t.pointer(&cx, &shifted(PointerKind::Down, 200.0, 140.0));
assert!(t.pointer(&cx, &shifted(PointerKind::Up, 200.0, 140.0)).is_empty(), "nothing drawn");
assert!(t.first.is_some(), "the first segment stays for another try");
assert!(t.claims_key(&cx, ToolKey::Escape));
t.key(&cx, ToolKey::Escape, Mods::default());
assert!(t.first.is_none() && !t.claims_key(&cx, ToolKey::Escape));
// An edit the tool did not make (or Undo, or another document) forgets it too.
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 100.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 100.0));
assert!(t.first.is_some());
t.history_moved();
assert!(t.first.is_none() && t.overlays(&cx).is_empty());
}
#[test]
fn a_circle_the_three_points_cannot_draw_keeps_the_first_segment() {
// A circle the geometry found, moved to (x, 0) and given radius `r`.
let line = |y: f64| CubicBez::new(Point::new(0.0, y), Point::new(30.0, y), Point::new(60.0, y), Point::new(90.0, y));
let found = circles_of_radius(line(0.0), &[line(40.0)], 20.0);
let circle = |x: f64, r: f64| {
let mut c = found[0];
(c.circle.center, c.circle.radius, c.first, c.second) = (Point::new(x, 0.0), r, Point::new(x, -r), Point::new(x, r));
c
};
assert!(draw(&circle(100.0, 20.0), 1e-3).is_some());
// At 10⁹ pt from the origin, where coordinates step by about 1.2e-7 pt, a radius of 5e-8 pt
// rounds the three points onto one line.
assert!(draw(&circle(1e9, 5e-8), 1e-3).is_none());
let d = doc();
let (sel, p) = (Selection::default(), paint());
let cx = cx(&d, &sel, &p);
let mut t = TangentCircleTool::default();
t.pointer(&cx, &ev(PointerKind::Down, 150.0, 101.0));
t.pointer(&cx, &ev(PointerKind::Up, 150.0, 101.0));
t.pointer(&cx, &ev(PointerKind::Down, 200.0, 139.0));
t.found = Some(circle(1e9, 5e-8));
assert!(t.pointer(&cx, &ev(PointerKind::Up, 200.0, 139.0)).is_empty(), "nothing drawn");
assert!(t.first.is_some(), "the first segment stays for another try");
// A huge circle (segments 10³⁰ pt apart) shows with a few dozen segments, not millions.
t.found = Some(circle(0.0, 1e30));
let segments: Vec<usize> = t
.overlays(&cx)
.iter()
.filter_map(|o| match o {
Overlay::Path { path, color, .. } if *color == RED => Some(path.elements().len()),
_ => None,
})
.collect();
assert!(matches!(segments[..], [n] if n < 100), "{segments:?}");
}
}
+1
View File
@@ -79,6 +79,7 @@ const ROWS: &[Row] = &[
(&[crate::addons::extend_path::ID], None, &["mode"]),
(&[crate::addons::corner_tool::ID], None, &["radius", "kind"]),
(&[crate::addons::shared_edge::ID], None, &["diameter", "tolerance", "together"]),
(&[crate::addons::tangent_circle::ID], None, &["radius"]),
(&[crate::addons::smart_pen::ID], None, &["next"]),
// The kind first: a new kind resets the values after it.
(&[crate::addons::parametric_shape::ID], None, &["kind", "count", "a", "b", "radius", "width", "height", "rotation"]),
+13 -1
View File
@@ -16,6 +16,7 @@ pub mod tangent_circle;
use egui::Ui;
use serde_json::{Map, Value, json};
use vectorcraft_geom::Point;
use vectorcraft_tools::addons::tangent_circle as tangent_circle_tool;
use vectorcraft_tools::addons::{anchor_eraser, extend_path, measure_inspect, parametric_shape, slide_anchor, trim};
use crate::VectorcraftApp;
@@ -65,6 +66,7 @@ pub fn menu() -> Vec<Item> {
Item::Cmd("Set Corners…", set_corners::COMMAND, Value::Null),
tool("Slide Anchor Along Path", slide_anchor::ID),
Item::Cmd("Shared Edge Merge Tool", shared_edge::COMMAND, json!({})),
tool("Tangent Circle Tool", tangent_circle_tool::ID),
tool("Trim at Crossings Tool", trim::ID),
Item::Sep,
Item::Cmd("Anchor Inspector", "window.panel", json!({ "panel": ID })),
@@ -197,7 +199,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
/// Tools whose options the dialog edits.
pub fn has_options(tool: &str) -> bool {
[anchor_eraser::ID, extend_path::ID].contains(&tool)
[anchor_eraser::ID, extend_path::ID, tangent_circle_tool::ID].contains(&tool)
}
/// Open the options of add-on tool `tool` with its current values.
@@ -227,6 +229,16 @@ fn body(_app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog) -> bool {
});
return false;
}
if d.str("__tool") == tangent_circle_tool::ID {
let (lo, hi) = tangent_circle_tool::RADIUS_RANGE;
let r = d.f64("radius", tangent_circle_tool::RADIUS);
widgets::label_row(ui, tl!("Radius:"), LABEL_W, |ui| {
if let Some(x) = widgets::range_field(ui, "tangent-circle-radius", r, lo..=hi, " pt", 2, 96.0) {
d.fields.insert("radius".into(), json!(x));
}
});
return false;
}
let rows = [
("size", "Size:", anchor_eraser::SIZE_RANGE, "px", anchor_eraser::SIZE),
("tolerance", "Tolerance:", anchor_eraser::TOLERANCE_RANGE, "", anchor_eraser::TOLERANCE),
@@ -22,6 +22,7 @@ fn the_plugins_submenu_selects_the_tools_and_opens_the_anchor_inspector() {
("Measure & Inspect Tool", "measureInspect"),
("Parametric Shape Tool", "parametricShape"),
("Slide Anchor Along Path", "slideAnchor"),
("Tangent Circle Tool", "tangentCircle"),
("Trim at Crossings Tool", "trimAtCrossings"),
] {
let e = under(label).expect(label);
@@ -98,6 +99,14 @@ fn double_clicking_the_brush_opens_its_options_and_ok_sets_them() {
app.ui.dialog.as_mut().unwrap().fields.insert("mode".into(), json!("arc"));
crate::dialogs::confirm(&mut app).unwrap();
assert_eq!(app.session.tool_options_of("extendPath")["mode"], json!("arc"));
// The Tangent Circle tool's radius for Shift.
app.run("tool.options", json!({"tool": "tangentCircle"})).unwrap();
assert_eq!(app.ui.dialog.as_ref().unwrap().f64("radius", 0.0), 36.0);
let text = painted_text(&mut app, |app, ui| crate::dialogs::show(app, ui.ctx()));
assert!(text.contains("Tangent Circle Tool Options") && text.contains("Radius:"), "{text}");
app.ui.dialog.as_mut().unwrap().fields.insert("radius".into(), json!(12.5));
crate::dialogs::confirm(&mut app).unwrap();
assert_eq!(app.session.tool_options_of("tangentCircle")["radius"], json!(12.5));
assert!(app.run("tool.options", json!({"tool": "measureInspect"})).is_err());
}
+2 -1
View File
@@ -761,6 +761,7 @@ fn addon_tools_are_in_the_drawer_not_the_toolbars() {
"cornerTool",
"slideAnchor",
"sharedEdge",
"tangentCircle",
"smartPen",
contour,
box3d,
@@ -776,7 +777,7 @@ fn addon_tools_are_in_the_drawer_not_the_toolbars() {
let listed = |id: &str| {
sections().iter().find(|(_, tools)| tools.iter().any(|t| t.id == id)).map(|(h, tools)| (*h, tools.iter().map(|t| t.id).collect::<Vec<_>>()))
};
assert_eq!(listed("extendPath"), Some(("Path Precision Tools", addon[..7].to_vec())));
assert_eq!(listed("extendPath"), Some(("Path Precision Tools", addon[..8].to_vec())));
assert_eq!(listed("smartPen"), Some(("Smart Pen", vec!["smartPen"])));
assert_eq!(listed(contour), Some(("Contour", vec![contour])));
assert_eq!(listed(box3d), Some(("3D Box", vec![box3d])));
+2
View File
@@ -6994,6 +6994,8 @@ breakText Glyphs Глифи
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Допирателна окръжност…
Tangent Circle Допирателна окръжност
Tangent Circle Tool Инструмент „Допирателна окръжност“
No tangent circle here Тук няма допирателна окръжност
Circle: Окръжност:
@msg `ids` names an object twice `ids` посочва обект два пъти
@msg select two or three paths or compound paths изберете два или три пътя или съставни пътя
Can't render this file because it is too large.
+2
View File
@@ -7043,6 +7043,8 @@ shape Open Otvoren
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Tangentna kružnica…
Tangent Circle Tangentna kružnica
Tangent Circle Tool Alat tangentna kružnica
No tangent circle here Ovdje nema tangentne kružnice
Circle: Kružnica:
@msg `ids` names an object twice `ids` navodi objekat dvaput
@msg select two or three paths or compound paths odaberite dvije ili tri putanje ili složene putanje
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -7764,6 +7764,8 @@ breakText Glyphs Glifs
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Cercle tangent…
Tangent Circle Cercle tangent
Tangent Circle Tool Eina de cercle tangent
No tangent circle here Aquí no hi ha cap cercle tangent
Circle: Cercle:
@msg `ids` names an object twice `ids` indica un objecte dues vegades
@msg select two or three paths or compound paths seleccioneu dos o tres camins o camins compostos
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -7749,6 +7749,8 @@ breakText Glyphs Glyfy
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Tečná kružnice…
Tangent Circle Tečná kružnice
Tangent Circle Tool Nástroj Tečná kružnice
No tangent circle here Zde není žádná tečná kružnice
Circle: Kružnice:
@msg `ids` names an object twice `ids` uvádí některý objekt dvakrát
@msg select two or three paths or compound paths vyberte dvě nebo tři cesty nebo složené cesty
Can't render this file because it is too large.
+2
View File
@@ -9808,6 +9808,8 @@ breakText Glyphs Glyffer
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Tangentcirkel…
Tangent Circle Tangentcirkel
Tangent Circle Tool Tangentcirkel-værktøj
No tangent circle here Ingen tangentcirkel her
Circle: Cirkel:
@msg `ids` names an object twice `ids` nævner et objekt to gange
@msg select two or three paths or compound paths vælg to eller tre stier eller sammensatte stier
Can't render this file because it is too large.
+2
View File
@@ -7344,6 +7344,8 @@ breakText Glyphs Glyphen
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Tangentialkreis…
Tangent Circle Tangentialkreis
Tangent Circle Tool Tangentialkreis-Werkzeug
No tangent circle here Hier kein Tangentialkreis
Circle: Kreis:
@msg `ids` names an object twice `ids` nennt ein Objekt zweimal
@msg select two or three paths or compound paths wählen Sie zwei oder drei Pfade oder zusammengesetzte Pfade aus
Can't render this file because it is too large.
+2
View File
@@ -7737,6 +7737,8 @@ breakText Glyphs Γλύφοι
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Εφαπτόμενος κύκλος…
Tangent Circle Εφαπτόμενος κύκλος
Tangent Circle Tool Εφαπτόμενος κύκλος (Tangent Circle Tool)
No tangent circle here Δεν υπάρχει εφαπτόμενος κύκλος εδώ
Circle: Κύκλος:
@msg `ids` names an object twice το `ids` αναφέρει ένα αντικείμενο δύο φορές
@msg select two or three paths or compound paths επιλέξτε δύο ή τρεις διαδρομές ή σύνθετες διαδρομές
Can't render this file because it is too large.
+2
View File
@@ -7725,6 +7725,8 @@ breakText Glyphs Glifos
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Círculo tangente…
Tangent Circle Círculo tangente
Tangent Circle Tool Herramienta Círculo tangente
No tangent circle here No hay círculo tangente aquí
Circle: Círculo:
@msg `ids` names an object twice `ids` indica un objeto dos veces
@msg select two or three paths or compound paths seleccione dos o tres trazados o trazados compuestos
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -7813,6 +7813,8 @@ breakText Glyphs Merkit
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Sivuava ympyrä…
Tangent Circle Sivuava ympyrä
Tangent Circle Tool Sivuava ympyrä -työkalu
No tangent circle here Tässä ei ole sivuavaa ympyrää
Circle: Ympyrä:
@msg `ids` names an object twice `ids` mainitsee saman objektin kahdesti
@msg select two or three paths or compound paths valitse kaksi tai kolme polkua tai yhdistelmäpolkua
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -7744,6 +7744,8 @@ breakText Glyphs Glyphes
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Cercle tangent…
Tangent Circle Cercle tangent
Tangent Circle Tool Outil Cercle tangent
No tangent circle here Aucun cercle tangent ici
Circle: Cercle :
@msg `ids` names an object twice `ids` désigne deux fois le même objet
@msg select two or three paths or compound paths sélectionnez deux ou trois tracés ou tracés transparents
Can't render this file because it is too large.
+2
View File
@@ -4051,6 +4051,8 @@
Tabs ટૅબ
Tamil તમિલ
Tangent Circle સ્પર્શક વર્તુળ
Tangent Circle Tool સ્પર્શક વર્તુળ ટૂલ
No tangent circle here અહીં કોઈ સ્પર્શક વર્તુળ નથી
Tangent Circle… સ્પર્શક વર્તુળ…
Taper ટેપર
Target લક્ષ્ય
Can't render this file because it contains an unexpected character in line 72 and column 5.
+2
View File
@@ -5328,6 +5328,8 @@ antiAlias Sharp शार्प
Tail: पूंछ:
Tamil तमिल
Tangent Circle स्पर्शी वृत्त
Tangent Circle Tool स्पर्शी वृत्त टूल
No tangent circle here यहाँ कोई स्पर्शी वृत्त नहीं है
Tangent Circle… स्पर्शी वृत्त…
Taper टेपर
Target लक्ष्य
Can't render this file because it is too large.
+2
View File
@@ -7734,6 +7734,8 @@ breakText Glyphs Glifák
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Érintőkör…
Tangent Circle Érintőkör
Tangent Circle Tool Érintőkör eszköz
No tangent circle here Itt nincs érintőkör
Circle: Kör:
@msg `ids` names an object twice `ids`: egy objektumot kétszer nevez meg
@msg select two or three paths or compound paths jelölj ki két vagy három útvonalat vagy összetett útvonalat
Can't render this file because it is too large.
+2
View File
@@ -7011,6 +7011,8 @@ breakText Glyphs Glif
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Lingkaran singgung…
Tangent Circle Lingkaran singgung
Tangent Circle Tool Alat lingkaran singgung
No tangent circle here Tidak ada lingkaran singgung di sini
Circle: Lingkaran:
@msg `ids` names an object twice `ids` menyebut satu objek dua kali
@msg select two or three paths or compound paths pilih dua atau tiga jalur atau jalur gabungan
Can't render this file because it contains an unexpected character in line 2528 and column 5.
+2
View File
@@ -7382,6 +7382,8 @@ breakText Glyphs Glifi
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Cerchio tangente…
Tangent Circle Cerchio tangente
Tangent Circle Tool Strumento Cerchio tangente
No tangent circle here Nessun cerchio tangente qui
Circle: Cerchio:
@msg `ids` names an object twice `ids` indica due volte lo stesso oggetto
@msg select two or three paths or compound paths seleziona due o tre tracciati o tracciati composti
Can't render this file because it is too large.
+2
View File
@@ -9265,6 +9265,8 @@ breakText Glyphs 字形
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… 接円…
Tangent Circle 接円
Tangent Circle Tool 接円ツール
No tangent circle here ここに接円はありません
Circle: 円:
@msg `ids` names an object twice `ids` に同じオブジェクトが 2 回指定されています
@msg select two or three paths or compound paths パスまたは複合パスを 2 つか 3 つ選択してください
Can't render this file because it is too large.
+2
View File
@@ -9960,6 +9960,8 @@ breakText Glyphs გლიფები
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… მხები წრე…
Tangent Circle მხები წრე
Tangent Circle Tool მხები წრის ხელსაწყო
No tangent circle here აქ მხები წრე არ არის
Circle: წრე:
@msg `ids` names an object twice `ids` ერთსა და იმავე ობიექტს ორჯერ მიუთითებს
@msg select two or three paths or compound paths მონიშნეთ ორი ან სამი ტრაექტორია ან შედგენილი ტრაექტორია
Can't render this file because it is too large.
+2
View File
@@ -7346,6 +7346,8 @@ breakText Glyphs 글리프
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… 접원…
Tangent Circle 접원
Tangent Circle Tool 접원 도구
No tangent circle here 여기에는 접원이 없음
Circle: 원:
@msg `ids` names an object twice `ids`에 같은 오브젝트가 두 번 있습니다
@msg select two or three paths or compound paths 패스나 컴파운드 패스를 두 개 또는 세 개 선택하세요
Can't render this file because it is too large.
+2
View File
@@ -9640,6 +9640,8 @@ breakText Glyphs Glyphs
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Raakcirkel…
Tangent Circle Raakcirkel
Tangent Circle Tool Raakcirkel-gereedschap
No tangent circle here Hier geen raakcirkel
Circle: Cirkel:
@msg `ids` names an object twice `ids` noemt een object twee keer
@msg select two or three paths or compound paths selecteer twee of drie paden of samengestelde paden
Can't render this file because it is too large.
+2
View File
@@ -7612,6 +7612,8 @@ breakText Glyphs Glify
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Okrąg styczny…
Tangent Circle Okrąg styczny
Tangent Circle Tool Narzędzie Okrąg styczny
No tangent circle here Brak okręgu stycznego w tym miejscu
Circle: Okrąg:
@msg `ids` names an object twice `ids` wskazuje ten sam obiekt dwa razy
@msg select two or three paths or compound paths zaznacz dwie lub trzy ścieżki lub ścieżki złożone
Can't render this file because it is too large.
+2
View File
@@ -7776,6 +7776,8 @@ breakText Glyphs Glifos
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Círculo tangente…
Tangent Circle Círculo tangente
Tangent Circle Tool Ferramenta Círculo tangente
No tangent circle here Nenhum círculo tangente aqui
Circle: Círculo:
@msg `ids` names an object twice `ids` indica um objeto duas vezes
@msg select two or three paths or compound paths selecione dois ou três caminhos ou caminhos compostos
Can't render this file because it is too large.
+2
View File
@@ -7739,6 +7739,8 @@ breakText Glyphs Глифы
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Касательная окружность…
Tangent Circle Касательная окружность
Tangent Circle Tool Инструмент «Касательная окружность»
No tangent circle here Здесь нет касательной окружности
Circle: Окружность:
@msg `ids` names an object twice `ids` указывает объект дважды
@msg select two or three paths or compound paths выделите два или три контура или составных контура
Can't render this file because it is too large.
+2
View File
@@ -7783,6 +7783,8 @@ breakText Glyphs Glyfer
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Tangentcirkel…
Tangent Circle Tangentcirkel
Tangent Circle Tool Tangentcirkelverktyget
No tangent circle here Ingen tangentcirkel här
Circle: Cirkel:
@msg `ids` names an object twice `ids` anger ett objekt två gånger
@msg select two or three paths or compound paths markera två eller tre banor eller sammansatta banor
Can't render this file because it is too large.
+2
View File
@@ -9638,6 +9638,8 @@ breakText Glyphs Glifler
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Teğet Daire…
Tangent Circle Teğet Daire
Tangent Circle Tool Teğet Daire Aracı
No tangent circle here Burada teğet daire yok
Circle: Daire:
@msg `ids` names an object twice `ids` bir nesneyi iki kez belirtiyor
@msg select two or three paths or compound paths iki veya üç yol ya da bileşik yol seçin
Can't render this file because it is too large.
+2
View File
@@ -7364,6 +7364,8 @@ breakText Glyphs Гліфи
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Дотичне коло…
Tangent Circle Дотичне коло
Tangent Circle Tool Інструмент «Дотичне коло»
No tangent circle here Тут немає дотичного кола
Circle: Коло:
@msg `ids` names an object twice `ids` указує об’єкт двічі
@msg select two or three paths or compound paths виділіть два або три контури чи складені контури
Can't render this file because it is too large.
+2
View File
@@ -7400,6 +7400,8 @@ breakText Glyphs Glyph
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… Đường tròn tiếp xúc…
Tangent Circle Đường tròn tiếp xúc
Tangent Circle Tool Công cụ Đường tròn tiếp xúc
No tangent circle here Không có đường tròn tiếp xúc ở đây
Circle: Đường tròn:
@msg `ids` names an object twice `ids` nêu một đối tượng hai lần
@msg select two or three paths or compound paths chọn hai hoặc ba đường dẫn hoặc đường dẫn phức hợp
Can't render this file because it contains an unexpected character in line 206 and column 5.
+2
View File
@@ -7594,6 +7594,8 @@ breakText Glyphs 字形
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… 相切圆…
Tangent Circle 相切圆
Tangent Circle Tool 相切圆工具
No tangent circle here 此处没有相切圆
Circle: 圆:
@msg `ids` names an object twice `ids` 重复指定了同一个对象
@msg select two or three paths or compound paths 请选择两个或三个路径或复合路径
Can't render this file because it is too large.
+2
View File
@@ -7405,6 +7405,8 @@ breakText Glyphs 字符
# Path Precision Tools add-on: Tangent Circle.
Tangent Circle… 相切圓…
Tangent Circle 相切圓
Tangent Circle Tool 相切圓工具
No tangent circle here 此處沒有相切圓
Circle: 圓:
@msg `ids` names an object twice `ids` 將同一個物件指定了兩次
@msg select two or three paths or compound paths 請選取兩個或三個路徑或複合路徑
Can't render this file because it is too large.
+21 -4
View File
@@ -12866,10 +12866,10 @@ type and evening out horizontal scales are not there yet.
Path Precision Tools is a built-in add-on for exact anchor and path work: its commands are `addon.pathtools.*`, and in
the desktop app it lives in Object › Plug-ins › Path Precision Tools, in its Anchor Inspector panel
(`window.panel {panel: "anchorInspector"}`), in its Parametric Shape panel (`window.panel {panel: "parametricShape"}`)
and in eight tools: `anchorEraserBrush`, `extendPath`, `measureInspect`, `parametricShape`, `cornerTool`, `slideAnchor`,
`sharedEdge` and `trimAtCrossings`. The toolbars don't show the first seven until they are added from the All Tools
drawer (or chosen with `tool.select`); `trimAtCrossings` is in the Scissors tool's group in both shipped toolbars,
after the Knife, and `ui.tool.list` lists it there. A toolbar edited before it joined keeps its saved layout until
and in nine tools: `anchorEraserBrush`, `extendPath`, `measureInspect`, `parametricShape`, `cornerTool`, `slideAnchor`,
`sharedEdge`, `tangentCircle` and `trimAtCrossings`. The toolbars don't show the first eight until they are added from
the All Tools drawer (or chosen with `tool.select`); `trimAtCrossings` is in the Scissors tool's group in both shipped
toolbars, after the Knife, and `ui.tool.list` lists it there. A toolbar edited before it joined keeps its saved layout until
Reset Toolbar. None has a shortcut; one can be set in Edit › Keyboard Shortcuts › Tools. Each edit is one undo step,
and an edit that changes nothing makes no step.
@@ -12920,6 +12920,23 @@ Tools:
different in length, or at over 120° at an end, are left alone. Options (`tool.setOption`, or the panel, kept with the
preferences): `diameter` (0.25 to 200 pt, 20), `tolerance` (how near two anchors count as coincident, 0 to 3 pt,
0.002) and `together` (Keep Shared Points Together).
- **Tangent Circle Tool** (`tangentCircle`): draws a circle on two path segments of any unlocked paths, selected or
not. A click picks the first segment; over a second segment the circle that would be drawn shows (red) with its
center, its radii to the two touch points and its radius, or a note that there is none. A click there draws the
circle that is tangent to the first segment at the point clicked and touches the second (its center on the first
segment's normal there). With Shift the circle instead has the tool's `radius` and may touch the first segment
anywhere along it. A drag from the second segment sets the radius to the drag's length; Shift steps it by 1, 2 or 5
times a power of 10 pt, at least 4 screen pixels long (2 pt at 200%), and Cmd/Ctrl pressed during the drag moves
it by a tenth of the pointer's movement (held at the press, Cmd/Ctrl lends the selection tool, as for every tool).
The segments on either side of the second one, on its subpath, count with it (the first segment excepted; the two
may be on the same path, and the first segment picked again gives no circle), and of the circles found the one
touching them nearest the pointer is drawn. A circle touches them when they lie outside it with a point on it, and
it never crosses the first segment. The circle is a new ellipse with the current paint, drawn through three of its
points with `shape.circleThroughPoints` so that Align New Objects to Pixel Grid leaves it in place, one undo step.
With no circle, or one too small or too large for its three points to give it back in floating point, nothing is
drawn and the first segment stays picked. Escape, an edit, Undo or Redo outside the tool, or another document
forgets the first segment. Option (`tool.setOption`, or a double-click on the tool): `radius` (pt, 0.01 to 1000000,
36).
- **Trim at Crossings Tool** (`trimAtCrossings`): removes stretches of paths between the places where they are crossed,
on any path that can be edited, selected or not. A click runs `addon.pathtools.trim` with `at`, for the path within 4
screen pixels of the pointer. A drag draws a rectangle and runs it with `rect` on release; once the pointer has
+4
View File
@@ -2694,6 +2694,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov
A VectorCraft addition, so no area score moves. Object › Plug-ins › Path Precision Tools › Tangent Circle… (`addon.pathtools.tangentCircle`) draws the circles that touch two selected paths or compound paths at a set radius, or that touch three of them; for three circles these are the solutions of the [problem of Apollonius](https://en.wikipedia.org/wiki/Problem_of_Apollonius), up to eight. The rest is VectorCraft's own: a circle touches a shape when it meets the outline without crossing it (the whole outline outside the circle or inside it), so it is tangent at a smooth point and passes through a corner or an open end; circles, ellipses at any angle and other closed or open paths all take part, a compound path's members as one outline. Circles are solved in closed form, each answer then moved onto the drawn Bézier outlines; other shapes are searched on a grid and refined with Newton's method on the curves, and with three shapes circles up to 64 times the diagonal of the box around the shapes' anchors and handles are found. The circles are listed by radius, then top to bottom, then left to right; the dialog previews every circle found, or one picked by number, and OK draws them with the current paint as one undo step. No circle, more than 64 (shapes touched along a whole curve) and more than 2000 segments are errors. Tests: `tangent_circle::tests` in `vectorcraft-pathops` (three circles: two known circles and eight distinct ones in a steady order; two circles and a radius; the search against the closed form; rotated and skewed ellipses against an independent solve of every combination; two circles close together; squares; a compound path moved far off and scaled; open paths and the errors), `cmd::addons::pathtools::tangent_circle::tests` in `vectorcraft-engine`, `tangent_circle_previews_picks_one_cancels_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Path Precision Tools add-on.
## Path Precision Tools add-on: Tangent Circle Tool (2026-11-17)
A VectorCraft addition, so no area score moves. The Tangent Circle Tool (`tangentCircle`; Object › Plug-ins › Path Precision Tools and the All Tools drawer) draws a circle on two clicked path segments: tangent to the first at the point clicked (its center on the normal there) and touching the second segment or one beside it on its subpath, the touch nearest the pointer winning. Shift gives the circle the tool's radius anywhere along the first segment, and a drag from the second segment sets the radius to the drag's length (Shift: steps of 1, 2 or 5 times a power of 10 pt, at least 4 screen pixels; Cmd/Ctrl: a tenth of the movement). Before the click the circle shows with its center, radii and radius, or a note says there is none. The circles are found by sampling the distance to the second segments along the first segment's normal (or along the first segment, for a radius) and taking the places where it equals the radius (samples, bisection where it crosses, and a search where it only touches); circles that cross the first segment or touch both at one point are left out. The circle is a new ellipse with the current paint, one undo step. Tests: `tangent_circle::tests` in `vectorcraft-pathops` (parallel and crossing lines, a curved second segment, a corner's fillet, lines twice the radius apart, a touch between the places tried, the ends of a line with its handles on its anchors, no circle), `addons::tangent_circle::tests` in `vectorcraft-tools` (two clicks, Shift, a drag with Shift and Cmd/Ctrl, no circle and Escape) and the Path Precision Tools menu and options tests in `vectorcraft-ui-egui`. Commands: `docs/mcp.md` › Path Precision Tools add-on.
## Path Precision Tools add-on: Expand Dashes into Paths (2026-11-01)
A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Path Precision Tools › Expand Dashes into Paths turns the dashed stroke of each selected path and compound path into separate open paths, one per dash, for cutters and plotters that need the centre lines rather than Outline Stroke's filled outlines. The dashes are laid out by the renderer's own dash code, so they match what the canvas draws: the dash pattern, its offset and Align Dashes to Corners and Path Ends, a dash running on through the start of a closed path, a dash all the way round staying closed, and under a round or projecting cap each dot (a dash of no length) as a path on its point. Each dash keeps the path's appearance with the top stroke's dashes and arrowheads off; the path's fills stay on it, below its dashes; a compound path's dashes are plain paths. One undo step; the dashes are selected; at most 100000 (more, or a pattern too fine to draw, is refused). Tests: `expand_dashes_*` in `cmd::addons::pathtools::tests` in `vectorcraft-engine` (the stroke kept with dashes off, the offset, one undo step, the fill kept below, dashes centred on corners when aligned, dots under round and butt caps, compound paths, refusals and the piece cap), `the_plugins_submenu_selects_the_tools_and_opens_the_anchor_inspector` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Path Precision Tools add-on.
+2 -1
View File
@@ -495,12 +495,13 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po
| Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › Batch Trace Folder asks for a folder of images, then a destination folder, traces each image with a preset (optionally expanded) and saves it there as `.vectorcraft`, `.svg`, `.pdf`, `.ai` or `.eps` under its own name (taken names numbered, nothing replaced), closing each image again; the status bar counts the images traced and those that couldn't be; off on the web | done | #4921; `addon.document.batchTraceFolder`, `crates/engine/src/cmd/addons/document/batch_trace.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app |
| Document Tools add-on (VectorCraft addition): Object › Plug-ins › Document Tools › New Symbols from Layers makes a symbol of each layer's art named after the layer (the highlighted layers when two or more are, else all); Convert Layers to Symbols also replaces each layer's art with an instance in place; empty layers skipped, one undo step | done | #4927; `addon.document.symbolsFromLayers`, `crates/engine/src/cmd/addons/document.rs`, `crates/ui-egui/src/addons/document.rs` and their tests; not a feature of the reference app, so it is not scored |
| Smart Pen add-on (VectorCraft addition): Object › Plug-ins › Smart Pen selects the Smart Pen Tool, which the All Tools drawer lists under its own heading but neither toolbar shows as shipped (no shortcut), and opens the Smart Pen panel (next segment straight or curved; Remove Points Keep Shape, Make Smooth, Make Corner, Retract Handles, Close or Join). The tool draws (click: straight or curved segment, a curve after a straight one tangent; drag: smooth anchor, Alt breaks the handle, Shift 45°, Space moves it; Tab switches a segment; rubber band; close, join, continue) and edits without switching tools (click selects a point, drag moves it, Alt-click removes it keeping the shape, Shift+Alt-click deletes it, double-click toggles smooth/corner; handle drags with Shift and Alt; segment drags reshape, Alt-click adds a point) | done | `addon.pen.*`, `crates/tools/src/addons/smart_pen.rs`, `crates/ui-egui/src/addons/pen.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools selects its eight tools (Anchor Eraser Brush, Extend Path, Measure & Inspect, Parametric Shape, Corner Tool, Slide Anchor Along Path, Shared Edge Merge Tool, Trim at Crossings Tool), which the All Tools drawer lists under their own heading but neither toolbar shows as shipped (except Trim at Crossings, which both shipped toolbars and the drawer show in the Scissors tool's group), opens the Anchor Inspector panel (the selected anchor's X/Y and handle lengths and angles as fields; Make Smooth, Make Corner, Equalize Handles, Remove Points Keep Shape, Add Points, the three ways to close) and the Parametric Shape panel (kind, count, W/H, rotation, the kind's own values and corner radius of the selected parametric shape, or of the tool's next one), and runs Add Points at / Split at Crossings and Convert to Parametric Shape; the Parametric Shape Tool draws ten re-editable kinds from the centre (↑/↓ and ←/→ change their numbers while dragging) and edits a selected one with handles; the Corner Tool cuts editable corners on any path (hover shows the anchor, a click uses its radius and kind, a drag sizes the corner, Shift whole values; a corner's marker selects it and loads its values, drags to resize, to 0 or double-clicked removes it; never past what fits; Alt-marquee cuts every anchor inside) with a Corners section in the Anchor Inspector (radius, kind, selected count, Apply to Selected Anchors); Slide Anchor Along Path drags an anchor along its curve with the segments beside it refitted, Shift snapping where the tangent is a multiple of 45°; the Shared Edge Merge Tool shows, over two paths touching at two coincident anchors, the two stretches and the edge merging them, a click merges them (half way; Shift the upper path, Alt the lower), and near anchors meet or an anchor one path lacks is added to match (Shift+Alt asks for this inside a stretch), with a Shared Edges section in the Anchor Inspector (brush diameter, coincidence 0 to 3 pt, Keep Shared Points Together, which takes coincident anchors along with the add-on's own anchor moves); a double-click on the brush or Extend Path tool opens its options | done | `addon.pathtools.*`, `crates/tools/src/addons/`, `crates/ui-egui/src/addons/pathtools.rs`, `crates/ui-egui/src/addons/pathtools/` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools selects its nine tools (Anchor Eraser Brush, Extend Path, Measure & Inspect, Parametric Shape, Corner Tool, Slide Anchor Along Path, Shared Edge Merge Tool, Tangent Circle Tool, Trim at Crossings Tool), which the All Tools drawer lists under their own heading but neither toolbar shows as shipped (except Trim at Crossings, which both shipped toolbars and the drawer show in the Scissors tool's group), opens the Anchor Inspector panel (the selected anchor's X/Y and handle lengths and angles as fields; Make Smooth, Make Corner, Equalize Handles, Remove Points Keep Shape, Add Points, the three ways to close) and the Parametric Shape panel (kind, count, W/H, rotation, the kind's own values and corner radius of the selected parametric shape, or of the tool's next one), and runs Add Points at / Split at Crossings and Convert to Parametric Shape; the Parametric Shape Tool draws ten re-editable kinds from the centre (↑/↓ and ←/→ change their numbers while dragging) and edits a selected one with handles; the Corner Tool cuts editable corners on any path (hover shows the anchor, a click uses its radius and kind, a drag sizes the corner, Shift whole values; a corner's marker selects it and loads its values, drags to resize, to 0 or double-clicked removes it; never past what fits; Alt-marquee cuts every anchor inside) with a Corners section in the Anchor Inspector (radius, kind, selected count, Apply to Selected Anchors); Slide Anchor Along Path drags an anchor along its curve with the segments beside it refitted, Shift snapping where the tangent is a multiple of 45°; the Shared Edge Merge Tool shows, over two paths touching at two coincident anchors, the two stretches and the edge merging them, a click merges them (half way; Shift the upper path, Alt the lower), and near anchors meet or an anchor one path lacks is added to match (Shift+Alt asks for this inside a stretch), with a Shared Edges section in the Anchor Inspector (brush diameter, coincidence 0 to 3 pt, Keep Shared Points Together, which takes coincident anchors along with the add-on's own anchor moves); a double-click on the brush, Extend Path or Tangent Circle tool opens its options | done | `addon.pathtools.*`, `crates/tools/src/addons/`, `crates/ui-egui/src/addons/pathtools.rs`, `crates/ui-egui/src/addons/pathtools/` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Divide into Dashes… (Dash and Gap in any unit, Fit to Corners and Ends, Remove Gaps; Preview) cuts the selected paths, or only their direct-selected segments, into open pieces along the curve, keeping their appearance, one undo step | done | #4950; `addon.pathtools.divideDashes`, `crates/pathops/src/addons/pathtools/dashes.rs`, `crates/ui-egui/src/addons/pathtools/dashes.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Set Corners… (also a button in the Anchor Inspector's Corners section: Radius in any unit, Corner kind, Anchors: All, Odd-Numbered or Even-Numbered, counted from each path's first anchor; Angle: from … to …°, only the corners whose sides meet at an angle in that range; Preview) cuts corners on the chosen anchors of every selected path, one undo step | done | #5546, #5545; `addon.pathtools.cornerSet` (`every`, `minAngle`, `maxAngle`), `crates/ui-egui/src/addons/pathtools/set_corners.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Trim at Crossings Tool (also in the Scissors tool's group in both shipped toolbars, after the Knife, and listed there in the All Tools drawer; a toolbar edited before keeps its saved layout until Reset Toolbar; no shortcut until one is set in Edit › Keyboard Shortcuts › Tools; the Knife's cursor, drawn as a knife with the blade's point on the hotspot) removes stretches of paths between the places where they are crossed, on any editable path, selected or not: a click removes the stretch under the pointer, a drag removes every stretch its rectangle touches, and an Alt-drag removes every stretch its freehand line crosses; one undo step each; Escape during a drag removes nothing; hovering shows in red the stretch a click would remove, and a drag that reaches few paths shows what its release would remove | done | `addon.pathtools.trim` (in `crates/engine/src/cmd/addons/pathtools/trim.rs`), `crates/tools/src/addons/trim.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Expand Dashes into Paths turns each selected path's dashed stroke into separate open paths, one per dash, laid out as the stroke draws them (pattern, offset, Align Dashes to Corners and Path Ends), each keeping the stroke with the dashes off; one undo step | done | #4922; `addon.pathtools.expandDashes` (in `crates/engine/src/cmd/addons/pathtools.rs`, using the renderer's dash layout) and its tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Tangent Circle… draws the circles that touch two selected paths or compound paths at a radius, or three of them, each touching the outlines without crossing them; Radius (two shapes), a Circle menu (All or one by number) and Preview; one undo step | done | `addon.pathtools.tangentCircle` (in `crates/engine/src/cmd/addons/pathtools/tangent_circle.rs`, geometry in `crates/pathops/src/addons/pathtools/tangent_circle.rs`) and its tests; a VectorCraft addition, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools › Tangent Circle Tool (also in the All Tools drawer): a click on a path segment, then on another, draws the circle tangent to the first at the point clicked that touches the second or a segment beside it; Shift uses the tool's radius (36 pt to start, set in its options), a drag from the second segment sets the radius (Shift in round steps, Cmd/Ctrl slowly); the circle shows with its center and radii first, or a note when there is none; one undo step | done | tool `tangentCircle` (in `crates/tools/src/addons/tangent_circle.rs`, geometry in `crates/pathops/src/addons/pathtools/tangent_circle/on_segments.rs`) and its tests; a VectorCraft addition, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Effect › Path Effects lists its live effects (Dashes to Geometry, Add Anchors, Extend Path, Close Path, Smooth Anchors, Retract Handles, Reverse Direction, Simplify Anchors, Split at Anchors), each with the effect dialog's live Preview except Reverse Direction, which has no options, and listed in the Appearance panel like any effect | done | `addon.path.*`, `crates/effects/src/addons/path.rs`, `crates/ui-egui/src/addons/pathtools.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools selects its four tools (Anchor Eraser Brush, Extend Path, Measure & Inspect, Parametric Shape), which the All Tools drawer lists under their own heading but neither toolbar shows as shipped, opens the Anchor Inspector panel (the selected anchor's X/Y and handle lengths and angles as fields; Make Smooth, Make Corner, Equalize Handles, Remove Points Keep Shape, Add Points, the three ways to close) and the Parametric Shape panel (kind, count, W/H, rotation, the kind's own values and corner radius of the selected parametric shape, or of the tool's next one), and runs Add Points at / Split at Crossings and Convert to Parametric Shape; the Parametric Shape Tool draws ten re-editable kinds from the centre (↑/↓ and ←/→ change their numbers while dragging) and edits a selected one with handles; a double-click on the brush or Extend Path tool opens its options | done | `addon.pathtools.*`, `crates/tools/src/addons/`, `crates/ui-egui/src/addons/pathtools.rs`, `crates/ui-egui/src/addons/pathtools/shape.rs` and their tests; not a feature of the reference app, so it is not scored |
| Path Precision Tools add-on (VectorCraft addition): Object › Plug-ins › Path Precision Tools selects its six tools (Anchor Eraser Brush, Extend Path, Measure & Inspect, Parametric Shape, Corner Tool, Slide Anchor Along Path), which the All Tools drawer lists under their own heading but neither toolbar shows as shipped, opens the Anchor Inspector panel (the selected anchor's X/Y and handle lengths and angles as fields; Make Smooth, Make Corner, Equalize Handles, Remove Points Keep Shape, Add Points, the three ways to close) and the Parametric Shape panel (kind, count, W/H, rotation, the kind's own values and corner radius of the selected parametric shape, or of the tool's next one), and runs Add Points at / Split at Crossings and Convert to Parametric Shape; the Parametric Shape Tool draws ten re-editable kinds from the centre (↑/↓ and ←/→ change their numbers while dragging) and edits a selected one with handles; the Corner Tool cuts editable corners on any path (hover shows the anchor, a click uses its radius and kind, a drag sizes the corner, Shift whole values; a corner's marker selects it and loads its values, drags to resize, to 0 or double-clicked removes it; never past what fits; Alt-marquee cuts every anchor inside) with a Corners section in the Anchor Inspector (radius, kind, selected count, Apply to Selected Anchors); Slide Anchor Along Path drags an anchor along its curve with the segments beside it refitted, Shift snapping where the tangent is a multiple of 45°; a double-click on the brush or Extend Path tool opens its options | done | `addon.pathtools.*`, `crates/tools/src/addons/`, `crates/ui-egui/src/addons/pathtools.rs`, `crates/ui-egui/src/addons/pathtools/` and their tests; not a feature of the reference app, so it is not scored |