From 5fccf73431456ec49eb08f0761649eeb2dbe4b69 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 18:02:26 -0800 Subject: [PATCH] Color Effects: Randomize Fill Colors colors compound marks in a graph series A compound path or live compound shape directly in a graph series group now takes a color. Generated column, marker and legend swatch copies carry a new graph_design_art flag and keep their design's fill; in documents saved before the flag, a compound in a series whose assigned design is itself a compound is still treated as design art. Paths a user groups inside a series keep their fills, as for paint.setFill. Nested members resolve to the outermost compound in one walk of the ancestry, and series membership is looked up once per run. --- ROADMAP.md | 2 +- crates/doc/src/graph.rs | 1 + crates/doc/src/node/extras.rs | 3 + crates/doc/src/node/tests.rs | 2 + crates/doc/src/node/wire.rs | 5 + crates/engine/src/cmd/addons/color.rs | 2 +- .../src/cmd/addons/color/random_fill.rs | 136 +++++- .../src/cmd/addons/color/random_fill/tests.rs | 415 ++++++++++++++++++ crates/engine/src/cmd/graph.rs | 4 +- crates/engine/src/cmd/graph/columns.rs | 4 +- crates/engine/src/cmd/graph/labels.rs | 4 +- crates/engine/src/cmd/graph/series.rs | 2 +- docs/mcp.md | 12 +- docs/target-app-parity.md | 2 +- 14 files changed, 567 insertions(+), 27 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index e00dedaaa6..bc350856d2 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -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`); 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-29: Randomize Fill Colors joins the Color Effects add-on (Object › Plug-ins › Color Effects): each selected filled path, compound path and live compound shape, inside groups and graph series 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). diff --git a/crates/doc/src/graph.rs b/crates/doc/src/graph.rs index 36fe29a8f2..43614eba87 100644 --- a/crates/doc/src/graph.rs +++ b/crates/doc/src/graph.rs @@ -108,6 +108,7 @@ impl GraphDesign { let mut e = n.extras_mut(); e.graph = None; e.series_index = None; + e.graph_design_art = false; } if let Some(ch) = n.children_mut() { let old = std::mem::take(ch); diff --git a/crates/doc/src/node/extras.rs b/crates/doc/src/node/extras.rs index 9dbb409706..99ca99a2c5 100644 --- a/crates/doc/src/node/extras.rs +++ b/crates/doc/src/node/extras.rs @@ -22,6 +22,8 @@ pub struct NodeExtras { /// Index of the graph series this generated group belongs to. Axes, the legend and other /// children leave it unset, so a series named "Legend" or "Axes" is not mistaken for them. pub series_index: Option, + /// This object is a generated copy of a graph column or marker design. + pub graph_design_art: bool, /// The group holds the glyph outlines of type. Geometry effects that reshape it move and scale /// the placed gradients in it with the outlines. pub type_outlines: bool, @@ -108,6 +110,7 @@ pub(super) static NO_EXTRAS: NodeExtras = NodeExtras { wrap: None, graph: None, series_index: None, + graph_design_art: false, type_outlines: false, pixelated: false, shaper: None, diff --git a/crates/doc/src/node/tests.rs b/crates/doc/src/node/tests.rs index 8d6520265a..8b8d848ed3 100644 --- a/crates/doc/src/node/tests.rs +++ b/crates/doc/src/node/tests.rs @@ -13,6 +13,7 @@ fn extras_are_written_flat_in_order() { e.mask = Some(Box::new(OpacityMask::new(Node::group(NodeId(8), vec![]), true))); e.trace = Some(Box::new(serde_json::json!({"preset": "p"}))); e.series_index = Some(2); + e.graph_design_art = true; e.type_outlines = true; e.graphic_style = Some(3); e.attrs = Some(Box::default()); @@ -59,6 +60,7 @@ fn extras_are_written_flat_in_order() { "mask", "trace", "series_index", + "graph_design_art", "type_outlines", "kind", "graphic_style", diff --git a/crates/doc/src/node/wire.rs b/crates/doc/src/node/wire.rs index d543c9d9e1..234adb7793 100644 --- a/crates/doc/src/node/wire.rs +++ b/crates/doc/src/node/wire.rs @@ -36,6 +36,7 @@ impl Serialize for Node { e.wrap.is_none(), e.graph.is_none(), e.series_index.is_none(), + is_default(&e.graph_design_art), is_default(&e.type_outlines), is_default(&e.pixelated), e.shaper.is_none(), @@ -86,6 +87,7 @@ impl Serialize for Node { field!("wrap", &e.wrap); field!("graph", &e.graph); field!("series_index", &e.series_index); + field!("graph_design_art", &e.graph_design_art); field!("type_outlines", &e.type_outlines); field!("pixelated", &e.pixelated); field!("shaper", &e.shaper); @@ -220,6 +222,8 @@ pub(super) struct NodeWire { #[serde(default)] series_index: Option, #[serde(default)] + graph_design_art: bool, + #[serde(default)] type_outlines: bool, #[serde(default)] pixelated: bool, @@ -480,6 +484,7 @@ impl From for Node { wrap: w.wrap, graph: w.graph, series_index: w.series_index, + graph_design_art: w.graph_design_art, type_outlines: w.type_outlines, pixelated: w.pixelated, shaper: w.shaper, diff --git a/crates/engine/src/cmd/addons/color.rs b/crates/engine/src/cmd/addons/color.rs index c991d75389..bd07f1552f 100644 --- a/crates/engine/src/cmd/addons/color.rs +++ b/crates/engine/src/cmd/addons/color.rs @@ -99,7 +99,7 @@ pub fn specs() -> Vec { "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, 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}", + "{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, which must still support tints), 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, compound path and live compound shape, 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). Compound paths and live compound shapes take one color and keep their members' fills. An id naming a nested member targets the outermost compound. Paths, compound paths and live compound shapes 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), generated graph design art, paths a user groups inside a graph series, 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 ), diff --git a/crates/engine/src/cmd/addons/color/random_fill.rs b/crates/engine/src/cmd/addons/color/random_fill.rs index f8ac3967b3..eaf78e5660 100644 --- a/crates/engine/src/cmd/addons/color/random_fill.rs +++ b/crates/engine/src/cmd/addons/color/random_fill.rs @@ -1,18 +1,22 @@ //! Randomize Fill Colors (`addon.color.randomFill`, Object › Plug-ins › Color Effects › Randomize -//! Fill Colors…): each selected filled path and compound path, and each one inside the selected +//! Fill Colors…): each selected filled path, compound path and live compound shape, and each one inside the selected //! groups, gets a fill color of its own, picked at random from a seed: any color, a tint of one //! global or spot swatch, or a gray, as one undo step. #[cfg(test)] mod tests; +use std::collections::HashSet; + use serde_json::{Value, json}; use vectorcraft_color::recolor::Rng; use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{Document, Node, NodeId, NodeKind}; use super::super::super::colorcmds::{edit_if_changed, keeping_series_paint}; -use super::super::super::graph::paint_targets; +#[cfg(test)] +use super::super::super::graph::is_design_art; +use super::super::super::graph::{is_series_group, paint_targets}; use super::super::super::menucmds::whole_or; use super::super::super::paint::swatch_solid; use super::super::super::{bad, checked_ids_or_selection, number_or, text_param}; @@ -32,10 +36,10 @@ enum Scheme { Gray(f32, f32), } -/// The percentage `p` gives for `key` (`default` when left out) as a fraction. -fn percent(p: &Value, key: &str, default: f64) -> Result { +/// The percentage `p` gives for `key` (`default` when left out). +fn percent(p: &Value, key: &str, default: f64) -> Result { let v = number_or(p, key, default, C)?; - if (0.0..=100.0).contains(&v) { Ok((v / 100.0) as f32) } else { Err(bad(C, format!("`{key}` must be from 0 to 100"))) } + if (0.0..=100.0).contains(&v) { Ok(v) } else { Err(bad(C, format!("`{key}` must be from 0 to 100"))) } } /// The scheme `p` asks for, checked against the document's swatches. @@ -58,11 +62,18 @@ fn scheme(s: &Session, p: &Value) -> Result { if min > max { return Err(bad(C, "`min` is greater than `max`")); } + let (min, max) = ((min / 100.0) as f32, (max / 100.0) as f32); if name == "gray" { return Ok(Scheme::Gray(min, max)); } let swatch = text_param(p, "swatch", C)?.ok_or_else(|| bad(C, "scheme tint needs a `swatch`: a global or spot color swatch"))?; - swatch_solid(&s.doc()?.doc, swatch, Some(1.0)).map_err(|e| bad(C, e))?; + let d = &s.doc()?.doc; + swatch_solid(d, swatch, Some(1.0)).map_err(|e| bad(C, e))?; + if let Some((base, _)) = d.swatch_link(swatch) + && d.tint_paint(&base, 1.0).is_none() + { + return Err(bad(C, format!("`{swatch}` needs a global or spot base swatch `{base}`"))); + } Ok(Scheme::Tint(swatch.to_string(), min, max)) } @@ -77,7 +88,7 @@ fn left_alone(d: &Document, id: NodeId) -> bool { matches!(nodes.as_slice(), [.., parent, n] if parent.clips() && parent.children().and_then(|c| c.first()).is_some_and(|c| c.id == n.id)) } -/// Add to `out` `n` when it is a filled path or compound path that is shown and unlocked, or the +/// Add to `out` `n` when it is a filled path, compound path or live compound shape that is shown and unlocked, or the /// ones inside it when it is a group or a layer. A clipping path (the first object of a clipping /// group or clipped layer, a compound path included), a guide, type, images, symbol instances, /// blends and envelopes are left as they are. @@ -85,6 +96,12 @@ fn filled(n: &Node, out: &mut Vec) { if !n.visible || n.locked { return; } + if n.is_compound_shape() { + if !n.appearance.fill_paint().is_none() { + out.push(n.id); + } + return; + } match &n.kind { NodeKind::Group { children, .. } | NodeKind::Layer { children, .. } => { for c in children.iter().skip(usize::from(n.clips())) { @@ -96,6 +113,45 @@ fn filled(n: &Node, out: &mut Vec) { } } +/// `ids` with each graph series group replaced by the paths, compound paths and live compound shapes directly inside +/// it. A compound path or live compound shape directly in a series group is kept, and the other ids go through +/// [`paint_targets`], as for `paint.setFill`. +fn series_roots(doc: &Document, ids: &[NodeId]) -> Vec { + let is_series = |id: NodeId| doc.node(id).is_some_and(|n| is_series_group(doc, n)); + let compound = |n: &Node| matches!(n.kind, NodeKind::Compound { .. }) || n.is_compound_shape(); + let ordinary: std::collections::HashSet = paint_targets(doc, ids).into_iter().collect(); + let mut out = vec![]; + for id in ids { + let Some(n) = doc.node(*id) else { continue }; + if is_series(*id) { + out.extend(n.children().into_iter().flatten().filter(|m| matches!(m.kind, NodeKind::Path { .. }) || compound(m)).map(|m| m.id)); + } else if (compound(n) && doc.parent_of(*id).is_some_and(is_series)) || ordinary.contains(id) { + out.push(*id); + } + } + let mut seen = std::collections::HashSet::new(); + out.retain(|id| seen.insert(*id)); + out +} + +/// The graph series groups among the ancestors of `targets`, each checked once. +fn cached_series_groups(doc: &Document, targets: &[NodeId]) -> HashSet { + let mut groups: HashSet = targets.iter().filter_map(|id| doc.ancestry(*id)).flatten().collect(); + groups.retain(|id| doc.node(*id).is_some_and(|n| is_series_group(doc, n))); + groups +} + +/// [`is_design_art`] with the series groups looked up in `series_groups`. +fn cached_is_design_art(doc: &Document, id: NodeId, series_groups: &HashSet) -> bool { + let Some(chain) = doc.ancestry(id) else { return false }; + let Some(at) = chain.iter().position(|a| series_groups.contains(a)) else { return false }; + match chain.len() - at { + 1 => false, + 2 => doc.node(id).is_some_and(|n| !matches!(n.kind, NodeKind::Path { .. })), + _ => true, + } +} + pub(super) fn run(s: &mut Session, p: &Value) -> Result { let scheme = scheme(s, p)?; let mut rng = Rng::new(whole_or(p, "seed", 0, C)?); @@ -106,24 +162,76 @@ pub(super) fn run(s: &mut Session, p: &Value) -> Result { let model = s.doc()?.doc.color_mode.model(); // A run that gives every object the fill it has records no undo step. 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(); + // A nested member stands for the outermost compound path or live compound shape after each ancestor is checked. + let mut resolved = vec![]; + for id in &ids { + let Some(chain) = before.ancestry(*id) else { continue }; + let mut target = None; + let mut blocked = false; + let mut parent: Option<&Node> = None; + let mut layer_object_checked = false; + for ancestor in &chain { + let Some(n) = before.node(*ancestor) else { + blocked = true; + break; + }; + if !n.visible || n.locked || parent.is_some_and(|p| p.clips() && p.children().and_then(|c| c.first()).is_some_and(|c| c.id == n.id)) { + blocked = true; + break; + } + if !layer_object_checked && (n.is_ruler_guide() || !n.is_layer()) { + layer_object_checked = true; + if !n.is_ruler_guide() && locks.holds(n) { + blocked = true; + break; + } + } + if matches!(n.kind, NodeKind::Compound { .. }) || n.is_compound_shape() { + target.get_or_insert(*ancestor); + } + parent = Some(n); + } + if !blocked { + resolved.push(target.unwrap_or(*id)); + } + } + // A graph's series group stands for its marks, as for `paint.setFill`. + let roots = series_roots(before, &resolved); 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); + let id = *id; if left_alone(before, id) || locks.holds_id(id) { continue; } let Some(n) = before.node(id) else { continue }; filled(n, &mut targets); } + let series_groups = cached_series_groups(before, &targets); let mut seen = std::collections::HashSet::new(); - targets.retain(|id| seen.insert(*id) && !locks.holds_id(*id)); + // A compound directly in a series group is one of the series' marks unless the graph drew it from a design; + // the rest of the series' art below its top level is design art. + let series_compound = |id: NodeId| { + let Some(n) = before.node(id) else { return false }; + if !(matches!(n.kind, NodeKind::Compound { .. }) || n.is_compound_shape()) || n.extras().graph_design_art { + return false; + } + let Some(group) = before.parent_of(id).filter(|p| series_groups.contains(p)).and_then(|p| before.node(p)) else { return false }; + let Some(index) = group.extras().series_index.and_then(|i| usize::try_from(i).ok()) else { return false }; + let graph = before.parent_of(group.id).and_then(|p| before.node(p)).and_then(|p| p.extras().graph.as_deref()); + graph.is_some_and(|spec| { + let column = spec.series_columns.get(index).and_then(Option::as_ref).map(|c| c.design.as_str()); + let marker = spec.series_markers.get(index).and_then(Option::as_deref); + ![column, marker].into_iter().flatten().any(|name| { + before + .graph_designs + .iter() + .any(|design| design.name == name && (matches!(design.art.kind, NodeKind::Compound { .. }) || design.art.is_compound_shape())) + }) + }) + }; + targets.retain(|id| seen.insert(*id) && !locks.holds_id(*id) && (series_compound(*id) || !cached_is_design_art(before, *id, &series_groups))); let count = keeping_series_paint(d, &roots, |d| { let mut count = 0; for id in &targets { diff --git a/crates/engine/src/cmd/addons/color/random_fill/tests.rs b/crates/engine/src/cmd/addons/color/random_fill/tests.rs index 3253ce98ee..1c66e7cde4 100644 --- a/crates/engine/src/cmd/addons/color/random_fill/tests.rs +++ b/crates/engine/src/cmd/addons/color/random_fill/tests.rs @@ -212,6 +212,421 @@ fn a_compound_clipping_path_keeps_its_fill() { assert_eq!(fill(&s, compound), mask_fill); } +#[test] +fn a_live_compound_shape_takes_one_color_and_keeps_its_members_fills() { + for target in ["shape", "group", "member"] { + let mut s = session(); + let [a, b] = [0.0, 2.0].map(|x| rect(&mut s, x)); + select(&mut s, &[a, b]); + let shape = NodeId(s.execute("object.compoundShape.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + assert!(s.doc().unwrap().doc.node(shape).unwrap().is_compound_shape()); + let id = match target { + "group" => NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()), + "member" => a, + _ => shape, + }; + let before = fill(&s, shape); + let members = fills(&s, &[a, b]); + let n = steps(&s); + assert_eq!(s.execute(C, &json!({"ids": [id.0], "scheme": "gray", "min": 30, "max": 30})).unwrap()["count"], json!(1), "{target}"); + assert_eq!(fill(&s, shape), Paint::solid(Color::gray(0.3)), "{target}"); + assert_eq!(fills(&s, &[a, b]), members, "{target}"); + assert_eq!(steps(&s), n + 1); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(fill(&s, shape), before); + assert_eq!(fills(&s, &[a, b]), members); + } +} + +#[test] +fn a_selected_graph_keeps_the_fills_of_generated_design_art() { + let mut s = session(); + let a = rect(&mut s, 0.0); + s.execute("paint.setFill", &json!({"ids": [a.0], "color": "#336699"})).unwrap(); + select(&mut s, &[a]); + s.execute("graph.design", &json!({"new": "Tile"})).unwrap(); + let graph = NodeId( + s.execute("graph.create", &json!({"type": "column", "x": 100, "y": 100, "width": 200, "height": 150, "series": ["A"], "rows": [[20], [30]]})) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute("graph.column", &json!({"id": graph.0, "design": "Tile"})).unwrap(); + let mut design_paths = vec![]; + let d = &s.doc().unwrap().doc; + d.node(graph).unwrap().walk(&mut |n| { + if matches!(n.kind, NodeKind::Path { .. }) && super::is_design_art(d, n.id) && !n.appearance.fill_paint().is_none() { + design_paths.push(n.id); + } + }); + assert!(!design_paths.is_empty()); + let before = fills(&s, &design_paths); + select(&mut s, &[graph]); + s.execute(C, &json!({"scheme": "gray", "min": 30, "max": 30})).unwrap(); + assert_eq!(fills(&s, &design_paths), before); +} + +#[test] +fn a_compound_path_in_a_graph_series_takes_a_color() { + let mut s = session(); + let graph = NodeId( + s.execute("graph.create", &json!({"type": "column", "x": 100, "y": 100, "width": 200, "height": 150, "series": ["A"], "rows": [[20], [30]]})) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + let d = &s.doc().unwrap().doc; + let series = d.node(graph).unwrap().children().into_iter().flatten().find(|n| n.extras().series_index.is_some()).unwrap(); + let group = series.id; + let marks: Vec = series.children().into_iter().flatten().filter(|m| matches!(m.kind, NodeKind::Path { .. })).map(|m| m.id).collect(); + assert!(marks.len() >= 2); + let marks = &marks[..2]; + select(&mut s, marks); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(compound), Some(group), "the compound path is directly in the series group"); + for ids in [vec![compound], vec![marks[0]], vec![group]] { + let before = fill(&s, compound); + let r = s.execute(C, &json!({"scheme": "gray", "min": 40, "max": 40, "ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); + assert!(r["count"].as_u64().unwrap() >= 1, "{ids:?}"); + assert_ne!(fill(&s, compound), before, "{ids:?}"); + s.execute("edit.undo", &json!({})).unwrap(); + } +} + +#[test] +fn a_compound_in_a_graph_series_takes_a_color_after_its_design_is_deleted() { + for kind in ["column", "line", "scatter"] { + let mut s = session(); + let a = rect(&mut s, 0.0); + select(&mut s, &[a]); + s.execute("graph.design", &json!({"new": "Tile"})).unwrap(); + let graph = NodeId( + s.execute( + "graph.create", + &json!({"type": kind, "x": 100, "y": 100, "width": 200, "height": 150, "series": ["X", "A"], "rows": [[10, 20], [20, 30]]}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute(if kind == "column" { "graph.column" } else { "graph.marker" }, &json!({"id": graph.0, "design": "Tile"})).unwrap(); + s.execute("graph.design", &json!({"delete": "Tile"})).unwrap(); + let d = &s.doc().unwrap().doc; + assert!(d.graph_designs.is_empty()); + let series = d.node(graph).unwrap().children().into_iter().flatten().find(|n| n.extras().series_index.is_some()).unwrap(); + let group = series.id; + let index = series.extras().series_index.unwrap() as usize; + let spec = d.node(graph).unwrap().extras().graph.as_deref().unwrap(); + if kind == "column" { + assert_eq!(spec.series_columns[index].as_ref().unwrap().design, "Tile"); + } else { + assert_eq!(spec.series_markers[index].as_deref(), Some("Tile")); + } + let marks: Vec = series + .children() + .into_iter() + .flatten() + .filter(|m| matches!(m.kind, NodeKind::Path { .. }) && !m.appearance.fill_paint().is_none()) + .map(|m| m.id) + .collect(); + assert!(marks.len() >= 2, "{kind}"); + let marks = &marks[..2]; + select(&mut s, marks); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(compound), Some(group), "{kind}"); + let before = fill(&s, compound); + let members = fills(&s, marks); + select(&mut s, &[graph]); + let result = s.execute(C, &json!({"scheme": "gray", "min": 40, "max": 40})).unwrap(); + assert!(result["count"].as_u64().unwrap() >= 1, "{kind}"); + assert_ne!(fill(&s, compound), before, "{kind}"); + assert_eq!(fills(&s, marks), members, "{kind}"); + } +} + +#[test] +fn a_user_compound_in_a_series_with_a_plain_path_design_takes_a_color() { + for kind in ["column", "line", "scatter"] { + let mut s = session(); + let a = rect(&mut s, 0.0); + select(&mut s, &[a]); + s.execute("graph.design", &json!({"new": "Tile"})).unwrap(); + assert!(matches!(s.doc().unwrap().doc.graph_designs[0].art.kind, NodeKind::Path { .. })); + let graph = NodeId( + s.execute( + "graph.create", + &json!({"type": kind, "x": 100, "y": 100, "width": 200, "height": 150, "series": ["X", "A"], "rows": [[10, 20], [20, 30]]}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute(if kind == "column" { "graph.column" } else { "graph.marker" }, &json!({"id": graph.0, "design": "Tile"})).unwrap(); + let designed = s.doc().unwrap().doc.node(graph).unwrap().extras().graph.clone(); + s.execute("edit.undo", &json!({})).unwrap(); + s.edit("Set series design without replacing ordinary marks", |d, _| { + d.node_mut(graph).unwrap().extras_mut().graph = designed; + Ok(()) + }) + .unwrap(); + let d = &s.doc().unwrap().doc; + let series = d.node(graph).unwrap().children().into_iter().flatten().find(|n| n.extras().series_index.is_some()).unwrap(); + let group = series.id; + let marks: Vec = series + .children() + .into_iter() + .flatten() + .filter(|m| matches!(m.kind, NodeKind::Path { .. }) && !m.appearance.fill_paint().is_none()) + .map(|m| m.id) + .collect(); + assert!(marks.len() >= 2, "{kind}"); + let marks = &marks[..2]; + select(&mut s, marks); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(compound), Some(group), "{kind}"); + assert!(!s.doc().unwrap().doc.node(compound).unwrap().extras().graph_design_art, "{kind}"); + let members = fills(&s, marks); + for ids in [vec![compound], vec![marks[0]], vec![group], vec![graph]] { + let before = fill(&s, compound); + let result = s.execute(C, &json!({"scheme": "gray", "min": 40, "max": 40, "ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); + assert!(result["count"].as_u64().unwrap() >= 1, "{kind}: {ids:?}"); + assert_eq!(fill(&s, compound), Paint::solid(Color::gray(0.4)), "{kind}: {ids:?}"); + assert_ne!(fill(&s, compound), before, "{kind}: {ids:?}"); + assert_eq!(fills(&s, marks), members, "{kind}: {ids:?}"); + s.execute("edit.undo", &json!({})).unwrap(); + } + } +} + +#[test] +fn grouped_paths_in_a_graph_series_keep_their_fills_as_for_paint_set_fill() { + for kind in ["column", "line", "scatter"] { + let mut s = session(); + let graph = NodeId( + s.execute( + "graph.create", + &json!({"type": kind, "x": 100, "y": 100, "width": 200, "height": 150, "series": ["X", "A"], "rows": [[10, 20], [20, 30]]}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + let d = &s.doc().unwrap().doc; + let series = d.node(graph).unwrap().children().into_iter().flatten().find(|n| n.extras().series_index.is_some()).unwrap(); + let group = series.id; + let marks: Vec = series + .children() + .into_iter() + .flatten() + .filter(|m| matches!(m.kind, NodeKind::Path { .. }) && !m.appearance.fill_paint().is_none()) + .map(|m| m.id) + .collect(); + assert!(marks.len() >= 2, "{kind}"); + let marks = &marks[..2]; + select(&mut s, marks); + let nested = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + assert_eq!(s.doc().unwrap().doc.parent_of(nested), Some(group), "{kind}"); + let before = fills(&s, marks); + select(&mut s, &[graph]); + // `paint.setFill` on the graph leaves a group inside a series alone, as design art; so does this command. + s.execute("paint.setFill", &json!({"color": "#aa0000"})).unwrap(); + let after_set_fill = fills(&s, marks); + s.execute("edit.undo", &json!({})).unwrap(); + s.execute(C, &json!({"scheme": "gray", "min": 40, "max": 40})).unwrap(); + assert_eq!(fills(&s, marks), before, "{kind}"); + assert_eq!(after_set_fill, before, "{kind}: paint.setFill keeps grouped marks too"); + } +} + +#[test] +fn generated_compound_design_copies_in_a_graph_series_keep_their_fills() { + for (kind, legacy) in ["column", "line", "scatter"].into_iter().flat_map(|kind| [false, true].map(|legacy| (kind, legacy))) { + let mut s = session(); + let marks = rects(&mut s, 2); + select(&mut s, &marks); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("paint.setFill", &json!({"ids": [compound.0], "color": "#336699"})).unwrap(); + select(&mut s, &[compound]); + s.execute("graph.design", &json!({"new": "Tile"})).unwrap(); + let graph = NodeId( + s.execute( + "graph.create", + &json!({"type": kind, "x": 100, "y": 100, "width": 200, "height": 150, "series": ["X", "A"], "rows": [[10, 20], [20, 30]]}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute(if kind == "column" { "graph.column" } else { "graph.marker" }, &json!({"id": graph.0, "design": "Tile"})).unwrap(); + let d = &s.doc().unwrap().doc; + let series = d.node(graph).unwrap().children().into_iter().flatten().find(|n| n.extras().series_index.is_some()).unwrap(); + let group = series.id; + let copies: Vec = + series.children().into_iter().flatten().filter(|m| matches!(m.kind, NodeKind::Compound { .. })).map(|m| m.id).collect(); + assert!(!copies.is_empty(), "{kind}: the generated compound is directly in the series group"); + for id in &copies { + assert!(d.node(*id).unwrap().extras().graph_design_art, "{kind}"); + assert!(super::is_design_art(d, *id), "{kind}"); + } + let mut art = vec![]; + series.walk(&mut |n| { + if super::is_design_art(d, n.id) { + art.push(n.id); + } + }); + if legacy { + s.edit("Clear graph design flags", |d, _| { + for id in &art { + d.node_mut(*id).unwrap().extras_mut().graph_design_art = false; + } + Ok(()) + }) + .unwrap(); + } + let before = fills(&s, &art); + for ids in [vec![graph], vec![group], copies] { + s.execute(C, &json!({"scheme": "gray", "min": 40, "max": 40, "ids": ids.iter().map(|i| i.0).collect::>()})).unwrap(); + assert_eq!(fills(&s, &art), before, "{kind}, legacy: {legacy}: {ids:?}"); + } + } +} + +#[test] +fn hidden_or_locked_compound_members_given_by_id_keep_the_compounds_fill() { + for hide in [true, false] { + let mut s = session(); + let [a, b] = [0.0, 2.0].map(|x| rect(&mut s, x)); + select(&mut s, &[a, b]); + let compound = NodeId(s.execute("object.compoundPath.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("object.setProps", &if hide { json!({"id": a.0, "visible": false}) } else { json!({"id": a.0, "locked": true}) }).unwrap(); + let member = s.doc().unwrap().doc.node(a).unwrap(); + assert!(if hide { !member.visible } else { member.locked }); + let parent = s.doc().unwrap().doc.node(compound).unwrap(); + assert!(parent.visible && !parent.locked); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + assert_eq!(s.execute(C, &json!({"ids": [a.0], "scheme": "gray", "min": 30, "max": 30})).unwrap()["count"], json!(0), "hidden: {hide}"); + assert_eq!(fill(&s, compound), before.node(compound).unwrap().appearance.fill_paint()); + assert!(*s.doc().unwrap().doc == *before); + assert_eq!(steps(&s), n); + } +} + +#[test] +fn seeded_colors_follow_ids_order_without_repeating_objects() { + let mut s = session(); + let ids = rects(&mut s, 3); + s.execute(C, &json!({"ids": ids.iter().map(|id| id.0).collect::>(), "seed": 7})).unwrap(); + let first = fills(&s, &ids); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(s.execute(C, &json!({"ids": [ids[2].0, ids[0].0, ids[2].0, ids[1].0], "seed": 7})).unwrap()["count"], json!(3)); + assert_eq!(fills(&s, &[ids[2], ids[0], ids[1]]), first); +} + +#[test] +fn nested_members_color_the_outermost_compound_unless_an_ancestor_is_blocked() { + for blocked in ["none", "hidden", "locked", "artboard"] { + let mut s = session(); + let [a, b, c] = [0.0, 2.0, 4.0].map(|x| rect(&mut s, x)); + select(&mut s, &[a]); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[group, b]); + let inner = NodeId(s.execute("object.compoundShape.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + select(&mut s, &[inner, c]); + let outer = NodeId(s.execute("object.compoundShape.make", &json!({})).unwrap()["id"].as_u64().unwrap()); + match blocked { + "hidden" => { + s.execute("object.setProps", &json!({"id": group.0, "visible": false})).unwrap(); + } + "locked" => { + s.execute("object.setProps", &json!({"id": inner.0, "locked": true})).unwrap(); + } + "artboard" => { + s.execute("artboard.setProps", &json!({"index": 0, "locked": true})).unwrap(); + } + _ => {} + } + let before = s.doc().unwrap().doc.clone(); + let members = fills(&s, &[a, b, c, group, inner]); + let n = steps(&s); + let r = s.execute(C, &json!({"ids": [a.0], "scheme": "gray", "min": 30, "max": 30})).unwrap(); + assert_eq!(fills(&s, &[a, b, c, group, inner]), members, "{blocked}"); + if blocked == "none" { + assert_eq!(r["count"], json!(1)); + assert_eq!(fill(&s, outer), Paint::solid(Color::gray(0.3))); + assert_eq!(steps(&s), n + 1); + s.execute("edit.undo", &json!({})).unwrap(); + } else { + assert_eq!(r["count"], json!(0), "{blocked}"); + assert_eq!(steps(&s), n, "{blocked}"); + } + assert!(*s.doc().unwrap().doc == *before, "{blocked}"); + } +} + +#[test] +fn an_invalid_series_index_keeps_ordinary_subgroups_reachable() { + let mut s = session(); + let graph = NodeId( + s.execute("graph.create", &json!({"type": "column", "x": 100, "y": 100, "width": 200, "height": 150, "series": ["A"], "rows": [[20], [30]]})) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + let series = s.doc().unwrap().doc.node(graph).unwrap().children().unwrap().iter().find(|n| n.extras().series_index == Some(0)).unwrap(); + let group = series.id; + let marks: Vec = series.children().unwrap().iter().filter(|n| matches!(n.kind, NodeKind::Path { .. })).map(|n| n.id).collect(); + assert!(!marks.is_empty()); + select(&mut s, &marks); + s.execute("object.group", &json!({})).unwrap(); + s.edit("Set series index", |d, _| { + d.node_mut(group).unwrap().extras_mut().series_index = Some(u32::MAX); + Ok(()) + }) + .unwrap(); + let before = fills(&s, &marks); + let r = s.execute(C, &json!({"ids": [group.0], "scheme": "gray", "min": 30, "max": 30})).unwrap(); + assert_eq!(r["count"], json!(marks.len())); + assert!(fills(&s, &marks).iter().all(|p| *p == Paint::solid(Color::gray(0.3)))); + assert_ne!(fills(&s, &marks), before); + assert!(s.doc().unwrap().doc.node(graph).unwrap().extras().graph.as_ref().unwrap().series_paints.is_empty()); +} + +#[test] +fn a_tint_swatch_with_a_deleted_base_is_refused_without_a_change() { + let mut s = session(); + let ids = rects(&mut s, 2); + select(&mut s, &ids); + s.execute("swatch.new", &json!({"name": "Ink", "color": "#e01020", "spot": true})).unwrap(); + let tint = s.execute("swatch.new", &json!({"name": "Pale", "swatch": "Ink", "tint": 40})).unwrap()["name"].as_str().unwrap().to_string(); + s.execute("swatch.delete", &json!({"name": "Ink", "unlink": false})).unwrap(); + let d = &s.doc().unwrap().doc; + assert!(d.swatch("Ink").is_none()); + assert_eq!(d.swatch_link(&tint), Some(("Ink".to_string(), 0.4))); + let before = d.clone(); + let n = steps(&s); + let e = s.execute(C, &json!({"scheme": "tint", "swatch": tint, "min": 10, "max": 80})).unwrap_err().to_string(); + assert!(e.contains("base swatch `Ink`"), "{e}"); + assert!(*s.doc().unwrap().doc == *before); + assert_eq!(steps(&s), n); +} + +#[test] +fn an_inverted_range_that_rounds_to_equal_f32_bounds_is_refused() { + let mut s = session(); + let a = rect(&mut s, 0.0); + select(&mut s, &[a]); + s.execute("swatch.new", &json!({"name": "Ink", "color": "#e01020", "spot": true})).unwrap(); + let before = s.doc().unwrap().doc.clone(); + let n = steps(&s); + for p in [json!({"scheme": "gray", "min": 50.0000001, "max": 50}), json!({"scheme": "tint", "swatch": "Ink", "min": 50.0000001, "max": 50})] { + let e = s.execute(C, &p).unwrap_err().to_string(); + assert!(e.contains("`min` is greater than `max`"), "{p}: {e}"); + assert!(*s.doc().unwrap().doc == *before); + assert_eq!(steps(&s), n); + } +} + #[test] fn no_undo_step_when_no_fill_changes() { let mut s = session(); diff --git a/crates/engine/src/cmd/graph.rs b/crates/engine/src/cmd/graph.rs index 06fb062e50..f348a97f3c 100644 --- a/crates/engine/src/cmd/graph.rs +++ b/crates/engine/src/cmd/graph.rs @@ -54,8 +54,8 @@ pub(crate) use series::{ capture_label_paragraphs, capture_label_rows, capture_label_styles, capture_label_styles_given, capture_label_text, capture_line_changes, capture_line_fill_stroke_rows, capture_line_kind_rows, capture_line_paint_writes, capture_line_row_writes, capture_line_rows, capture_series_object_opacity, capture_series_opacity, capture_series_top_paints, follow_wedge_shades, graph_part_members, is_design_art, - is_graph_line, label_object_opacity_differs, label_rows, labels_in, paint_targets, plain_labels, series_group_marks, series_group_marks_where, - series_groups_among, series_marks_in, series_object_opacity_differs, shown_paint, wedge_shades, + is_graph_line, is_series_group, label_object_opacity_differs, label_rows, labels_in, paint_targets, plain_labels, series_group_marks, + series_group_marks_where, series_groups_among, series_marks_in, series_object_opacity_differs, shown_paint, wedge_shades, }; #[cfg(test)] diff --git a/crates/engine/src/cmd/graph/columns.rs b/crates/engine/src/cmd/graph/columns.rs index 6c87143618..ad7f145af0 100644 --- a/crates/engine/src/cmd/graph/columns.rs +++ b/crates/engine/src/cmd/graph/columns.rs @@ -328,7 +328,9 @@ pub(super) fn column_art( } parts.push(Arc::new(d.reid(&crate::cmd::place::transformed(n, by)))); } - Some(Arc::new(Node::group(d.alloc_id(), parts))) + let mut n = Node::group(d.alloc_id(), parts); + n.extras_mut().graph_design_art = true; + Some(Arc::new(n)) }; let mut parts = vec![]; let (mut label, mut sliding) = (fit_affine(frame, rect), None); diff --git a/crates/engine/src/cmd/graph/labels.rs b/crates/engine/src/cmd/graph/labels.rs index b5d5632356..b5faf1ccf8 100644 --- a/crates/engine/src/cmd/graph/labels.rs +++ b/crates/engine/src/cmd/graph/labels.rs @@ -271,7 +271,9 @@ impl Gen<'_> { /// A copy of design art drawn in a series: a single path gets a group of its own, as painting a series paints the /// paths directly inside its group and the design keeps its own paint. fn design_copy(&mut self, n: Arc) -> Arc { - if matches!(n.kind, NodeKind::Path { .. }) { Arc::new(Node::group(self.d.alloc_id(), vec![n])) } else { n } + let mut n = if matches!(n.kind, NodeKind::Path { .. }) { Arc::new(Node::group(self.d.alloc_id(), vec![n])) } else { n }; + Arc::make_mut(&mut n).extras_mut().graph_design_art = true; + n } /// A series group. Empty series are omitted by the caller; the index is stored on the group /// so later paint edits find the series without counting siblings. diff --git a/crates/engine/src/cmd/graph/series.rs b/crates/engine/src/cmd/graph/series.rs index 3ea811392d..7371961c20 100644 --- a/crates/engine/src/cmd/graph/series.rs +++ b/crates/engine/src/cmd/graph/series.rs @@ -204,7 +204,7 @@ pub(crate) fn series_group_marks_where(doc: &Document, ids: &[NodeId], stands: i /// Whether `n` is a graph series group: a child of a graph with one of the graph's series indexes ([`series_members`]). /// It is looked up through its parent, with no pass over the document: the panels call this while they draw. -fn is_series_group(doc: &Document, n: &Node) -> bool { +pub(crate) fn is_series_group(doc: &Document, n: &Node) -> bool { let Some(index) = n.extras().series_index.and_then(|i| usize::try_from(i).ok()) else { return false }; let graph = doc.parent_of(n.id).and_then(|parent| doc.node(parent)).and_then(|parent| parent.extras().graph.as_deref()); graph.is_some_and(|spec| index < series_count(spec)) diff --git a/docs/mcp.md b/docs/mcp.md index 3b341caa6e..b51ea5d626 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17265,7 +17265,7 @@ on the object or on one of its fills or strokes; a group carrying one is selecte `count` selected. `addon.color.randomFill {scheme?, swatch?, min?, max?, seed?, ids?}` (Object › Plug-ins › Color Effects › Randomize -Fill Colors…) gives each selected filled path and compound path, and each one inside the selected groups and clipping +Fill Colors…) gives each selected filled path, compound path and live compound shape, and each one inside the selected groups and clipping groups, a top fill color of its own, picked at random and evenly, as one undo step (none when no fill changes): | `scheme` | Each fill becomes | @@ -17275,13 +17275,15 @@ groups, a top fill color of its own, picked at random and evenly, as one undo st | `gray` | A gray from `min` to `max` percent black | `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 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 +only and is needed there (a tint swatch gives tints of its base, which must still support tints). The same `seed` (a whole number, 0 when left out), +objects and settings give the same colors. Compound paths and live compound shapes take one color and keep their members' fills. +An id naming a nested member targets the outermost compound. +Paths, compound paths and live compound shapes 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 or on a locked artboard (also when `ids` names them; new art made there while it is still selected takes a color), generated graph design art, paths a user groups inside a graph series, 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 -percent outside 0 to 100, `min` above `max`, a missing or process swatch and a seed that is not a whole number are +percent outside 0 to 100, `min` above `max`, a missing or process swatch, a tint swatch whose base cannot produce tints and a seed that is not a whole number are errors, and the document is left as it was. The dialog's seed starts new whenever the document has changed, and its Swatch choice lists the document's global and spot swatches. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e33bb042f..671fd127b6 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3129,7 +3129,7 @@ add-on. ## Color Effects add-on: Randomize Fill Colors (2026-11-29) -A VectorCraft addition, so no area score moves. Object › Plug-ins › Color Effects › Randomize Fill Colors… gives each selected filled path and compound path, and each one inside the selected groups and clipping groups, its own top fill color, picked at random and evenly: any color in the document's color mode, a linked tint of a global or spot swatch, or a gray, the tints and grays between a minimum and a maximum percent. A seed repeats a result exactly, and the dialog starts with a new one whenever the document has changed. Paths without a fill, clipping paths, hidden and locked objects, type, images, symbol instances, blends and envelopes keep their fills. One undo step, none when no fill changes; bad params are refused without a change. Tests: `cmd::addons::color::random_fill::tests` in `vectorcraft-engine` (each scheme and its range, the seed, groups, compound paths and clipping groups entered, unfilled, hidden and locked objects left alone, CMYK documents, one undo step or none, bad params refused), `addons::color::random_fill::tests` and the add-on dialog family test in `vectorcraft-ui-egui` (typed values preview, OK and Cancel, the Swatch choice), and `command_sweep`. Commands: `docs/mcp.md` › Color Effects add-on. +A VectorCraft addition, so no area score moves. Object › Plug-ins › Color Effects › Randomize Fill Colors… gives each selected filled path, compound path and live compound shape, and each one inside the selected groups and clipping groups, its own top fill color, picked at random and evenly: any color in the document's color mode, a linked tint of a global or spot swatch, or a gray, the tints and grays between a minimum and a maximum percent. Compound paths and live compound shapes take one color and keep their members' fills. An id naming a nested member targets the outermost compound. A seed repeats a result exactly, and the dialog starts with a new one whenever the document has changed. Objects without a fill, clipping paths, hidden and locked objects, objects inside hidden or locked groups and layers or on a locked artboard, generated graph design art, type, images, symbol instances, blends and envelopes keep their fills. New art made on a locked artboard takes a color while it is still selected. The command records one undo step when a fill changes and rejects bad params without a change. Tests: `cmd::addons::color::random_fill::tests` in `vectorcraft-engine` (each scheme and its range, the seed, groups, compound paths, live compound shapes and clipping groups entered, unfilled, hidden and locked objects left alone, CMYK documents, one undo step or none, bad params refused), `addons::color::random_fill::tests` and the add-on dialog family test in `vectorcraft-ui-egui` (typed values preview, OK and Cancel, the Swatch choice), and `command_sweep`. Commands: `docs/mcp.md` › Color Effects add-on. ## Arrange Tools add-on (2026-10-31)