Color Effects: Randomize Fill Colors leaves art on a locked artboard alone

Objects named in `ids` skipped the locked-artboard filter that the
selection applies, so the command could recolor art on a locked artboard.
The command now skips every target the locked artboards hold, checked once
per run with `Document::locked_artboards`. New art made on a locked
artboard that is still selected takes a color, as with other commands.

The params text, docs/mcp.md and the ROADMAP entry state the rule.
This commit is contained in:
dotCooCoo committed 2026-11-29 10:45:46 -08:00
1 parent 9334f11ddf
commit 2c807a0e9d
5 files changed
+19 -5

No files matched your search

+1 -1
View File
@@ -160,7 +160,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
- 2026-11-11: Pattern libraries: Patterns › Grit Textures, a second built-in pattern library, holds eight seamless black textures (Fine Grain, Coarse Grit, Sand, Speckle, Stipple, Scratches, Sparse Flecks and Dense Flecks) on tiles of 18 to 36 pt, each drawn the same way every time; marks that reach past a tile edge continue on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
- 2026-11-11: Pattern libraries: Patterns › Optical Effects, a third built-in pattern library, of VectorCraft's own designs, holds eight black wave, moiré and op-art tiles (Sine Bands, Ripple Lines, Interference Rings, Offset Rings, Warped Checks, Pinched Stripes, Chevron Pulse and Radiating Lenses) of 32 to 48 pt, each drawn the same way every time; each tile is one period of its design, and art that reaches past a tile edge continues on the next tile, so the tiles join without a seam (`swatch.library.add`). Scores and estimates unchanged.
- 2026-11-01: Find Nearest Swatch joins the Color Effects add-on (Object › Plug-ins › Color Effects): for each colour of the selection, the closest swatches of the document, a built-in library or a library or colour book the user loaded, with their CIEDE2000 difference; Apply gives each colour its nearest swatch as one undo step, linking global and spot swatches and adding a library's to the document first, so a process colour becomes the closest spot colour (`addon.color.nearestSwatch`, `addon.color.applyNearestSwatch`, #4923).
- 2026-11-29: Randomize Fill Colors joins the Color Effects add-on (Object › Plug-ins › Color Effects): each selected filled path and compound path, inside groups too, gets a fill color of its own at random: any color, tints of a global or spot swatch, or grays between a minimum and a maximum percent, with a seed that repeats the result and Preview, as one undo step (`addon.color.randomFill`).
- 2026-11-29: Randomize Fill Colors joins the Color Effects add-on (Object › Plug-ins › Color Effects): each selected filled path and compound path, inside groups too, gets a fill color of its own at random: any color, tints of a global or spot swatch, or grays between a minimum and a maximum percent, with a seed that repeats the result and Preview, as one undo step (`addon.color.randomFill`); art on a locked artboard keeps its fill (also when `ids` names it), except new art made there while it is still selected.
- 2026-11-01: Expand Dashes into Paths joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): each selected path's dashed stroke becomes separate open paths, one per dash, laid out exactly as the stroke draws them (pattern, offset, Align Dashes to Corners and Path Ends), each keeping the stroke with the dashes off, so the gaps are real gaps for cutters and plotters, as one undo step (`addon.pathtools.expandDashes`, #4922).
- 2026-11-01: Randomize Opacity joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): each selected object gets its own opacity at random between a minimum and a maximum percent, with a seed that repeats the result, as one undo step (`addon.arrange.randomizeOpacity`, #4925).
- 2026-11-01: Sort Objects joins the Arrange Tools add-on (Object › Plug-ins › Arrange Tools): the selected objects are sorted by width, height, area, position, opacity or stacking order (small to large, large to small or at random) and take another of those in that order, trading their values or stepping them evenly, as one undo step (`addon.arrange.sort`, #4917).
+1 -1
View File
@@ -99,7 +99,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Randomize Fill Colors",
["Object", "Plug-ins", "Color Effects"],
None,
"{scheme?: \"color\" (any color: red, green and blue each at random, in the document's color mode) | \"tint\" (a tint of `swatch`, linked to it) | \"gray\" (a gray) (\"color\"), swatch?: a global or spot color swatch's name (tint only, and needed there; a tint swatch gives tints of its base), min?: % 0..100 (0), max?: % 0..100 (100; not less than min) (tint and gray only: the tint, or the gray's black, ranges from min to max), seed?: whole number (0; the same seed, objects and settings give the same colors), ids?: [id…] (default: the selection)} give each selected filled path and compound path, and each one inside the selected groups, its own top fill color, picked at random and evenly within the scheme, as one undo step (none when no fill changes). Paths and compound paths with no fill, clipping paths, hidden and locked objects (and objects in hidden or locked groups and layers), type, images, symbol instances, blends and envelopes keep their fills; a gradient or pattern fill becomes the color. On paths directly in a graph series whose fill changes, the graph stores the fill of the frontmost of them for its next redraw, which gives every mark of the series that one color (docs/mcp.md) → {count: objects whose fill changed}",
"{scheme?: \"color\" (any color: red, green and blue each at random, in the document's color mode) | \"tint\" (a tint of `swatch`, linked to it) | \"gray\" (a gray) (\"color\"), swatch?: a global or spot color swatch's name (tint only, and needed there; a tint swatch gives tints of its base), min?: % 0..100 (0), max?: % 0..100 (100; not less than min) (tint and gray only: the tint, or the gray's black, ranges from min to max), seed?: whole number (0; the same seed, objects and settings give the same colors), ids?: [id…] (default: the selection)} give each selected filled path and compound path, and each one inside the selected groups, its own top fill color, picked at random and evenly within the scheme, as one undo step (none when no fill changes). Paths and compound paths with no fill, clipping paths, hidden and locked objects (and objects in hidden or locked groups and layers, or on a locked artboard, also when given in ids, except new art made there while it is still selected), type, images, symbol instances, blends and envelopes keep their fills; a gradient or pattern fill becomes the color. On paths directly in a graph series whose fill changes, the graph stores the fill of the frontmost of them for its next redraw, which gives every mark of the series that one color (docs/mcp.md) → {count: objects whose fill changed}",
has_selection,
random_fill::run
),
@@ -108,20 +108,22 @@ pub(super) fn run(s: &mut Session, p: &Value) -> Result<Value> {
let count = edit_if_changed(s, "Randomize Fill Colors", |before, d| {
// A graph's series group stands for its marks, as for `paint.setFill`.
let roots = paint_targets(before, &ids);
// Art on a locked artboard is left as it is, as for the other commands that take `ids`.
let locks = before.locked_artboards();
let mut targets = vec![];
for id in &roots {
let id = before
.parent_of(*id)
.filter(|parent| before.node(*parent).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. })))
.unwrap_or(*id);
if left_alone(before, id) {
if left_alone(before, id) || locks.holds_id(id) {
continue;
}
let Some(n) = before.node(id) else { continue };
filled(n, &mut targets);
}
let mut seen = std::collections::HashSet::new();
targets.retain(|id| seen.insert(*id));
targets.retain(|id| seen.insert(*id) && !locks.holds_id(*id));
let count = keeping_series_paint(d, &roots, |d| {
let mut count = 0;
for id in &targets {
@@ -259,3 +259,15 @@ fn bad_params_are_refused() {
assert_eq!(steps(&s), n);
assert!(*s.doc().unwrap().doc == *before, "the document is unchanged");
}
#[test]
fn art_on_a_locked_artboard_given_by_id_keeps_its_fill() {
let mut s = session();
let a = rect(&mut s, 0.0);
let before = fill(&s, a);
s.execute("artboard.setProps", &json!({"index": 0, "locked": true})).unwrap();
let n = steps(&s);
assert_eq!(s.execute(C, &json!({"ids": [a.0], "seed": 3})).unwrap()["count"], json!(0));
assert_eq!(fill(&s, a), before);
assert_eq!(steps(&s), n);
}
+1 -1
View File
@@ -17277,7 +17277,7 @@ groups, a top fill color of its own, picked at random and evenly, as one undo st
`min` and `max` are 0 to 100 (0 and 100 when left out) and go with `tint` and `gray` only; `swatch` goes with `tint`
only and is needed there (a tint swatch gives tints of its base). The same `seed` (a whole number, 0 when left out),
objects and settings give the same colors. Paths and compound paths with no fill, clipping paths (a compound path that
clips included), hidden and locked objects and the objects in hidden or locked groups and layers, type, images, symbol instances, blends and envelopes keep their fills; a gradient or pattern fill is replaced by
clips included), hidden and locked objects and the objects in hidden or locked groups and layers or on a locked artboard (also when `ids` names them; new art made there while it is still selected takes a color), type, images, symbol instances, blends and envelopes keep their fills; a gradient or pattern fill is replaced by
the color. On paths directly in a graph series whose fill changes, the graph stores the fill of the frontmost of them
for its next redraw, so after the redraw every mark of the series has that one color. It returns the
`count` of objects whose fill changed. An unknown scheme, `min` or `max` with `color`, `swatch` without `tint`, a