Document Tools: Flood Fill Artboards takes keepModel

- `keepModel: true` keeps an explicit RGB color in RGB in a CMYK
  document, as paint.setFill does; it is declared in the params text,
  docs/mcp.md and ROADMAP.
- A `keepModel` of null or another non-boolean is an error, and nothing
  is edited.
This commit is contained in:
dotCooCoo committed 2026-11-29 17:26:32 -08:00
1 parent d2c2f66940
commit 9d3d9bde76
5 files changed
+28 -10

No files matched your search

+1 -1
View File
@@ -166,7 +166,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
- 2026-11-15: Tangent Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the circles that touch two selected paths or compound paths at a set radius, or three of them (up to eight for three circles), touching each outline without crossing it; circles, rotated ellipses and other paths alike. A dialog that previews every circle or one picked by number, the current paint, one undo step (`addon.pathtools.tangentCircle`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-17: Add Bounding Rectangle and Add Bounding Circle join the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): a live rectangle on the selection's geometric bounding box, or the smallest live circle that holds its outlines, around the whole selection or around each object, with the current paint and one undo step; the menu items open a dialog with Offset, One per Object and Preview (`addon.pathtools.boundingRectangle`, `addon.pathtools.boundingCircle`, #6966). A VectorCraft addition: headline numbers unchanged.
- 2026-11-22: Add Inscribed Circle joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the largest live circle inside each selected closed path or compound path, in the area it fills under its fill rule, with the current paint and one undo step (`addon.pathtools.inscribedCircle`, #6966). A VectorCraft addition: headline numbers unchanged.
- 2026-11-29: Flood Fill Artboards joins the Document Tools add-on (Object › Plug-ins › Document Tools): an editable rectangle exactly the size of the active artboard, or of every artboard, in the current fill or a chosen color with no stroke, on a layer named Flood Fill (or another name typed), which is made at the bottom of the layers when the document has none and otherwise keeps its lock and visibility (a layer that holds a clipping mask is refused). A dialog with Preview, one undo step (`addon.document.floodFillArtboards`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-29: Flood Fill Artboards joins the Document Tools add-on (Object › Plug-ins › Document Tools): an editable rectangle exactly the size of the active artboard, or of every artboard, in the current fill or a chosen color with no stroke (a chosen RGB color goes into the document's color model, or stays RGB with `keepModel`), on a layer named Flood Fill (or another name typed), which is made at the bottom of the layers when the document has none and otherwise keeps its lock and visibility (a layer that holds a clipping mask is refused). A dialog with Preview, one undo step (`addon.document.floodFillArtboards`). A VectorCraft addition: headline numbers unchanged.
- 2026-11-01: New Symbols from Layers joins the Document Tools add-on (Object › Plug-ins › Document Tools): one symbol of each top-level layer's art (the layers highlighted in the Layers panel when two or more are, else every layer), named after the layer, made as New Symbol makes one; Convert Layers to Symbols also puts an instance of each in place of its layer's art. Empty layers are skipped and reported; one undo step. A VectorCraft addition: headline numbers unchanged.
- 2026-11-01: Document Tools, a built-in add-on (Object › Plug-ins › Document Tools), starts with Save a Timestamped Copy: a copy of the document named `<name>_YYYY-MM-DD_HH-MM` (UTC; `-2`, `-3`… when that name is taken) goes next to it, or into a folder picked for a document never saved, written as File › Save a Copy writes it, so the document keeps its path, title and modified state. Off on the web, which has no clock. A VectorCraft addition: headline numbers unchanged.
- 2026-11-01: Divide into Dashes joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): the selected paths, or only their direct-selected segments, are cut into separate open paths of a dash length measured along the curve, with an optional gap (left empty, or kept as pieces), each keeping the path's appearance; Fit to Corners and Ends stretches or squeezes the lengths so every run starts and ends on a dash. A dialog with Preview, one undo step, at most 100000 pieces. A VectorCraft addition: headline numbers unchanged.
+1 -1
View File
@@ -67,7 +67,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Flood Fill Artboards",
["Object", "Plug-ins", "Document Tools"],
None,
"{artboards?: [index…] (default: the active artboard), all?: bool (true: every artboard; not with artboards), color?: color (\"#rrggbb\", {c,m,y,k}, … as the paint commands take, #rrggbbaa and #rgba refused, as is a component too large to be finite; explicit RGB colors convert to the document's color model as paint.setFill does; default: the current fill, using the live fill after earlier batch steps or the fill the preview began with in a Flood Fill preview, an error when that is None), layer?: name (default: \"Flood Fill\"; trimmed, nonempty, at most 255 characters after trimming)} add an editable rectangle exactly the size of each artboard, painted with the color and no stroke, on top of the top-level layer of that name, made at the bottom of the layers when there is none. A destination layer that holds a clipping mask is rejected before any edit. A layer that already exists keeps its lock and visibility; the rectangles are selected unless that layer is locked, hidden or a template, in which case the prior selection stays. The current layer stays as it was. One undo step. Params must be an object or null (omitted options). Every option given is checked: null and values of the wrong type are errors. Refused in isolation mode or while a symbol, pattern or opacity mask is edited → {ids: [rectangle id…], layer: layer id, created: bool (a new layer was made)}",
"{artboards?: [index…] (default: the active artboard), all?: bool (true: every artboard; not with artboards), color?: color (\"#rrggbb\", {c,m,y,k}, … as the paint commands take, #rrggbbaa and #rgba refused, as is a component too large to be finite; explicit RGB colors convert to the document's color model as paint.setFill does; default: the current fill, using the live fill after earlier batch steps or the fill the preview began with in a Flood Fill preview, an error when that is None), keepModel?: bool (as paint.setFill: true keeps an explicit RGB color in RGB), layer?: name (default: \"Flood Fill\"; trimmed, nonempty, at most 255 characters after trimming)} add an editable rectangle exactly the size of each artboard, painted with the color and no stroke, on top of the top-level layer of that name, made at the bottom of the layers when there is none. A destination layer that holds a clipping mask is rejected before any edit. A layer that already exists keeps its lock and visibility; the rectangles are selected unless that layer is locked, hidden or a template, in which case the prior selection stays. The current layer stays as it was. One undo step. Params must be an object or null (omitted options). Every option given is checked: null and values of the wrong type are errors. Refused in isolation mode or while a symbol, pattern or opacity mask is edited → {ids: [rectangle id…], layer: layer id, created: bool (a new layer was made)}",
flood_fill_enabled,
flood_fill::flood_fill_artboards
),
@@ -20,7 +20,7 @@ const LAYER: &str = "Flood Fill";
/// The longest layer name taken, in characters.
const MAX_NAME: usize = 255;
/// `{artboards?, all?, color?, layer?}`: see the command's params text in [`super::specs`].
/// `{artboards?, all?, color?, keepModel?, layer?}`: see the command's params text in [`super::specs`].
pub(super) fn flood_fill_artboards(s: &mut Session, p: &Value) -> Result<Value> {
let st = s.doc()?;
let d = &st.doc;
@@ -36,6 +36,10 @@ pub(super) fn flood_fill_artboards(s: &mut Session, p: &Value) -> Result<Value>
if d.artboards.is_empty() {
return Err(bad(COMMAND, "the document has no artboards"));
}
if p.get("keepModel").is_some_and(Value::is_null) {
return Err(bad(COMMAND, "`keepModel` must be true or false"));
}
super::super::super::paint::check_keep_model(p, COMMAND)?;
let all = match p.get("all") {
None => false,
Some(v) => v.as_bool().ok_or_else(|| bad(COMMAND, "`all` must be true or false"))?,
+19 -5
View File
@@ -313,6 +313,22 @@ fn flood_fill_converts_explicit_rgb_to_cmyk_like_set_fill() {
}
}
#[test]
fn flood_fill_keep_model_keeps_explicit_rgb_in_a_cmyk_document() {
let mut s = Session::new();
s.execute("file.new", &json!({"colorMode": "cmyk"})).unwrap();
let r = s.execute(FLOOD, &json!({"color": "#ff0000", "keepModel": true})).unwrap();
let id = NodeId(r["ids"][0].as_u64().unwrap());
let fill = s.doc().unwrap().doc.node(id).unwrap().appearance.fill_paint();
assert!(matches!(fill.color(), Some(vectorcraft_color::Color::Rgb { .. })), "{fill:?}");
let undo = s.doc().unwrap().history.undo.len();
for bad in [json!("yes"), json!(null)] {
let error = s.execute(FLOOD, &json!({"color": "#ff0000", "keepModel": bad})).unwrap_err().to_string();
assert!(error.contains("keepModel"), "{error}");
assert_eq!(s.doc().unwrap().history.undo.len(), undo);
}
}
#[test]
fn flood_fill_refuses_isolation_without_an_edit_and_is_disabled() {
let mut s = boards();
@@ -561,11 +577,9 @@ fn paint_preview_replacement_from_an_empty_selection_uses_the_starting_defaults(
#[test]
fn paint_previews_from_an_empty_selection_restore_defaults_on_cancel() {
for (command, params) in [
("paint.swap", json!({})),
("paint.setFill", json!({"color": "#0000ff"})),
("paint.setStroke", json!({"color": "#0000ff"})),
] {
for (command, params) in
[("paint.swap", json!({})), ("paint.setFill", json!({"color": "#0000ff"})), ("paint.setStroke", json!({"color": "#0000ff"}))]
{
let mut s = boards();
s.prefs.new_art_basic = false;
s.execute("select.none", &json!({})).unwrap();
+2 -2
View File
@@ -17511,10 +17511,10 @@ there is no step. → `{symbols: [name…], ids: [instance id…], skipped: [{la
{"name":"run_command","arguments":{"command":"addon.document.symbolsFromLayers","params":{"replace":true}}}
```
`addon.document.floodFillArtboards {artboards?, all?, color?, layer?}` adds an editable rectangle exactly the size of
`addon.document.floodFillArtboards {artboards?, all?, color?, keepModel?, layer?}` adds an editable rectangle exactly the size of
each artboard, painted with `color` and no stroke, as one undo step. `artboards` lists artboard indices (the active
artboard by default), and `all: true` takes every artboard instead; the two can't be given together. `color` takes the
colors the paint commands take (`#rrggbbaa` and `#rgba` are refused, as is a component too large to be finite). Explicit RGB colors convert to the document's color model as `paint.setFill` does. Without `color`, the rectangles take the current fill
colors the paint commands take (`#rrggbbaa` and `#rgba` are refused, as is a component too large to be finite). Explicit RGB colors convert to the document's color model as `paint.setFill` does, and `keepModel: true` keeps them in RGB. Without `color`, the rectangles take the current fill
(in a Flood Fill preview, the fill the preview began with; in a batch step, the live fill after preceding steps), and a current fill of None is an error. The rectangles go on top of the top-level layer named `layer` (`Flood Fill` by
default, trimmed and nonempty, at most 255 characters after trimming), which is made at the bottom of the layers when the document has none. A destination layer that holds a clipping mask is rejected before any edit. A layer that
already exists keeps its lock and visibility. The rectangles are selected unless that layer is locked, hidden or a template,