From bd0d0149ac2c83b3c7a14129a09ebb8f709ac6e2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:00:26 -0800 Subject: [PATCH] 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. --- crates/engine/src/cmd/brushsym.rs | 2 +- crates/engine/src/tests/brushsym.rs | 15 +++++++++++++++ docs/mcp.md | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/brushsym.rs b/crates/engine/src/cmd/brushsym.rs index 2de3ddfcfe..84f7c5ed3b 100644 --- a/crates/engine/src/cmd/brushsym.rs +++ b/crates/engine/src/cmd/brushsym.rs @@ -98,7 +98,7 @@ pub fn specs() -> Vec { "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 ), diff --git a/crates/engine/src/tests/brushsym.rs b/crates/engine/src/tests/brushsym.rs index 86074c2a6b..33363119c1 100644 --- a/crates/engine/src/tests/brushsym.rs +++ b/crates/engine/src/tests/brushsym.rs @@ -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] diff --git a/docs/mcp.md b/docs/mcp.md index b22bc55ef5..14e4d45f77 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -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