Merge pull request #9120 from dotCooCoo/fix/pathfinder-effect-options-followup

Pathfinder: effects journal every option they use, and Outline follows Precision
This commit is contained in:
BFlat
2026-11-26 08:45:50 +07:00
committed by GitHub
10 changed files with 258 additions and 19 deletions
+11 -4
View File
@@ -66,7 +66,7 @@ pub const PATHFINDER_EFFECT_PRECISION: std::ops::RangeInclusive<f64> = 0.001..=1
/// The documentation of [`PATHFINDER_OPTION_KEYS`], as a literal for `concat!`.
macro_rules! options_doc {
() => {
"precision?: pt 0.001..10 (effect.apply: Pathfinder Options › Precision; 0.01 when missing; results are refit to within it and pieces thinner than it are dropped), removeRedundantPoints?: bool (effect.apply: Pathfinder Options › Remove Redundant Points; false when missing; results lose the anchors that don't change their shape to within precision), removeUnpainted?: bool (effect.apply: Pathfinder Options › Divide and Outline Will Remove Unpainted Artwork; false when missing; Divide and Outline leave out the pieces of members with no visible fill, a compound shape's area going by the shape's own fill, except that Divide keeps every piece when the group or compound shape has a visible fill of its own; the other operations ignore it)"
"precision?: pt 0.001..10 (effect.apply: Pathfinder Options › Precision; 0.01 when missing, and a stored value that is not a number evaluates as 0.01; results are refit to within it and pieces thinner than it are dropped; Outline treats crossings closer together than precision / 10000 as one point, or than the tolerance for the art's size when that is larger), removeRedundantPoints?: bool (effect.apply: Pathfinder Options › Remove Redundant Points; false when missing; results lose the anchors that don't change their shape to within precision), removeUnpainted?: bool (effect.apply: Pathfinder Options › Divide and Outline Will Remove Unpainted Artwork; false when missing; Divide and Outline leave out the pieces of members with no visible fill, a compound shape's area going by the shape's own fill, except that Divide keeps every piece when the group or compound shape has a visible fill of its own; the other operations ignore it)"
};
}
@@ -102,14 +102,21 @@ impl Default for PathfinderEffectOptions {
}
}
/// The `precision` stored in a Pathfinder effect's parameters `p`, out of range or not, when it is a
/// JSON number. A value of another type (`true`, `"1 pt"`) is not a precision.
pub(crate) fn stored_precision(p: &Value) -> Option<f64> {
p.get("precision").and_then(Value::as_f64).filter(|v| v.is_finite())
}
impl PathfinderEffectOptions {
/// The options in `p`: a missing or non-numeric value takes its default and a precision out of
/// range its nearest bound, so a live effect always evaluates.
/// The options in `p`: a missing value, or one of the wrong type (a precision that is not a
/// number), takes its default, and a precision out of range its nearest bound, so a live effect
/// always evaluates.
pub fn from_params(p: &Value) -> Self {
let d = PathfinderEffectOptions::default();
let (lo, hi) = (*PATHFINDER_EFFECT_PRECISION.start(), *PATHFINDER_EFFECT_PRECISION.end());
PathfinderEffectOptions {
precision: crate::util::num(p, "precision", d.precision).clamp(lo, hi),
precision: stored_precision(p).unwrap_or(d.precision).clamp(lo, hi),
remove_redundant_points: crate::util::flag(p, "removeRedundantPoints", d.remove_redundant_points),
remove_unpainted: crate::util::flag(p, "removeUnpainted", d.remove_unpainted),
}
+6 -3
View File
@@ -131,9 +131,12 @@ pub fn scale_effect(e: &mut Effect, s: f64) {
let mut keys: Vec<&str> = info.lengths.keys(relative).collect();
keys.extend(merged.as_object().into_iter().flat_map(|m| m.keys()).map(String::as_str).filter(|k| crate::raster_px_range(&e.id, k).is_some()));
for k in keys {
let missing =
if k == "precision" && crate::takes_pathfinder_options(&e.id) { crate::PathfinderEffectOptions::default().precision } else { f64::NAN };
let v = util::num(&merged, k, missing);
// A Pathfinder effect's precision that is not a number scales the precision it evaluates with.
let v = if k == "precision" && crate::takes_pathfinder_options(&e.id) {
crate::group::stored_precision(&merged).unwrap_or(crate::PathfinderEffectOptions::default().precision)
} else {
util::num(&merged, k, f64::NAN)
};
if v.is_finite() {
if !e.params.is_object() {
e.params = Value::Object(Map::new());
+20
View File
@@ -2186,3 +2186,23 @@ fn a_pathfinder_effects_precision_is_a_distance_that_scales_with_the_object() {
assert_eq!(e.params["precision"].as_f64(), Some(8.0), "{id}");
}
}
#[test]
fn a_pathfinder_effects_stored_precision_that_is_not_a_number_is_the_default() {
let d = PathfinderEffectOptions::default().precision;
for v in [json!(true), json!(false), json!("1abc"), json!("5 pt"), json!(null), json!([2.0])] {
assert_eq!(PathfinderEffectOptions::from_params(&json!({ "precision": v })).precision, d, "{v}");
}
// A number out of range takes its nearest bound.
assert_eq!(PathfinderEffectOptions::from_params(&json!({"precision": 50.0})).precision, *PATHFINDER_EFFECT_PRECISION.end());
assert_eq!(PathfinderEffectOptions::from_params(&json!({"precision": 0})).precision, *PATHFINDER_EFFECT_PRECISION.start());
// Scale Strokes & Effects scales the precision such an effect evaluates with.
for (id, _, _) in PATHFINDER_EFFECTS {
for v in [json!(true), json!("1abc")] {
let mut e = crate::new_effect(id, &json!({ "precision": v })).unwrap();
crate::scale_effect(&mut e, 3.0);
let scaled = e.params["precision"].as_f64().unwrap_or(f64::NAN);
assert!((scaled - d * 3.0).abs() < 1e-12, "{id} {v}: {scaled}");
}
}
}
+3 -3
View File
@@ -126,7 +126,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Pathfinder Options…",
["Window", "Pathfinder"],
None,
"{precision?: pt 0.001..10 (0.01; how closely the Pathfinder operations follow the paths: results are refit to within it and pieces thinner than it are dropped), removeRedundantPoints?: bool (false; the results lose the anchors that don't change their shape), removeUnpainted?: bool (false; Divide and Outline leave out the pieces of objects with no fill)} Pathfinder Options, kept in the preferences and used by every later Shape Mode and Pathfinder operation (not Trap); {} reads them → the options",
"{precision?: pt 0.001..10 (0.01; how closely the Pathfinder operations follow the paths: results are refit to within it and pieces thinner than it are dropped; Outline treats crossings closer together than precision / 10000 as one point, or than the tolerance for the art's size when that is larger), removeRedundantPoints?: bool (false; the results lose the anchors that don't change their shape), removeUnpainted?: bool (false; Divide and Outline leave out the pieces of objects with no fill)} Pathfinder Options, kept in the preferences and used by every later Shape Mode and Pathfinder operation (not Trap); {} reads them → the options",
always,
pathfinder_options
),
@@ -610,8 +610,8 @@ impl Default for PathfinderOptions {
}
}
/// The range of Pathfinder Options › Precision (pt).
pub const PATHFINDER_PRECISION_RANGE: std::ops::RangeInclusive<f64> = 0.001..=10.0;
/// The range of Pathfinder Options › Precision (pt), which a Pathfinder effect's `precision` shares.
pub const PATHFINDER_PRECISION_RANGE: std::ops::RangeInclusive<f64> = vectorcraft_render::effects::PATHFINDER_EFFECT_PRECISION;
impl PathfinderOptions {
/// These options with those `p` names (`precision` in pt or a string with a unit), or why `p`
+10
View File
@@ -401,8 +401,18 @@ impl Session {
// The params' own values win, except a null: it reads as a key left out, so the
// noted value is the one the command resolved. A noted `defaultsOnly` wins too: the
// Live Paint Bucket kept the command to the defaults although the params gave `false`.
// An object noted for an object the params give (`effect.apply`'s `params`) is merged
// by the same rule, so the keys the command filled in stay.
Value::Object(m) if !note.is_empty() => {
for (k, v) in m {
if let (Some(Value::Object(resolved)), Value::Object(given)) = (note.get_mut(k), v) {
for (gk, gv) in given {
if !gv.is_null() || !resolved.contains_key(gk) {
resolved.insert(gk.clone(), gv.clone());
}
}
continue;
}
if (!v.is_null() && k != "defaultsOnly") || !note.contains_key(k) {
note.insert(k.clone(), v.clone());
}
+25
View File
@@ -1955,6 +1955,31 @@ fn a_pathfinder_effect_keeps_the_options_in_force_when_applied() {
assert_eq!(mix, &json!({"mixingRate": 50.0, "precision": 0.5, "removeRedundantPoints": true, "removeUnpainted": true}));
}
/// A Pathfinder effect given some of its options in `params` journals every option it used, so
/// replaying the journal with other preferences gives the same effect and art.
#[test]
fn a_pathfinder_effect_given_some_options_journals_every_option_it_used() {
let mut s = session();
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 100, "height": 100})).unwrap();
s.execute("paint.setFill", &json!({"color": "#ff0000"})).unwrap();
s.execute("shape.rectangle", &json!({"x": 0, "y": 99.5, "width": 100, "height": 50})).unwrap();
s.execute("paint.setFill", &json!({"none": true})).unwrap();
s.execute("select.all", &json!({})).unwrap();
s.prefs.pathfinder = PathfinderOptions { precision: 1.0, remove_redundant_points: true, remove_unpainted: true };
s.execute("effect.apply", &json!({"effect": "pathfinder.divide", "params": {"precision": 0.25}})).unwrap();
let all = json!({"precision": 0.25, "removeRedundantPoints": true, "removeUnpainted": true});
assert_eq!(first_effect_params(&s), all);
let (id, p) = s.journal.last().unwrap().clone();
assert_eq!((id.as_str(), &p["params"]), ("effect.apply", &all), "the journal entry gives every option the effect used");
let mut replay = Session::new();
for (id, p) in &s.journal {
replay.execute(id, p).unwrap();
}
assert_eq!(replay.prefs.pathfinder, PathfinderOptions::default());
let doc = |s: &Session| serde_json::to_value(&*s.doc().unwrap().doc).unwrap();
assert_eq!(doc(&replay), doc(&s));
}
/// A live Pathfinder effect evaluates with its own options as the panel's operations do with
/// Pathfinder Options: a precision of 1 pt drops a 0.5 pt overlap, Divide leaves out an unfilled
/// object's pieces, and Remove Redundant Points drops an anchor that shapes nothing.
+112 -5
View File
@@ -226,7 +226,7 @@ pub fn pathfinder_with(op: PathfinderOp, shapes: &[Shape], precision: f64) -> Ve
);
subpaths.into_iter().zip(shapes).filter(|(sp, _)| !sp.is_empty()).flat_map(|(sp, s)| one(PathData::new(sp), s.key)).collect()
}
PathfinderOp::Outline => outline_edges(&arr, shapes),
PathfinderOp::Outline => outline_edges(&arr, shapes, precision),
PathfinderOp::HardMix | PathfinderOp::SoftMix => regions_of(&arr)
.into_iter()
.filter_map(|r| {
@@ -971,13 +971,60 @@ fn along(a: &[PathSeg], b: &[PathSeg], tol: f64) -> bool {
covers(a, b) && covers(b, a)
}
/// Pathfinder Outline: split every shape's boundary at junctions of the arrangement.
fn outline_edges(arr: &Arrangement, shapes: &[Shape]) -> Vec<Shape> {
/// [`along`] with each piece checked at points no farther apart along its control polygon than
/// `tol`, at most 64 to a piece, so curves that meet at the middles and ends of their pieces but
/// part between them are not one. `a` and `b` run opposite ways. Each piece's samples include its
/// middle. Chains whose pieces pair up with control points within `tol` of each other are one
/// without sampling: each point of such a piece is within `tol` of the point of its pair at the same
/// parameter.
fn along_closely(a: &[PathSeg], b: &[PathSeg], tol: f64) -> bool {
let within = |p: Point, q: Point| p.distance(q) <= tol;
let paired = a.len() == b.len()
&& a.iter().zip(b.iter().rev()).all(|(p, q)| match (p, q.reverse()) {
(PathSeg::Line(x), PathSeg::Line(y)) => within(x.p0, y.p0) && within(x.p1, y.p1),
(PathSeg::Quad(x), PathSeg::Quad(y)) => within(x.p0, y.p0) && within(x.p1, y.p1) && within(x.p2, y.p2),
(PathSeg::Cubic(x), PathSeg::Cubic(y)) => within(x.p0, y.p0) && within(x.p1, y.p1) && within(x.p2, y.p2) && within(x.p3, y.p3),
_ => false,
});
if paired {
return true;
}
let samples = |s: &PathSeg| {
let len = match s {
PathSeg::Line(l) => l.p0.distance(l.p1),
PathSeg::Quad(q) => q.p0.distance(q.p1) + q.p1.distance(q.p2),
PathSeg::Cubic(c) => c.p0.distance(c.p1) + c.p1.distance(c.p2) + c.p2.distance(c.p3),
};
// An even count puts a sample at the middle of the piece.
let n = if tol > 0.0 { ((len / tol / 2.0).ceil().clamp(1.0, 32.0) as usize) * 2 } else { 64 };
let s = *s;
(1..=n).map(move |k| s.eval(k as f64 / n as f64))
};
let covers = |from: &[PathSeg], to: &[PathSeg]| {
// Each point's search goes back along `to` from the piece the point before it was near.
let mut at = to.len();
from.iter().flat_map(samples).all(|p| {
let mut order = to.iter().enumerate().take(at).rev().chain(to.iter().enumerate().skip(at).rev());
let Some((i, _)) = order.find(|(_, t)| t.nearest(p, 1e-12).distance_sq.sqrt() <= tol) else { return false };
at = i + 1;
true
})
};
covers(a, b) && covers(b, a)
}
/// Pathfinder Outline: split every shape's boundary at junctions of the arrangement. Junctions
/// closer together than `reach` are one, and coincident edges within ten times it are one edge.
/// `reach` is the larger of the arrangement's tolerance for the art's size and `precision` / 10,000,
/// with `precision` kept within 0.001 to 10 pt (Pathfinder Options › Precision's range), so the
/// default precision gives 0.000001 pt as before. Scaling the art and the precision together scales
/// `reach` by the same amount.
fn outline_edges(arr: &Arrangement, shapes: &[Shape], precision: f64) -> Vec<Shape> {
// Sorted by x (then y), so a segment needs only the junctions inside its control box.
let junctions = arr.junctions();
let scale = shapes.iter().filter_map(|s| s.path.control_bounds()).map(|r| r.width().max(r.height())).fold(1.0, f64::max);
let tol = scale * 1e-7;
let reach = tol.max(1e-6);
let reach = tol.max(1e-6 * (precision / DEFAULT_PRECISION).clamp(0.1, 1000.0));
// (chain, key, source index)
let mut chains: Vec<(Vec<Seg>, u64)> = Vec::new();
for s in shapes {
@@ -1054,8 +1101,15 @@ fn outline_edges(arr: &Arrangement, shapes: &[Shape]) -> Vec<Shape> {
// De-duplicate coincident chains, keeping the front-most key (later shapes overwrite). A
// match has its midpoint within `near` of this one's, so only the chains in the grid cells
// around it are candidates; the first of them in `out` order is the one a scan would find.
// Ends and midpoint only pick the candidates: two chains are one edge when each lies within `d`
// of the other along its whole length.
let mut out: Vec<(Vec<Seg>, u64)> = Vec::new();
let mut sigs: Vec<(Point, Point, Point)> = Vec::new();
let mut paths: Vec<Vec<PathSeg>> = Vec::new();
let as_path = |c: &[Seg]| -> Vec<PathSeg> {
c.iter().map(|s| if s.line { PathSeg::Line(Line::new(s.c.p0, s.c.p3)) } else { PathSeg::Cubic(s.c) }).collect()
};
let reversed = |c: &[PathSeg]| -> Vec<PathSeg> { c.iter().rev().map(|s| s.reverse()).collect() };
let sig = |c: &[Seg]| -> (Point, Point, Point) {
let a = c[0].c.p0;
let b = c[c.len() - 1].c.p3;
@@ -1068,6 +1122,7 @@ fn outline_edges(arr: &Arrangement, shapes: &[Shape]) -> Vec<Shape> {
let mut grid: HashMap<(i64, i64), Vec<usize>> = HashMap::new();
for (chain, key) in chains {
let (a, b, m) = sig(&chain);
let path = as_path(&chain);
let (cx, cy) = cell(m);
let found = (cx - 1..=cx + 1)
.flat_map(|x| (cy - 1..=cy + 1).map(move |y| (x, y)))
@@ -1076,7 +1131,21 @@ fn outline_edges(arr: &Arrangement, shapes: &[Shape]) -> Vec<Shape> {
.copied()
.filter(|&i| {
let (a2, b2, m2) = sigs[i];
near(m, m2) && ((near(a, a2) && near(b, b2)) || (near(a, b2) && near(b, a2)))
let other = &paths[i];
let same = near(a, a2) && near(b, b2);
let opposite = near(a, b2) && near(b, a2);
if !near(m, m2) || !(same || opposite) {
return false;
}
// A chain whose ends meet matches both ways round; the end of its first piece shows
// which way the other runs. `along_closely` takes chains that run opposite ways.
let runs_same = same
&& (!opposite
|| match (path.first(), other.first(), other.last()) {
(Some(p), Some(f), Some(l)) => p.end().distance(f.end()) <= p.end().distance(l.start()),
_ => true,
});
if runs_same { along_closely(&path, &reversed(other), d) } else { along_closely(&path, other, d) }
})
.min();
match found {
@@ -1084,6 +1153,7 @@ fn outline_edges(arr: &Arrangement, shapes: &[Shape]) -> Vec<Shape> {
None => {
grid.entry((cx, cy)).or_default().push(out.len());
sigs.push((a, b, m));
paths.push(path);
out.push((chain, key));
}
}
@@ -1711,4 +1781,41 @@ mod tests {
assert_eq!(merged.len(), 40);
assert!(merged.iter().enumerate().all(|(k, s)| s.key == k as u64));
}
/// A curve with the ends of a line that passes within 0.25 pt of the line's middle, and whose
/// own middle is within 0.25 pt of the line, but which runs about 23 pt past the line's start:
/// the middles and ends of the two pieces match, and the two are still not one edge.
#[test]
fn along_closely_checks_curves_between_the_middles_of_their_pieces() {
let line = [PathSeg::Line(Line::new((100.0, 0.0), (0.0, 0.0)))];
let curve = [PathSeg::Cubic(kurbo::CubicBez::new((0.0, 0.0), (-54.56, 0.4537), (198.85, 0.0963), (100.0, 0.0)))];
assert!(along(&line, &curve, 0.25), "the middles and ends match");
assert!(!along_closely(&line, &curve, 0.25));
assert!(!along_closely(&curve, &line, 0.25));
let same = [PathSeg::Line(Line::new((0.0, 0.0), (100.0, 0.0)))];
assert!(along_closely(&line, &same, 0.25));
}
/// A curve 1.05 pt from a line at its middle and under 1 pt from it at its thirds: with a
/// control polygon under three times the tolerance long, the samples still take in the middle.
#[test]
fn along_closely_samples_the_middle_of_a_short_piece() {
let line = [PathSeg::Line(Line::new((0.15, 0.0), (0.0, 0.0)))];
let curve = [PathSeg::Cubic(kurbo::CubicBez::new((0.0, 0.0), (0.05, 1.4), (0.1, 1.4), (0.15, 0.0)))];
assert!(!along_closely(&curve, &line, 1.0));
}
/// Pieces whose control points pair up within the tolerance are one edge, copies included.
#[test]
fn along_closely_takes_pieces_whose_control_points_pair_up() {
let a = [
PathSeg::Cubic(kurbo::CubicBez::new((0.0, 0.0), (10.0, 20.0), (30.0, 20.0), (40.0, 0.0))),
PathSeg::Line(Line::new((40.0, 0.0), (80.0, 0.0))),
];
let reversed: Vec<PathSeg> = a.iter().rev().map(|s| s.reverse()).collect();
assert!(along_closely(&a, &reversed, 0.01));
let shifted: Vec<PathSeg> = reversed.iter().map(|s| kurbo::Affine::translate((0.0, 0.2)) * *s).collect();
assert!(along_closely(&a, &shifted, 0.25));
assert!(!along_closely(&a, &shifted, 0.1));
}
}
+62
View File
@@ -237,6 +237,68 @@ fn pf_outline_dedups_shared_edges() {
assert!(close(len, 70.0, 1e-9), "len {len}");
}
/// Outline follows Precision: two bars whose left edges cross a square's top edge 0.00005 pt apart
/// leave a piece of that length between the crossings at the default precision, and none at 10 pt,
/// where the two crossings are one junction.
#[test]
fn pf_outline_joins_junctions_closer_than_the_precision() {
let s = vec![shape(rect(0.0, 0.0, 100.0, 100.0), 1), shape(rect(50.0, 90.0, 10.0, 20.0), 2), shape(rect(50.00005, 95.0, 4.99995, 10.0), 3)];
let shortest = |r: &[Shape]| r.iter().map(|s| s.path.length()).fold(f64::INFINITY, f64::min);
let length = |r: &[Shape]| r.iter().map(|s| s.path.length()).sum::<f64>();
let at_default = pathfinder_with(PathfinderOp::Outline, &s, DEFAULT_PRECISION);
assert_eq!(at_default, pathfinder(PathfinderOp::Outline, &s));
assert!(shortest(&at_default) < 1e-4, "{at_default:?}");
let coarse = pathfinder_with(PathfinderOp::Outline, &s, 10.0);
assert!(shortest(&coarse) > 1e-3, "{coarse:?}");
assert!(coarse.len() < at_default.len(), "{} pieces at 10 pt, {} at the default", coarse.len(), at_default.len());
assert!(close(length(&coarse), length(&at_default), 1e-6), "{} against {}", length(&coarse), length(&at_default));
}
/// Outline at a tenth of the size and a tenth of the precision gives the same pieces at a tenth of
/// the length: crossings 0.05 pt apart on a 1,000 pt square at 10 pt, and 0.005 pt apart on a 100 pt
/// square at 1 pt, stay two junctions in both.
#[test]
fn pf_outline_scales_with_the_art_and_the_precision_together() {
let art = |k: f64| {
vec![
shape(rect(0.0, 0.0, 1000.0 * k, 1000.0 * k), 1),
shape(rect(500.0 * k, 900.0 * k, 100.0 * k, 200.0 * k), 2),
shape(rect(500.05 * k, 950.0 * k, 49.95 * k, 100.0 * k), 3),
]
};
let length = |r: &[Shape]| r.iter().map(|s| s.path.length()).sum::<f64>();
let large = pathfinder_with(PathfinderOp::Outline, &art(1.0), 10.0);
let small = pathfinder_with(PathfinderOp::Outline, &art(0.1), 1.0);
assert_eq!(large.len(), small.len(), "{large:?}\n{small:?}");
assert!(close(length(&large) / 10.0, length(&small), 1e-6), "{} against {}", length(&large), length(&small));
let pieces = |r: &[Shape], k: f64| {
let mut l: Vec<f64> = r.iter().map(|s| s.path.length() / k).collect();
l.sort_by(f64::total_cmp);
l
};
let (a, b) = (pieces(&large, 1.0), pieces(&small, 0.1));
assert!(a.iter().zip(&b).all(|(x, y)| close(*x, *y, 1e-6)), "{a:?} against {b:?}");
}
/// Two boundaries that are close only at their start, end and middle stay two edges at 10 pt: an
/// ellipse 0.005 pt inside a circle at its rightmost and leftmost points, and 30 pt inside it at
/// the top and bottom. Two copies of one boundary are still one edge at that precision.
#[test]
fn pf_outline_keeps_boundaries_that_differ_between_their_ends_at_coarse_precision() {
let ellipse = |rx: f64, ry: f64| PathData::from_bezpath(&kurbo::Ellipse::new((100.0, 100.0), (rx, ry), 0.0).to_path(1e-4));
let s = vec![shape(ellipse(50.0, 50.0), 1), shape(ellipse(49.995, 20.0), 2)];
let length = |r: &[Shape]| r.iter().map(|s| s.path.length()).sum::<f64>();
let expected = s[0].path.length() + s[1].path.length();
for precision in [DEFAULT_PRECISION, 10.0] {
let r = pathfinder_with(PathfinderOp::Outline, &s, precision);
assert_eq!(r.len(), 2, "{precision} pt: {r:?}");
assert!(close(length(&r), expected, 1e-6), "{precision} pt: {} against {expected}", length(&r));
}
let copies = vec![shape(ellipse(50.0, 50.0), 1), shape(ellipse(50.0, 50.0), 2)];
let r = pathfinder_with(PathfinderOp::Outline, &copies, 10.0);
assert!(close(length(&r), copies[0].path.length(), 1e-6), "{r:?}");
}
#[test]
fn regions_and_region_at() {
let s = stack();
+8 -3
View File
@@ -6414,7 +6414,10 @@ Pathfinder Options: `object.pathfinder.options {precision?, removeRedundantPoint
`prefs.get`/`prefs.set` with key `pathfinder`) reads and sets the options every later Shape Mode and Pathfinder
operation uses: `precision` (0.001–10 pt, default 0.01; a string with a unit or a string that is all one number also reads, and
any other string, such as `"1abc"`, is an error) is how closely results follow
the paths (they are refit to within it and pieces thinner than it are dropped), `removeRedundantPoints` takes the
the paths (they are refit to within it and pieces thinner than it are dropped; Outline treats crossings closer together
than `precision / 10000` as one point, or than the tolerance for the art's size when that is larger, and edges that lie
within ten times that distance of each other along their whole length as one edge; 0.01 keeps the earlier output, and
scaling the art and the precision together gives the same pieces at the new size), `removeRedundantPoints` takes the
anchors that don't change a result's shape off it, and `removeUnpainted` makes Divide and Outline leave out the pieces
of objects with no fill (or only hidden fills). Both default to false; `{}` reads the options. Each Shape Mode and
Pathfinder command (`object.pathfinder.unite` … `minusBack`) also takes `precision`, `removeRedundantPoints` and
@@ -6434,8 +6437,10 @@ mean what they mean for the panel's operations; the other operations ignore `rem
on, a compound shape's area counts as filled when the shape has a visible fill of its own, and Divide keeps every piece
when the group or compound shape has one. Outline strokes a compound shape's area in the shape's own fill, and gives
the edges no paint when the shape has no fill (the shape's own strokes still draw over the result). `effect.apply`
fills the ones `params` leave out from the current Pathfinder Options, and the values join its journal entry. An effect
saved without them evaluates with precision 0.01 and both switches off, as before effects kept them. `effect.setParams
fills the ones `params` leave out from the current Pathfinder Options, and all three values join its journal entry,
those `params` gave and those filled in, so a replay gives the same effect whatever the options are then. An effect
saved without them evaluates with precision 0.01 and both switches off, as before effects kept them. A stored
`precision` that is not a number (`true`, or a string such as `"1abc"`) evaluates and scales as 0.01. `effect.setParams
{index, params: {precision?, removeRedundantPoints?, removeUnpainted?}}` edits them as one undo step; values the
effect already evaluates with record no undo step and return `{ids: []}`. A precision out of range, or a switch that
isn't true or false, is refused with an error and nothing changes. Scale Strokes & Effects scales `precision` with the
+1 -1
View File
@@ -1739,7 +1739,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Revolve takes type, as its glyph outlines, and groups or layers, whose members sweep about one axis as [the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html) describes; a surface can have up to 16,384 profile points, and curves take fewer samples when a surface would pass 163,840 faces (#3617).
- Live effects with previewing dialogs: Distort & Transform, Path, Convert to Shape, 15 Warp styles, Round Corners, Scribble, Effect → Pathfinder (all 10 operations, live on groups; several loose objects are grouped first, in one undo step), Color Adjustments (Brightness/Contrast, Curves, Levels, Hue/Saturation, Shift to Color, Temperature/Tint, on vectors, live type and embedded images), and raster drop shadow, glows and feather. SVG and PDF export keep live effects (geometry baked; SVG raster effects as filters). Zig Zag spaces its ridges evenly along each segment, so lines and curves get a regular wave in Corner and Smooth (#1558). Warp › Arc (the effect and Envelope › Make with Warp) bends in the object's real proportions: a circular arc with concentric edges and no fold-over at 100%, so Arc on art that isn't square draws differently from before (#1581, fixes #1578). `effect.apply` and `effect.setParams` give an error for a misspelt or wrongly typed effect parameter instead of running the effect with its default (#1623, #1592). Roughen with Smooth keeps turn-backs smooth instead of making cusps that draw as spikes (#1646, #1643). Scribble draws one zig-zag per region, with no lines across holes and notches; convex shapes are unchanged (#1651, #1648). On the canvas, in Expand Appearance and in exports, Effect → Pathfinder uses the glyph outlines of type in the group, and results painted like the type keep its opacity and blend mode.
- Cmd/Ctrl+4 (`pathfinder.repeat`) repeats the last successful Pathfinder panel operation, direct `object.pathfinder.*` command or `command.batch` step (including Actions playback) on the current selection; the panel menu names it. `action.batch`, Trap, compound-shape edits and live effects do not set history. Public references: [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), [Pathfinder panel overview](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html).
- Pathfinder Options ([Pathfinder panel overview](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html)): the panel menu's Pathfinder Options… sets Precision (0.001–10 pt: results refit to within it, thinner pieces dropped), Remove Redundant Points and Divide and Outline Will Remove Unpainted Artwork (`object.pathfinder.options`, kept in the preferences) for every Shape Mode and Pathfinder operation; the defaults keep the earlier output (`pathops` `precision_drops_pieces_thinner_than_it`, engine `tests_pathops` Pathfinder Options tests, `panels::pathfinder` dialog test).
- Pathfinder Options ([Pathfinder panel overview](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html)): the panel menu's Pathfinder Options… sets Precision (0.001–10 pt: results refit to within it, thinner pieces dropped; Outline treats crossings closer together than a ten-thousandth of it as one point, or than the tolerance for the art's size when that is larger, by VectorCraft's own rule, `pf_outline_joins_junctions_closer_than_the_precision`, `pf_outline_scales_with_the_art_and_the_precision_together`), Remove Redundant Points and Divide and Outline Will Remove Unpainted Artwork (`object.pathfinder.options`, kept in the preferences) for every Shape Mode and Pathfinder operation; the defaults keep the earlier output (`pathops` `precision_drops_pieces_thinner_than_it`, engine `tests_pathops` Pathfinder Options tests, `panels::pathfinder` dialog test).
- Pathfinder on clip groups (#8093): a clip group's members take part in the Shape Modes and Pathfinder buttons (`object.pathfinder.*`) only where its clipping path shows them, so Divide cuts the visible art along the mask and the hidden art goes; nested clip groups cut by each mask, a member the mask hides gives no piece, a cutting line's hidden part cuts nothing, a selected object the masks hide altogether counts as an empty shape where that changes the result (Intersect, Minus Front, Minus Back, Crop), and the clipping path adds no piece of its own (the public documentation doesn't say what Pathfinder does with masked art; our choice, asked on the issue). A cutting line is clipped by sampling, so a part of the mask much narrower than the mask itself can be missed. Make Compound Shape, Trap and the Pathfinder effects still take the members whole. Tests: `crates/engine/src/tests/pathfinder_clip.rs`.
- Pathfinder › Trap ([trapping](https://helpx.adobe.com/illustrator/using/trapping.html), [Pathfinder panel](https://helpx.adobe.com/illustrator/using/pathfinder-panel-overview.html)): the Pathfinder panel menu's Trap… (`object.pathfinder.trap`) and Effect › Pathfinder › Trap… (`pathfinder.trap`, live on groups) add, where two objects' visible areas of different solid colours meet, a strip of the darker one's area along the edge, filled with the lighter colour at the Tint Reduction percentage and set to overprint (Reverse Traps: the darker colour spreads instead, but not a rich black); Thickness 0.01–5000 pt across vertical edges, Height/Width scales it across horizontal ones, Traps with Process Color paints a swatch colour's trap with its CMYK equivalent; the effect also has Precision and Remove Redundant Points. The panel's Trap is one undo step and groups the traps above the topmost selected object, selected; with no adjoining edges of different colours it says so and changes nothing. Tests: `crates/pathops/src/trap.rs`, `crates/effects/src/trap.rs`, `group::tests::trap_effect_adds_an_overprinting_strip_above_the_members`, `crates/engine/src/tests/trap.rs`, `panels::pathfinder::tests::trap_opens_its_options_and_ok_traps_the_selection`.
- Compound shapes ([Create compound shapes with Pathfinder](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/create-compound-shapes-with-pathfinder.html), [Pathfinder panel overview](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/pathfinder-panel-overview.html)): the Pathfinder panel menu's Make Compound Shape (every member in Add) and Alt-clicking a Shape Mode (every member in that mode) make the two or more selected paths, compound paths, groups, compound shapes or type a live compound shape (`object.compoundShape.make`): a group whose members each keep a shape mode and stay editable, drawn, printed and exported (SVG, PDF and the rest through the baked document) as the area the modes make from the backmost member up, open paths closed, painted with its own appearance, taken from the topmost member not subtracting. With members selected (Direct Selection, Layers panel, isolation mode) a Shape Mode button sets theirs (`object.compoundShape.setMode`) and is lit for the mode they share; with members in different modes selected, each of the four Shape Mode buttons carries a question mark and screen readers report it as mixed, and a click gives every selected member that mode in one undo step ([the help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=368)); paint given to a member goes to the compound shape. Release Compound Shape gives the members back as they were (`object.compoundShape.release`); Expand Compound Shape and the panel's Expand button turn it into the path or compound path of its area (`object.compoundShape.expand`). Shape Modes and Pathfinders take a compound shape as its area. Saved files keep it (`compound_shape`, `shape_mode`; an unknown mode reads as Add). Blends, envelopes and objects with a warp or another geometry effect are members as they draw (a blend's steps, an envelope's distorted art, the warped outline), and the area follows an edit of the blend, envelope or warp; Release gives them back as they were. Tests: `crates/engine/src/tests/compound_shape.rs`, `group::tests::compound_shapes_draw_the_area_their_shape_modes_make`, `group::tests::nested_compound_shapes_take_part_as_their_area`, `panels::pathfinder::tests::compound_shape_items_follow_the_selection`, `panels::pathfinder::tests::shape_modes_show_a_question_mark_while_the_selected_members_modes_differ`, `panels::pathfinder::tests::members_of_two_compound_shapes_are_compared_together`, `panels::pathfinder::tests::shape_modes_show_no_question_mark_without_mixed_members`, the `CompoundShape` op of the property-test strategies. Not yet: hit-testing by the area (a click hits the members).