Brushes: Apply Brush text says it clears a stroke's own settings

brush.apply clears the brush settings of each path's top stroke, and
clearing them is one undo step. The command text and docs/mcp.md now
limit the no-op to a current brush whose top strokes already have it,
paint, a width above 0 and no settings of their own. A new test applies
the current brush to a stroke with its own settings and checks that they
are cleared as one undo step.
This commit is contained in:
dotCooCoo committed 2026-11-29 10:00:26 -08:00
1 parent c77fd87964
commit bd0d0149ac
3 files changed
+19 -3

No files matched your search

+1 -1
View File
@@ -98,7 +98,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Apply Brush",
[],
None,
"{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current; when the strokes already have it and it is already current, nothing changes and no undo step is recorded → {ids}",
"{name, ids?|id?} apply a brush to the strokes of the selected paths (adds a stroke if missing) and make it current; the brush settings of each path's top stroke (brush.objectOptions) are cleared, and clearing them is one undo step; when the brush is already current and applying it leaves every path as it was (its top stroke already has the brush, paint, a width above 0 and no settings of its own), nothing changes and no undo step is recorded → {ids}",
has_doc,
brush_apply
),
+15
View File
@@ -969,6 +969,21 @@ fn brush_apply_that_changes_nothing_records_no_undo_step() {
assert_eq!(undo_steps(&s), steps + 1, "a new stroke to paint is one undo step");
}
/// Applying the current brush again to a stroke with settings of its own clears them as one undo step.
#[test]
fn brush_apply_clears_object_options_as_one_undo_step() {
let mut s = session();
let a = line(&mut s);
select(&mut s, &[a]);
s.execute("brush.apply", &json!({"name": "Arrow"})).unwrap();
s.execute("brush.objectOptions", &json!({"params": {"width": 50}})).unwrap();
assert_eq!(own_options(&s, a), json!({"width": 50.0}));
let steps = undo_steps(&s);
s.execute("brush.apply", &json!({"name": "Arrow"})).unwrap();
assert_eq!(own_options(&s, a), json!({}), "applying the brush clears the stroke's own settings");
assert_eq!(undo_steps(&s), steps + 1, "clearing the settings is one undo step");
}
/// A document whose brushes repeat a name opens with the later brush numbered: strokes of the name
/// keep the first brush, and renaming or deleting one brush leaves the other and its strokes alone.
#[test]
+3 -2
View File
@@ -5180,8 +5180,9 @@ already walks Image Trace. Short agent entry points:
the one found first), or black when they use no solid color. `brush.options` changes only the fields of
`colorization` and of an art brush's `scale` that `params` gives, so `{colorization: {method: "hueShift"}}` keeps a
Hue Shift brush's key. A `brush.options` whose `params` and `newName` leave the brush as it is, and a
`brush.apply` whose strokes already have the brush while it is already current, do not change the document or
its revision and record no undo step. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the
`brush.apply` of the current brush whose paths' top strokes already have the brush, paint, a width above 0 and no
settings of their own, do not change the document or its revision and record no undo step. `brush.apply` clears the own settings
(`brush.objectOptions`) of each path's top stroke, and clearing them is one undo step; lower strokes keep theirs. A scatter brush's `hue_jitter` (0 to 180 degrees, VectorCraft's own range; 0, the
default, leaves every copy's colors as the colorization gives them) turns the hue of each copy's solid fills and
strokes, its type's characters included, by that copy's own amount between minus and plus that many degrees. The
turn comes after the colorization: with None it turns the art's own colors, with Tints and Tints and Shades the