mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 17:23:00 +00:00
Merge pull request #9015 from dotCooCoo/fix/smooth-no-worse-pass
Smooth: a drag that would not make a path smoother leaves it as it was
This commit is contained in:
+13
@@ -7261,6 +7261,19 @@ own, and the corner keeps its place and the directions the path arrives and leav
|
||||
`fidelity`. A call that changes no anchor returns `{ids: [], before: 0, after: 0}` and adds no undo step. The 57.5°
|
||||
threshold is VectorCraft's own value.
|
||||
|
||||
`path.smoothRegion` keeps a subpath's result only when it is smoother. It measures the subpath and the result along
|
||||
lines between points on each curved segment, spaced about `step` apart along the segment's control polygon, where
|
||||
`step` is an eighth of `radius` or 1/512 of the diagonal of the box around the subpath's anchors and handles,
|
||||
whichever is smaller. The spacing is a target: each curved segment is cut into at least 4 and at most 1,024 pieces,
|
||||
and on a subpath of more than 256 segments into at most 262,144 divided by the number of segments (but never fewer
|
||||
than 4). The turning `t` is how far the path's direction turns along its length, in radians, with each turn at an
|
||||
anchor counted twice; the bending `b` is the sum of each turn between two pieces squared over their mean length.
|
||||
With `t0` and `b0` measured on the subpath, `t1` and `b1` on the result, and `s` the larger of `t0` and 1, the result
|
||||
is kept when `t1 <= t0 + 0.001 * s` and at least one of these holds: it has fewer anchors, `t0 - t1 >= 0.000001 * s`,
|
||||
or `b0 - b1 > 0.0001 * b0`. Any other result is dropped and the subpath stays as it was. A path none of whose subpaths is kept stays a Live
|
||||
Shape if it was one, is left out of `ids` and is not counted in `before` or `after`. The measure and both thresholds
|
||||
are VectorCraft's own.
|
||||
|
||||
In the desktop app, Object › Path › Smooth, the canvas context menu's Smooth… (listed while the selection holds a
|
||||
path) and the Contextual Task Bar's Smooth (with a path selected whole with the Direct Selection tool) open the
|
||||
slider (`ui.menuDialog {command: "object.path.smooth"}`, dialog `smoothSlider` with field `level`) at the
|
||||
|
||||
@@ -1559,6 +1559,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
`brush.freehand` refuses a `brush` that names no brush in the document, or is not a string, and a `style` other than "pencil" or "brush", with an error and no change or undo step, instead of drawing the plain path; the Paintbrush skips a chosen brush that has since been deleted (engine tests `brush_freehand_refuses_a_brush_or_style_it_cannot_use` and `paintbrush_tool_skips_a_deleted_brush`).
|
||||
A `brush.freehand` stroke and its brush are one undo step, so one Undo removes both. A `brush` for a path with no stroke (a continued or redrawn path without one, or a new filled "pencil" path while the stroke is None) is refused with "cannot apply brush `<name>`: path has no stroke", and a key the command does not take with "unknown parameter", with no change or undo step; the no-stroke refusal is VectorCraft's own rule (engine tests `brush_freehand_direct_call_has_one_undo_step`, `brush_freehand_refuses_a_brush_on_a_path_without_a_stroke` and `brush_freehand_refuses_unknown_keys`).
|
||||
Each drag of the Smooth tool smooths the stretch of a selected path in its reach along its length before refitting it within Fidelity, so a wobble wider than Fidelity is smoothed out and another drag over the same place smooths it further, as [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) describes (`path.smoothRegion`). The smoothing spread (a third of the reach) and the rule that each refit stays within twice the distance the smoothing moved the path, so repeated drags do not drift from it, are VectorCraft's own. A drag over the whole of a closed path smooths it across its first anchor too, so a bump there is smoothed like any other and no corner is left; Object › Path › Smooth smooths a closed path across its first anchor the same way.
|
||||
A Smooth drag changes a path only when the result is smoother, which [the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=79) gives as the aim of the tool's Fidelity: the result turns no more than a thousandth more along its length than the path did, with each turn at an anchor counted twice, and it has fewer anchors, turns less or bends less. Otherwise the path stays as it was and keeps its Live Shape, and the drag adds no undo step, so drags over a clean ellipse no longer add anchors to it or leave it rougher. A drag that only splits a convex curve into more anchors without smoothing it now leaves the path as it was. The measure and its thresholds are VectorCraft's own (engine tests `smooth_drags_over_a_clean_ellipse_change_nothing`, `a_smooth_drag_over_an_ellipse_and_a_jagged_line_changes_only_the_line`, `a_smooth_drag_at_the_lowest_fidelity_still_smooths_a_jagged_line` and `cmd::draw2::smooth::tests::the_smooth_tool_keeps_only_a_smoother_result`).
|
||||
When a Smooth tool drag reaches the first anchor of a closed path, the smoothed path starts at its point nearest where that anchor was: at an anchor there, or at a new anchor split into the curve without changing its outline. Dashes and type on the path start from that point. A drag that does not reach the first anchor leaves it first. This is VectorCraft's own rule (engine tests `smoothing_over_a_closed_paths_first_anchor_keeps_its_start` and `smoothing_a_whole_closed_path_with_a_spike_keeps_its_start`).
|
||||
The Smooth tool shows the Not Allowed cursor while no path is selected that it can act on (an editable path, not a guide, with three or more anchors on one of its subpaths or two anchors joined by a curve), and the release of a drag then sends no command and changes nothing; [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) has the path selected first. A selected path anywhere on the canvas gives the Smooth cursor wherever the pointer is. The Pencil with Alt key toggles to Smooth Tool on and the Blob Brush show Not Allowed the same way when Alt gives them the Smooth tool; the Paintbrush keeps its closing cursor, since its release with Alt closes the stroke. Use Precise Cursors leaves Not Allowed as it is. This cursor rule is VectorCraft's own (tools `smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `borrowed_smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `smoothing_release_sends_nothing_without_a_selected_path_to_smooth`; engine `use_precise_cursors_keeps_the_smooth_tools_not_allowed_pointer`).
|
||||
When a Smooth tool drag reaches the first or last anchor of an open path, that anchor stays where it is and the curve there leaves or arrives along the smoothed path within the reach, so a jagged first or last segment no longer sets the end's direction; an end where the smoothed path turns back by 90° or more keeps its segment's direction, and where the refitted stretch ends inside the path the curve keeps the direction of the part outside the drag. This rule is VectorCraft's own (`tests/draw2.rs`, `smoothing_an_open_path_turns_its_jagged_ends_with_the_path` and `a_smooth_drag_turns_only_the_end_it_reaches`).
|
||||
|
||||
Reference in New Issue
Block a user