mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 20:38:21 +00:00
Pathfinder: Outline's junction distance scales with the art and the precision together
Outline joined crossings closer together than the art-size tolerance multiplied by precision / 0.01. Scale Strokes & Effects scales the art and the precision together, so scaling both by 10 made that distance 100 times larger, and crossings that were apart could become one junction. The distance is now precision / 10000, or the tolerance for the art's size when that is larger. At the 0.01 pt default it is 0.000001 pt as before, and scaling the art and the precision together gives the same pieces at the new size. The params text of object.pathfinder.options and of the Pathfinder effects, docs/mcp.md and the Pathfinder Options line in docs/target-app-parity.md describe the new rule.
This commit is contained in:
@@ -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, 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 a tolerance multiplied by precision / 0.01 as one point), 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)"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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; Outline treats crossings closer together than a tolerance multiplied by precision / 0.01 as one point), 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
|
||||
),
|
||||
|
||||
@@ -1015,14 +1015,16 @@ fn along_closely(a: &[PathSeg], b: &[PathSeg], tol: f64) -> bool {
|
||||
|
||||
/// 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 its value at [`DEFAULT_PRECISION`] times `precision / DEFAULT_PRECISION`, a factor kept
|
||||
/// within 0.1 to 1000 (Pathfinder Options › Precision's range of 0.001 to 10 pt).
|
||||
/// `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) * (precision / DEFAULT_PRECISION).clamp(0.1, 1000.0);
|
||||
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 {
|
||||
|
||||
@@ -254,6 +254,32 @@ fn pf_outline_joins_junctions_closer_than_the_precision() {
|
||||
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.
|
||||
|
||||
+3
-2
@@ -6257,8 +6257,9 @@ Pathfinder Options: `object.pathfinder.options {precision?, removeRedundantPoint
|
||||
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; Outline treats crossings closer together
|
||||
than a small tolerance as one point and edges that lie within ten times it as one edge, and that tolerance is multiplied by
|
||||
`precision / 0.01`, so 0.01 keeps it as it was and 10 makes it 1,000 times larger), `removeRedundantPoints` takes the
|
||||
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
|
||||
|
||||
@@ -1707,7 +1707,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; Outline treats crossings closer together than a tolerance scaled by it as one point, by VectorCraft's own rule, `pf_outline_joins_junctions_closer_than_the_precision`), 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).
|
||||
|
||||
Reference in New Issue
Block a user