diff --git a/crates/engine/src/cmd/recolor.rs b/crates/engine/src/cmd/recolor.rs index 381912c3ac..73d53945eb 100644 --- a/crates/engine/src/cmd/recolor.rs +++ b/crates/engine/src/cmd/recolor.rs @@ -43,7 +43,7 @@ pub fn specs() -> Vec { "Recolor Artwork", ["Edit", "Edit Colors"], None, - "{map: rows [{from: [colour keys (recolor.colors) or \"#rrggbb\" (every colour shown as that hex); may be empty: an empty row recolours nothing, adds no library swatch and gives `group` no colour unless `added`], to: colour (hex, key, {c,m,y,k} or {l,a,b}) | null (in from, to and groupColors, #rrggbbaa and #rgba are refused), exclude?: false (the row's colours are kept), tint?: 100 (percent; with limitTo or swatch, art linked to the global or spot swatch the new color is takes this share of its tint), added?: false (an empty row's new color is a color added to `group`), swatch?: {name, library?: swatch library id or name; \"document\" (default)} (the swatch the new color was picked from: of the swatches with the name, the first with the row's new color (as a color key); while it is a global or spot swatch and there is no globalAdjust (or limitTo is given), the row's art takes the swatch as with limitTo, linked to it at its tints; a process swatch, or a swatch or library that is not there, links nothing; a `swatch` that is not {name, library?} is an error)}] | {\"key or #rrggbb\": colour, …} (one row per colour), method?: \"exact\" (default)|\"preserveTints\"|\"scaleTints\"|\"tintsShades\"|\"hueShift\" (how a row's colours take its new colour, relative to the row's darkest, average or most saturated colour), limitTo?: swatch library id or name; or \"document\" (the document's swatches): new colours snap to its nearest colour, group?: colour group to rewrite, groupColors?: [colour | null | \"keep\"] (what the color swatches of `group` are rewritten with, in order: a gradient, pattern or None swatch keeps its place and paint; a null removing the color swatch at its place and \"keep\" leaving that swatch its colour, without the Global Adjust (past the color swatches it adds nothing); default: the new colors of the rows with current colors, in order, then those of the empty rows with `added`, excluded rows left out), rename?: the group's new name, includeImages?: true, includePatterns?: true, globalAdjust?: {saturation?: 0, brightness?: 0, temperature?: 0, luminosity?: 0} (Global Adjust: percent from -100 to 100, 0 changes nothing; every colour a row that isn't excluded recolours, and the group's new colours, take the same change after the row's new colour: saturation scales HSB saturation by 1 + saturation/100, brightness moves HSB brightness that share of the way to full or to black, temperature adds 0.2 × temperature/100 to red and takes it from blue, luminosity moves Lab lightness that share of the way to 100 or 0 keeping a and b; with limitTo each row's new colour takes the change before it snaps to the library)} recolour the selection (gradients, text, meshes, image pixels and pattern tiles included; each new colour keeps the model of the one it replaces (model?: \"keep\" default | \"new\" (the new colour's own model, so a CMYK colour replacing RGB art gives CMYK art) | \"document\" (the document's colour mode)), except a library swatch's with limitTo: art takes the swatch itself, linked to a global or spot colour at its tints, and the swatch joins the document's swatches; art linked to a global swatch of `group` that is rewritten with its row's new color stays linked to it, at its tint, unless the row converts the color into the art's model; other recolored art, and art in a row linked to a global swatch of `group` that is rewritten with another color, keeps its row's new color and loses its swatch link) and the group, as one undo step (none when nothing changes). On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {changed, swatches: [names added to the document's swatches], swatchesNotFound?: [names of rows' `swatch` that are not there, which linked nothing], relinked?: with group, the other paints linked to its global swatches that took their new colors, note?: set when a colour kept a model other than its new colour's (see model), notChanged: {locked, hidden} (as edit.colors.invert), warning?: set when notChanged counts any object}", + "{map: rows [{from: [colour keys (recolor.colors) or \"#rrggbb\" (every colour shown as that hex); may be empty: an empty row recolours nothing, adds no library swatch and gives `group` no colour unless `added`], to: colour (hex, key, {c,m,y,k} or {l,a,b}) | null (in from, to and groupColors, #rrggbbaa and #rgba are refused), exclude?: false (the row's colours are kept), tint?: 100 (percent; with limitTo or swatch, art linked to the global or spot swatch the new color is takes this share of its tint), added?: false (an empty row's new color is a color added to `group`), swatch?: {name, library?: swatch library id or name; \"document\" (default)} (the swatch the new color was picked from: of the swatches with the name, the first with the row's new color (as a color key); while it is a global or spot swatch and there is no globalAdjust (or limitTo is given), the row's art takes the swatch as with limitTo, linked to it at its tints; a process swatch, or a swatch or library that is not there, links nothing; with limitTo the library's swatch of the row's new color comes first; a global swatch of `group` that is rewritten with another color links nothing, and the row's art keeps the row's new color; a `swatch` that is not {name, library?} is an error)}] | {\"key or #rrggbb\": colour, …} (one row per colour), method?: \"exact\" (default)|\"preserveTints\"|\"scaleTints\"|\"tintsShades\"|\"hueShift\" (how a row's colours take its new colour, relative to the row's darkest, average or most saturated colour), limitTo?: swatch library id or name; or \"document\" (the document's swatches): new colours snap to its nearest colour, group?: colour group to rewrite, groupColors?: [colour | null | \"keep\"] (what the color swatches of `group` are rewritten with, in order: a gradient, pattern or None swatch keeps its place and paint; a null removing the color swatch at its place and \"keep\" leaving that swatch its colour, without the Global Adjust (past the color swatches it adds nothing); default: the new colors of the rows with current colors, in order, then those of the empty rows with `added`, excluded rows left out), rename?: the group's new name, includeImages?: true, includePatterns?: true, globalAdjust?: {saturation?: 0, brightness?: 0, temperature?: 0, luminosity?: 0} (Global Adjust: percent from -100 to 100, 0 changes nothing; every colour a row that isn't excluded recolours, and the group's new colours, take the same change after the row's new colour: saturation scales HSB saturation by 1 + saturation/100, brightness moves HSB brightness that share of the way to full or to black, temperature adds 0.2 × temperature/100 to red and takes it from blue, luminosity moves Lab lightness that share of the way to 100 or 0 keeping a and b; with limitTo each row's new colour takes the change before it snaps to the library)} recolour the selection (gradients, text, meshes, image pixels and pattern tiles included; each new colour keeps the model of the one it replaces (model?: \"keep\" default | \"new\" (the new colour's own model, so a CMYK colour replacing RGB art gives CMYK art) | \"document\" (the document's colour mode)), except a library swatch's with limitTo: art takes the swatch itself, linked to a global or spot colour at its tints, and the swatch joins the document's swatches; art linked to a global swatch of `group` that is rewritten with its row's new color stays linked to it, at its tint, unless the row converts the color into the art's model; other recolored art, and art in a row linked to a global swatch of `group` that is rewritten with another color, keeps its row's new color and loses its swatch link) and the group, as one undo step (none when nothing changes). On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {changed, swatches: [names added to the document's swatches], swatchesNotFound?: [names of rows' `swatch` that are not there, which linked nothing], relinked?: with group, the other paints linked to its global swatches that took their new colors, note?: set when a colour kept a model other than its new colour's (see model), notChanged: {locked, hidden} (as edit.colors.invert), warning?: set when notChanged counts any object}", has_doc, apply ), @@ -1622,7 +1622,9 @@ impl ColorMap { }; let i = out.rows.len(); let colors: Vec = r.from.iter().map(Match::color).collect(); - let link = links.get(n).cloned().flatten(); + // A global swatch of the rewritten group that takes another color links nothing, and the + // row recolors as it would with no swatch (its tint of the swatch left out). + let link = links.get(n).cloned().flatten().filter(|l| !(l.global && out.group.iter().any(|g| g.name == l.name && g.shown != l.color))); // Colors that can't link to the swatch take the row's tint of it too. let mapped = link.as_ref().filter(|l| l.global && l.tint < 1.0).map_or(to, |l| to.tinted(l.tint)); out.rows.push(RowMap::new(method, &colors, mapped).with_own_model(r.model.unwrap_or(model) != ModelRule::Keep)); diff --git a/crates/engine/src/tests/recolor.rs b/crates/engine/src/tests/recolor.rs index 2d11b9b1af..3c8da0536a 100644 --- a/crates/engine/src/tests/recolor.rs +++ b/crates/engine/src/tests/recolor.rs @@ -947,6 +947,63 @@ fn a_rows_swatch_with_a_finer_color_than_its_key_still_links() { assert!(close(fill(&s, id), ink), "the swatch's own color: {:?}", fill(&s, id)); } +/// A row's `swatch` that is a global swatch of the group being rewritten with another color links +/// nothing: the row's art takes the row's new color as with no swatch, in its own model and without +/// the row's tint of the swatch. A swatch of the group that keeps its color still links the art. +#[test] +fn a_rows_swatch_in_the_rewritten_group_keeps_the_rows_new_color() { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Red Ink", "color": "#ff0000", "global": true})); + run(&mut s, "swatch.new", json!({"name": "Blue Ink", "color": "#0000ff", "global": true})); + run(&mut s, "swatch.newGroup", json!({"name": "G", "swatches": ["Red Ink", "Blue Ink"]})); + let red = rect(&mut s, json!("#ff0000")); + let blue = rect(&mut s, json!("#0000ff")); + select_all(&mut s); + let map = |first: &str| { + json!([ + {"from": ["#ff0000"], "to": first}, + {"from": ["#0000ff"], "to": "#ff0000", "swatch": {"name": "Red Ink"}}, + ]) + }; + run(&mut s, "recolor.apply", json!({"map": map("#00ff00"), "group": "G"})); + let ink = |s: &Session| s.doc().unwrap().doc.swatch("Red Ink").unwrap().paint.color().unwrap().to_hex(); + assert_eq!(ink(&s), "#00ff00", "the group is rewritten"); + assert_eq!(fill(&s, red).to_hex(), "#00ff00"); + assert_eq!(fill(&s, blue).to_hex(), "#ff0000", "the blue art keeps its row's new color"); + assert_eq!(paint_link(&s, blue), None); + run(&mut s, "edit.undo", json!({})); + select_all(&mut s); + // Also at a row tint of 0, where Red Ink's old and new colors both show white. + let mut zero = map("#00ff00"); + zero[1]["tint"] = json!(0); + run(&mut s, "recolor.apply", json!({"map": zero, "group": "G"})); + assert_eq!(paint_link(&s, blue), None, "at a tint of 0"); + assert_eq!(fill(&s, blue).to_hex(), "#ff0000", "the row's new color, as with no swatch"); + run(&mut s, "edit.undo", json!({})); + select_all(&mut s); + // Red Ink is rewritten with its own color, so the blue art links to it. + run(&mut s, "recolor.apply", json!({"map": map("#ff0000"), "group": "G"})); + assert_eq!(ink(&s), "#ff0000"); + assert_eq!(fill(&s, blue).to_hex(), "#ff0000"); + assert_eq!(paint_link(&s, blue).as_deref(), Some("Red Ink")); + run(&mut s, "edit.undo", json!({})); + // A CMYK swatch of a group rewritten with another color: the RGB art takes the row's new color + // as the row without the swatch gives it, in the art's own model. + run(&mut s, "swatch.new", json!({"name": "Cyan Ink", "color": "cmyk 100 0 0 0", "global": true})); + run(&mut s, "swatch.newGroup", json!({"name": "C", "swatches": ["Cyan Ink"]})); + let result = |s: &mut Session, swatch: Value| { + select_all(s); + let map = json!([{"from": ["#0000ff"], "to": "cmyk 100 0 0 0", "swatch": swatch}]); + let r = run(s, "recolor.apply", json!({"map": map, "group": "C", "groupColors": ["#00ff00"]})); + let out = (fill(s, blue), paint_link(s, blue), r.get("note").cloned()); + run(s, "edit.undo", json!({})); + out + }; + let alone = result(&mut s, Value::Null); + assert!(alone.2.is_some(), "the RGB art keeps its model: {alone:?}"); + assert_eq!(result(&mut s, json!({"name": "Cyan Ink"})), alone); +} + /// A row's `swatch` from a loaded library links the art to it and adds it to the document's /// swatches; of two library swatches with the same name, the one with the row's new color is used, /// and rows that pick the same one link to one added swatch; of a process and a spot swatch with diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index 1c32bb5ec1..b5b51a89ab 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -1801,7 +1801,8 @@ fn assign_tab(app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut let mut clicked: Option = None; let mut pick: Option<(usize, bool)> = None; let mut limit_to: Option = None; - let shown: Vec = rows.iter().map(|r| new_shown(app, d, r)).collect(); + let links = RowLinks::new(app, d); + let shown: Vec = rows.iter().map(|r| new_shown(app, d, &links, r)).collect(); widgets::list_box(ui, |ui| { egui::ScrollArea::vertical().id_salt("recolor-rows").max_height(TABLE_H).show(ui, |ui| { ui.set_width(ui.available_width()); @@ -2061,12 +2062,12 @@ fn spot_tinted(app: &VectorcraftApp, c: Color, t: f32) -> Color { /// The color row `row`'s new color chip shows: what the art takes, at the row's tint (a spot color /// of the library as [`spot_tinted`] shows it). -fn new_shown(app: &VectorcraftApp, d: &Dialog, row: &Value) -> Color { +fn new_shown(app: &VectorcraftApp, d: &Dialog, links: &RowLinks, row: &Value) -> Color { let to = to_color(row).unwrap_or_default(); // Only a Lab spot color can show another color; the library lookup is skipped for the rest. - if matches!(to, Color::Lab { .. }) && d.bool("__art") && (spot_of(app, d, &to).is_some() || own_spot(app, d, row, &to).is_some()) { + if matches!(to, Color::Lab { .. }) && d.bool("__art") && linked_spot(app, d, links, row, &to).is_some() { spot_tinted(app, to, row_tint(row)) - } else if row_tint(row) < 1.0 && tint_applies(app, d, row, &to) { + } else if row_tint(row) < 1.0 && tint_applies(app, d, links, row, &to) { to.tinted(row_tint(row)) } else { // The swatch the tint was for no longer links the art, which takes the full color. @@ -2079,26 +2080,108 @@ fn mode_id(m: Mode) -> String { serde_json::to_value(m).ok().and_then(|v| v.as_str().map(str::to_string)).unwrap_or_default() } -/// The name of the library swatch (Limit to Library) that `recolor.apply` gives new color `c`, when -/// it is a spot color: the first swatch of the library color nearest `c`. -fn spot_of(app: &VectorcraftApp, d: &Dialog, c: &Color) -> Option { - let lib = d.str("limitTo"); - if lib.is_empty() { - return None; +/// What decides how `recolor.apply` links the art of the rows to swatches, read once for all rows: +/// Limit to Library's palette and color swatches, and the names of the color group's global swatches +/// that OK's rewrite gives another color ([`rewritten_to_another`]). +struct RowLinks { + library: Option<(vectorcraft_color::recolor::Palette, Vec)>, + rewritten: Vec, +} + +impl RowLinks { + fn new(app: &VectorcraftApp, d: &Dialog) -> Self { + let lib = d.str("limitTo"); + let library = if lib.is_empty() { None } else { limit_palette_before_preview(app, &lib).zip(limit_swatches(app, &lib)) }; + let rewritten = rewritten_to_another(app, d, library.as_ref().map(|(palette, _)| palette)); + Self { library, rewritten } + } + + /// The library swatch (Limit to Library) that `recolor.apply` gives new color `c`: the first + /// swatch of the library color nearest `c`. + fn library_swatch(&self, c: &Color) -> Option<&vectorcraft_color::swatch::Swatch> { + let (palette, swatches) = self.library.as_ref()?; + let near = palette.nearest(*c); + swatches.iter().find(|w| w.paint.color() == Some(near)) + } +} + +/// Limit to Library's palette for `lib`, as [`swatchlib::limit_palette`] gives it, with the +/// document's swatches read as they were before the preview, which `recolor.apply` runs on. +fn limit_palette_before_preview(app: &VectorcraftApp, lib: &str) -> Option { + if lib != swatchlib::DOCUMENT_SWATCHES { + return swatchlib::limit_palette(&app.session, lib); + } + let st = app.session.active()?; + let doc = st.interaction.as_ref().map_or(&st.doc, |it| &it.doc); + Some(vectorcraft_color::recolor::Palette::new(doc.swatches_iter().filter_map(|w| w.paint.color()))) +} + +/// The color swatches of Limit to Library's `lib`, as [`swatchlib::library_swatches`] gives them, +/// with the document's swatches read as they were before the preview. +fn limit_swatches(app: &VectorcraftApp, lib: &str) -> Option> { + if lib != swatchlib::DOCUMENT_SWATCHES { + return swatchlib::library_swatches(&app.session, lib); + } + let st = app.session.active()?; + let doc = st.interaction.as_ref().map_or(&st.doc, |it| &it.doc); + Some(doc.swatches_iter().filter(|w| matches!(w.paint, vectorcraft_color::Paint::Solid { swatch: None, .. })).cloned().collect()) +} + +/// The name of the spot swatch the art of `row`, with new color `c`, links to: Limit to Library's +/// swatch of that color when the library has one (a process swatch there links nothing, and the +/// row's own `swatch` is not used, as in `recolor.apply`), else the row's own spot swatch. +fn linked_spot(app: &VectorcraftApp, d: &Dialog, links: &RowLinks, row: &Value, c: &Color) -> Option { + match links.library_swatch(c) { + Some(w) => (w.spot && !link_rewritten(app, links, w)).then(|| w.name.clone()), + None => own_spot(app, d, links, row, c), } - let near = swatchlib::limit_palette(&app.session, &lib)?.nearest(*c); - swatchlib::library_swatches(&app.session, &lib)?.into_iter().find(|w| w.paint.color() == Some(near)).filter(|w| w.spot).map(|w| w.name) } /// The name of the spot swatch `row`'s new color `c` was picked from (its `swatch`), while that -/// swatch has color `c` and no Global Adjust applies without Limit to Library, as `recolor.apply` -/// reads it. -fn own_spot(app: &VectorcraftApp, d: &Dialog, row: &Value, c: &Color) -> Option { +/// swatch has color `c`, no Global Adjust applies without Limit to Library and OK's rewrite of the +/// color group gives it no other color ([`link_rewritten`]), as `recolor.apply` reads it. +fn own_spot(app: &VectorcraftApp, d: &Dialog, links: &RowLinks, row: &Value, c: &Color) -> Option { if d.str("limitTo").is_empty() && !global_adjust(adjust_values(d)).is_identity() { return None; } - let (name, _) = swatch_ref(row)?; - row_swatch(app, row, c).filter(|spot| *spot).map(|_| name.to_string()) + row_swatch(app, row, c).filter(|w| w.spot && !link_rewritten(app, links, w)).map(|w| w.name) +} + +/// Whether the art `recolor.apply` links to swatch `w` (a library's or the document's) links nothing +/// because OK's rewrite of the color group gives it another color: `w` joins the document under its +/// own name only when the document's swatch of that name has its paint, Global and spot, and is +/// added under a free name otherwise, which no swatch of the group has. +fn link_rewritten(app: &VectorcraftApp, links: &RowLinks, w: &vectorcraft_color::swatch::Swatch) -> bool { + if !links.rewritten.contains(&w.name) { + return false; + } + let Some(st) = app.session.active() else { return false }; + let doc = st.interaction.as_ref().map_or(&st.doc, |it| &it.doc); + doc.swatch(&w.name).is_some_and(|x| x.paint == w.paint && x.global == w.global && x.spot == w.spot) +} + +/// The names of the color group's global swatches that OK's rewrite (`groupColors` of +/// [`apply_params`]) gives a color other than their own, as `recolor.apply` reads it: each color +/// takes the Global Adjust and, with Limit to Library, the library's nearest color (`palette`); +/// `"keep"` and a removed color give none. Art whose row picked such a swatch links nothing. +fn rewritten_to_another(app: &VectorcraftApp, d: &Dialog, palette: Option<&vectorcraft_color::recolor::Palette>) -> Vec { + let p = apply_params(d); + let (Some(group), Some(colors)) = (p["group"].as_str(), p["groupColors"].as_array()) else { return Vec::new() }; + let Some(st) = app.session.active() else { return Vec::new() }; + let doc = st.interaction.as_ref().map_or(&st.doc, |it| &it.doc); + let adjust = global_adjust(adjust_values(d)); + let Some(g) = doc.swatch_groups.iter().find(|g| g.name == group) else { return Vec::new() }; + g.swatches + .iter() + .filter_map(|w| Some((w, w.paint.color()?))) + .zip(colors) + .filter(|((w, own), v)| { + let new = color_value(v).filter(|_| v.as_str() != Some("keep")).map(|c| adjust.apply(c)); + let new = new.map(|c| palette.map_or(c, |pl| pl.nearest(c))); + w.global && !w.is_reserved() && new.is_some_and(|c| doc.linked_color(c, w.spot) != doc.linked_color(*own, w.spot)) + }) + .map(|((w, _), _)| w.name.clone()) + .collect() } /// The name and library key of `row`'s `swatch` when it is `{name, library?}` with a name, as @@ -2113,12 +2196,11 @@ fn swatch_ref(row: &Value) -> Option<(&str, &str)> { Some((name, library)) } -/// Whether the swatch `row`'s `swatch` names, with color `c` (as a color key), is a spot color, -/// when it is a global or spot swatch; `None` when it is a process swatch or not there (deleted -/// since the pick). Of several swatches with that name, the first with that color counts, as -/// `recolor.apply` finds it. The document's swatches are read as they were before the preview, -/// which `recolor.apply` runs on. -fn row_swatch(app: &VectorcraftApp, row: &Value, c: &Color) -> Option { +/// The swatch `row`'s `swatch` names, with color `c` (as a color key), when it is a global or spot +/// swatch; `None` when it is a process swatch or not there (deleted since the pick). Of several +/// swatches with that name, the first with that color counts, as `recolor.apply` finds it. The +/// document's swatches are read as they were before the preview, which `recolor.apply` runs on. +fn row_swatch(app: &VectorcraftApp, row: &Value, c: &Color) -> Option { let (name, lib) = swatch_ref(row)?; let fits = |s: &&vectorcraft_color::swatch::Swatch| { s.name == name @@ -2128,19 +2210,25 @@ fn row_swatch(app: &VectorcraftApp, row: &Value, c: &Color) -> Option { let found = if lib == swatchlib::DOCUMENT_SWATCHES { let st = app.session.active()?; let doc = st.interaction.as_ref().map_or(&st.doc, |it| &it.doc); - doc.swatches_iter().find(fits).map(|s| (s.global || s.spot, s.spot)) + doc.swatches_iter().find(fits).cloned() } else { let (_, l) = swatchlib::library(&app.session, lib)?; - l.swatches.iter().chain(l.groups.iter().flat_map(|g| g.swatches.iter())).find(fits).map(|s| (s.global || s.spot, s.spot)) + l.swatches.iter().chain(l.groups.iter().flat_map(|g| g.swatches.iter())).find(fits).cloned() }; - found.filter(|(links, _)| *links).map(|(_, spot)| spot) + found.filter(|s| s.global || s.spot) } -/// Whether the new color chip shows `row`'s tint: with Limit to Library, when the row has no -/// `swatch`, or when its `swatch` links the art ([`row_swatch`], with no Global Adjust). A row whose -/// `swatch` links nothing recolors its art with the full color. -fn tint_applies(app: &VectorcraftApp, d: &Dialog, row: &Value, c: &Color) -> bool { - !d.str("limitTo").is_empty() || swatch_ref(row).is_none() || (global_adjust(adjust_values(d)).is_identity() && row_swatch(app, row, c).is_some()) +/// Whether the new color chip shows `row`'s tint: with Limit to Library unless the library's swatch +/// of `c` is one OK's rewrite of the color group gives another color ([`link_rewritten`]), when the +/// row has no `swatch`, or when its `swatch` links the art ([`row_swatch`], with no Global Adjust, +/// and not [`link_rewritten`]). A row whose `swatch` links nothing recolors its art with the full +/// color. +fn tint_applies(app: &VectorcraftApp, d: &Dialog, links: &RowLinks, row: &Value, c: &Color) -> bool { + if !d.str("limitTo").is_empty() { + return links.library_swatch(c).is_none_or(|w| !link_rewritten(app, links, w)); + } + swatch_ref(row) + .is_none_or(|_| global_adjust(adjust_values(d)).is_identity() && row_swatch(app, row, c).is_some_and(|w| !link_rewritten(app, links, &w))) } /// The mode the sliders show new color `c` in, `None` for Tint: the mode picked in the menu, else @@ -2188,7 +2276,7 @@ impl SliderTarget { let row = row.filter(|i| *i < rows.len()); let color = row.and_then(|i| to_color(&rows[i])); // A row tint acts only on art, so without art a spot color shows the process modes. - let spot = color.filter(|_| d.bool("__art")).and_then(|c| spot_of(app, d, &c).or_else(|| own_spot(app, d, &rows[row?], &c))); + let spot = color.filter(|_| d.bool("__art")).and_then(|c| linked_spot(app, d, &RowLinks::new(app, d), &rows[row?], &c)); Self { row, color, spot } } @@ -3647,7 +3735,7 @@ mod tests { rs[0]["tint"] = json!(40.0); picked.fields.insert("rows".into(), Value::Array(rs)); let rs = super::rows(&picked); - let tinted = new_shown(&app, &picked, &rs[0]); + let tinted = new_shown(&app, &picked, &RowLinks::new(&app, &picked), &rs[0]); assert!(tinted != ink && tinted.to_rgb()[1] > ink.to_rgb()[1], "the chip at 40%: {tinted:?}"); // A process swatch of the same color picked for the row. let process = with_new_swatch(&app, picked.clone(), 0, ink, None); @@ -3658,11 +3746,11 @@ mod tests { app.session.begin_interaction("Swatch Options").unwrap(); app.session.preview("swatch.edit", &json!({"name": "Ink", "color": "cmyk 100 0 0 0"})).unwrap(); assert_eq!(SliderTarget::at(&app, &picked, &rs, Some(0)).spot.as_deref(), Some("Ink"), "the swatch as it was before the preview"); - assert_eq!(new_shown(&app, &picked, &rs[0]), tinted); + assert_eq!(new_shown(&app, &picked, &RowLinks::new(&app, &picked), &rs[0]), tinted); let _ = app.session.cancel_interaction(); app.run("swatch.delete", json!({"names": ["Ink"]})).unwrap(); assert_eq!(SliderTarget::at(&app, &picked, &rs, Some(0)).spot, None, "no Tint slider"); - assert_eq!(new_shown(&app, &picked, &rs[0]), ink, "the full color the art takes"); + assert_eq!(new_shown(&app, &picked, &RowLinks::new(&app, &picked), &rs[0]), ink, "the full color the art takes"); let r = app.session.execute(CMD, &apply_params(&picked)).unwrap(); assert_eq!(r["swatchesNotFound"], json!(["Ink"]), "{r}"); let doc = &app.session.doc().unwrap().doc; @@ -3676,6 +3764,40 @@ mod tests { } } + /// A row picked from a spot swatch of the color group shows Tint and its tint on the chip while + /// OK leaves the swatch its color, and no Tint and the full color once OK gives the swatch + /// another color, as `recolor.apply` then gives the art. + #[test] + fn a_picked_swatch_the_group_rewrites_shows_the_full_color() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.run("swatch.new", json!({"name": "Ink", "color": "cmyk 0 100 0 0", "spot": true})).unwrap(); + app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink"]})).unwrap(); + for c in ["cmyk 0 100 0 0", "#808080"] { + let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].clone(); + app.run("paint.setFill", json!({"ids": [id], "color": c})).unwrap(); + app.run("paint.setStroke", json!({"ids": [id], "none": true})).unwrap(); + } + app.run("select.all", json!({})).unwrap(); + app.run("ui.recolorDialog", json!({"group": "Inks"})).unwrap(); + let mut d = app.ui.dialog.clone().unwrap(); + let ink = Color::cmyk(0.0, 1.0, 0.0, 0.0); + let rows = |first: &str| { + json!([ + {"from": ["cmyk 0 100 0 0"], "to": first}, + {"from": ["rgb 128 128 128"], "to": "cmyk 0 100 0 0", "swatch": {"name": "Ink", "library": "document"}, "tint": 40.0}, + ]) + }; + d.fields.insert("rows".into(), rows("cmyk 0 100 0 0")); + let rs = super::rows(&d); + assert_eq!(SliderTarget::at(&app, &d, &rs, Some(1)).spot.as_deref(), Some("Ink"), "Ink keeps its color"); + assert_ne!(new_shown(&app, &d, &RowLinks::new(&app, &d), &rs[1]), ink, "the chip at 40%"); + d.fields.insert("rows".into(), rows("rgb 0 255 0")); + let rs = super::rows(&d); + assert_eq!(SliderTarget::at(&app, &d, &rs, Some(1)).spot, None, "no Tint slider once Ink takes green"); + assert_eq!(new_shown(&app, &d, &RowLinks::new(&app, &d), &rs[1]), ink, "the full color the art takes"); + } + /// With the Spot Colors options on CMYK values, a row whose new color is a Lab spot color of the /// library shows the art's color at its tint: the working-CMYK equivalent with its inks scaled. #[test] @@ -3701,7 +3823,7 @@ mod tests { assert!(matches!(c, Color::Lab { .. }), "{c:?}"); let cmyk = app.session.doc().unwrap().doc.linked_color(c, true); assert!(matches!(cmyk, Color::Cmyk { .. }), "{cmyk:?}"); - assert_eq!(new_shown(&app, &d, &rs[0]), cmyk.tinted(0.5)); + assert_eq!(new_shown(&app, &d, &RowLinks::new(&app, &d), &rs[0]), cmyk.tinted(0.5)); } /// Runs one frame of the open dialog at `time` and returns row `i`'s new color chip, when the diff --git a/crates/ui-egui/src/tests/recolor.rs b/crates/ui-egui/src/tests/recolor.rs index 8823e1a0fa..6086f0de26 100644 --- a/crates/ui-egui/src/tests/recolor.rs +++ b/crates/ui-egui/src/tests/recolor.rs @@ -460,6 +460,107 @@ fn a_process_swatch_before_a_spot_one_of_its_color_shows_no_tint() { assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "C").is_some(), "the CMYK sliders"); } +/// A row picked from a spot swatch shows Tint, but not with Limit to Library while the library's +/// swatch of that color is a process color: `recolor.apply` gives the art the library's swatch, +/// which links nothing. +#[test] +fn a_process_library_swatch_hides_the_tint_of_a_rows_own_spot_swatch() { + let mut app = app(); + let lib = library_of(&mut app, &[json!({"name": "Mix Process", "color": {"c": 0, "m": 1, "y": 0, "k": 0}})]); + app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 1, "y": 0, "k": 0}, "spot": true})).unwrap(); + art(&mut app, &["cmyk 0 100 0 0"]); + let mut h = assign_harness(app, json!({"library": lib})); + let mut rows = field(h.state(), "rows"); + assert_eq!(rows[0]["to"], json!("cmyk 0 100 0 0"), "{rows}"); + rows[0]["swatch"] = json!({"name": "Ink", "library": "document"}); + set(h.state_mut(), "rows", rows); + set(h.state_mut(), "__sel", json!([0])); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_none(), "no Tint for the library's process swatch"); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "C").is_some(), "the CMYK sliders"); +} + +/// A row picked from a spot swatch of the color group being edited shows Tint while OK leaves the +/// swatch its color, and not once another row gives the swatch a new color: `recolor.apply` then +/// links the row's art to nothing. +#[test] +fn a_rows_spot_swatch_rewritten_with_another_color_shows_no_tint() { + let mut app = app(); + app.run("swatch.new", json!({"name": "Ink", "color": "cmyk 0 100 0 0", "spot": true})).unwrap(); + app.run("swatch.new", json!({"name": "Other", "color": "cmyk 100 0 0 0", "spot": true})).unwrap(); + app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink", "Other"]})).unwrap(); + art(&mut app, &["cmyk 0 100 0 0", "cmyk 100 0 0 0"]); + let mut h = assign_harness(app, json!({"group": "Inks"})); + let rows = field(h.state(), "rows"); + let at = |k: &str| rows.as_array().unwrap().iter().position(|r| r["from"].as_array().is_some_and(|f| f.contains(&json!(k)))).unwrap(); + let (magenta, cyan) = (at("cmyk 0 100 0 0"), at("cmyk 100 0 0 0")); + let mut rows = rows.clone(); + rows[cyan]["to"] = json!("cmyk 0 100 0 0"); + rows[cyan]["swatch"] = json!({"name": "Ink", "library": "document"}); + set(h.state_mut(), "rows", rows.clone()); + set(h.state_mut(), "__sel", json!([cyan])); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_some(), "Ink keeps its color: Tint"); + rows[magenta]["to"] = json!("rgb 0 255 0"); + set(h.state_mut(), "rows", rows); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_none(), "Ink takes green: no Tint"); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "C").is_some(), "the CMYK sliders"); +} + +/// With Limit to Library on the document's swatches, a row whose new color is a spot swatch of the +/// color group being edited shows Tint while OK leaves the swatch its color, and not once another +/// row gives the swatch a new color: `recolor.apply` then links the row's art to nothing. +#[test] +fn a_library_spot_swatch_rewritten_with_another_color_shows_no_tint() { + let mut app = app(); + app.run("swatch.new", json!({"name": "Ink", "color": "cmyk 0 70 0 20", "spot": true})).unwrap(); + app.run("swatch.new", json!({"name": "Other", "color": "cmyk 70 0 0 20", "spot": true})).unwrap(); + app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink", "Other"]})).unwrap(); + art(&mut app, &["cmyk 0 70 0 20", "cmyk 70 0 0 20"]); + let mut h = assign_harness(app, json!({"group": "Inks"})); + set(h.state_mut(), "limitTo", json!("document")); + // The dialog reduces the art again for the library, which clears the selection. + h.run_steps(2); + let rows = field(h.state(), "rows"); + let at = |k: &str| rows.as_array().unwrap().iter().position(|r| r["from"].as_array().is_some_and(|f| f.contains(&json!(k)))).unwrap(); + let (magenta, cyan) = (at("cmyk 0 70 0 20"), at("cmyk 70 0 0 20")); + let mut rows = rows.clone(); + rows[cyan]["to"] = json!("cmyk 0 70 0 20"); + set(h.state_mut(), "rows", rows.clone()); + set(h.state_mut(), "__sel", json!([cyan])); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_some(), "Ink keeps its color: Tint"); + rows[magenta]["to"] = json!("cmyk 70 0 0 20"); + set(h.state_mut(), "rows", rows); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_none(), "Ink takes cyan: no Tint"); +} + +/// A row picked from a library's spot swatch keeps Tint when the color group being edited gives a +/// different document swatch of the same name another color: `recolor.apply` adds the library's +/// swatch under a free name and links the row's art to it. +#[test] +fn a_library_swatch_named_like_a_rewritten_group_swatch_keeps_its_tint() { + let mut app = app(); + let lib = library_of(&mut app, &[json!({"name": "Ink", "color": {"c": 0, "m": 1, "y": 0, "k": 0}, "spot": true})]); + app.run("swatch.new", json!({"name": "Ink", "color": "cmyk 0 0 100 0", "spot": true})).unwrap(); + app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink"]})).unwrap(); + art(&mut app, &["cmyk 0 0 100 0", "cmyk 0 100 0 0"]); + let mut h = assign_harness(app, json!({"group": "Inks"})); + let rows = field(h.state(), "rows"); + let at = |k: &str| rows.as_array().unwrap().iter().position(|r| r["from"].as_array().is_some_and(|f| f.contains(&json!(k)))).unwrap(); + let (yellow, magenta) = (at("cmyk 0 0 100 0"), at("cmyk 0 100 0 0")); + let mut rows = rows.clone(); + rows[yellow]["to"] = json!("rgb 0 255 0"); + rows[magenta]["to"] = json!("cmyk 0 100 0 0"); + rows[magenta]["swatch"] = json!({"name": "Ink", "library": lib}); + set(h.state_mut(), "rows", rows); + set(h.state_mut(), "__sel", json!([magenta])); + h.run_steps(2); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Slider, "T").is_some(), "the library's Ink still links: Tint"); +} + /// Opened on a color group without art, a row whose new color is a spot color of the library shows /// the process modes and no Tint: OK saves only the group's colors, so a tint would be lost. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index 9bba7e67c1..2050ba1d32 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5573,7 +5573,10 @@ which round) is used. While it is a global or spot swatch and there is no Global row's art takes the swatch as it would with `limitTo`, linked to it at its tints (and its `tint` applies), and a library swatch joins the document's swatches. A process swatch, or a swatch or library that is not there (such as a swatch deleted after it was picked), links nothing, and the row recolors as its new color alone does; the result's -`swatchesNotFound` lists the names of the swatches that are not there. A row whose new color is +`swatchesNotFound` lists the names of the swatches that are not there. With `limitTo`, the library's swatch of the +row's new color is used instead when the library has one, so a process swatch there links nothing. A global swatch of +`group` that the group's rewrite gives another color links nothing either: the row's art keeps the row's new color, as +other recolored art does. A row whose new color is picked from a global or spot swatch in the Color Picker's swatch list in Recolor Artwork carries it, so with no Limit to Library the art still takes the swatch picked; the dialog drops a row's `swatch` when the row's new color changes. A `swatch` that is not `{name, library?}` is an error. `recolor.randomize` diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index cb88bca758..c026dbb243 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2033,7 +2033,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Recolor Artwork color groups list:** a list on the right of the dialog shows the document's color groups, and the Show Color Groups button beside the tabs shows or hides it. A click on a group makes it the group being edited, and the rows take its colors. Save Changes rewrites the selected group with the new colors, New Color Group saves them as a new group, and Delete removes the selected group; the Swatches panel shows each change ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html)). VectorCraft's own rules: when the art has colors of the group, Save Changes and OK keep the group's swatches in order, and a swatch no row lists keeps its color; an excluded row leaves its swatch its own color; after a save with art, the rows' new colors take the Global Adjust, which goes back to 0%. `group`, `groupStorage` and `groupAction` are the dialog fields. Tests: `the_color_groups_list_selects_saves_and_deletes_groups`, `a_group_picked_in_the_list_recolors_the_art` and the `saving_a_group_` tests in `crates/ui-egui/src/dialogs/recolor.rs`, and `edit_color_group_with_its_own_colors_records_no_undo_step` and `edit_color_group_with_its_own_color_keys_keeps_the_colors` in `crates/engine/src/tests/swatchcmds.rs`. - **Recolor Artwork New Row:** the Assign tab's New Row button adds a row with no current colors, so current colors can be moved into it and take its new color ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html), [Assign new colors to selected artworks](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/assign-new-colors-to-selected-artwork.html)). VectorCraft's own rules: the row goes above the first selected row (at the top when none is selected) with that row's new color and becomes the selection, and Merge with it as the first selected row moves the other rows' colors into it. The button needs selected art. An empty row recolors nothing, does not count toward Colors, adds no library swatch and gives a rewritten color group no color. While it is empty, Save All Colors and a new color group saved from colors alone leave its new color out, the Edit tab's wheel, bars and chips do not show it and its sliders edit the base color instead, the harmony rules and linked moves leave its new color as it is, and the Color Theme Picker gives it no color. Tests: `a_new_row_goes_above_the_selection_and_takes_merged_colors`, `an_empty_row_gives_the_group_no_color`, `an_empty_row_gives_a_new_group_no_color`, `an_empty_row_takes_no_harmony_or_wheel_color`, `theme_picks_leave_an_empty_row_out`, `save_all_colors_leaves_an_empty_row_out` and `colors_merged_into_a_new_row_take_its_new_color` in `crates/ui-egui/src/dialogs/recolor.rs`, `an_empty_row_recolors_nothing` and `an_empty_row_adds_no_swatch_and_no_group_color` in `crates/engine/src/tests/recolor.rs`. - **Recolor Artwork Undo Changes and Redo Changes:** two buttons beside the Color Theme Picker go back and forward one color edit made in the open dialog, and Undo Changes has nothing to undo after the dialog is opened again ([Recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/recolor-options-overview.html)); `ui.recolorUndo` and `ui.recolorRedo` run them. VectorCraft's own rules: the dialog's history is separate from the document's, which changes when OK records one undo step and when Save All Colors or Save Prominent Colors adds a color group at once as its own undo step, which Cancel and Undo Changes leave in place; a drag is one step, fields set with `ui.dialog.set` before the next frame with the pointer up or the next step are one step, Reset is a step of its own, a new edit leaves nothing to redo, selecting another color group or Save Changes leaves nothing to undo or redo and an edit after either is a step back to the fields as they were then, a button with no step to go to is disabled, and the dialog keeps at most 64 steps and 4 MiB of them, always keeping the newest step. Tests: `undo_and_redo_changes_step_through_the_dialogs_own_edits`, `a_drag_is_one_step_of_undo_changes`, `undo_changes_reverses_reset`, `the_recolor_undo_and_redo_commands_step_the_open_dialog`, `the_recolor_undo_and_redo_commands_preview_the_step`, `an_edit_with_the_pointer_down_from_the_first_frame_is_a_step` and `rows_and_weights_set_before_the_art_is_read_are_no_step` in `crates/ui-egui/src/tests/recolor.rs`, and `undo_changes_keeps_a_bounded_history` and `another_group_or_save_changes_leaves_nothing_to_undo` and `an_edit_right_after_another_group_is_a_step` and `an_unchanged_save_changes_leaves_nothing_to_redo` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged. - - **Recolor Artwork: a swatch picked for a row stays that swatch:** a row's new color is changed in the Color Picker ([Assign new colors to selected artworks](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/assign-new-colors-to-selected-artwork.html)), Scale Tints gives a row's lighter current colors lighter tints of its new color, and Preserve Tints gives a spot or global current color's tint to the new color ([CS5 help, Colorize Method](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=151), [2021 reference, Colorize Method](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=252)). VectorCraft's own rule: a spot or global swatch picked in the Color Picker's swatch list stays that swatch, so the row's art takes tints of it linked to it, also with no Limit to Library, and editing the swatch recolors the art; a process swatch gives its color as before, the row drops the swatch when its new color changes, and a swatch deleted after the pick links nothing. `recolor.apply` rows take `swatch: {name, library?}`. Tests: `a_swatch_picked_for_a_row_links_the_art_to_it_without_a_library` in `crates/ui-egui/src/tests/recolor.rs`, `a_picked_spot_swatch_gives_its_row_the_tint_slider` and `a_picked_swatch_that_is_gone_links_nothing` in `crates/ui-egui/src/dialogs/recolor.rs`, and `a_rows_swatch_links_its_art_without_limit_to_library`, `a_rows_swatch_with_a_finer_color_than_its_key_still_links` and `a_rows_library_swatch_joins_the_document_and_a_process_swatch_changes_nothing` in `crates/engine/src/tests/recolor.rs`. Scores and estimates unchanged. + - **Recolor Artwork: a swatch picked for a row stays that swatch:** a row's new color is changed in the Color Picker ([Assign new colors to selected artworks](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/assign-new-colors-to-selected-artwork.html)), Scale Tints gives a row's lighter current colors lighter tints of its new color, and Preserve Tints gives a spot or global current color's tint to the new color ([CS5 help, Colorize Method](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=151), [2021 reference, Colorize Method](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=252)). VectorCraft's own rule: a spot or global swatch picked in the Color Picker's swatch list stays that swatch, so the row's art takes tints of it linked to it, also with no Limit to Library, and editing the swatch recolors the art; a process swatch gives its color as before, the row drops the swatch when its new color changes, and a swatch deleted after the pick links nothing, nor does a global swatch of the color group being rewritten that takes another color, and with Limit to Library the library's swatch of that color is used instead. `recolor.apply` rows take `swatch: {name, library?}`. Tests: `a_swatch_picked_for_a_row_links_the_art_to_it_without_a_library`, `a_process_library_swatch_hides_the_tint_of_a_rows_own_spot_swatch`, `a_rows_spot_swatch_rewritten_with_another_color_shows_no_tint`, `a_library_spot_swatch_rewritten_with_another_color_shows_no_tint` and `a_library_swatch_named_like_a_rewritten_group_swatch_keeps_its_tint` in `crates/ui-egui/src/tests/recolor.rs`, `a_picked_spot_swatch_gives_its_row_the_tint_slider`, `a_picked_swatch_that_is_gone_links_nothing` and `a_picked_swatch_the_group_rewrites_shows_the_full_color` in `crates/ui-egui/src/dialogs/recolor.rs`, and `a_rows_swatch_links_its_art_without_limit_to_library`, `a_rows_swatch_with_a_finer_color_than_its_key_still_links`, `a_rows_swatch_in_the_rewritten_group_keeps_the_rows_new_color` and `a_rows_library_swatch_joins_the_document_and_a_process_swatch_changes_nothing` in `crates/engine/src/tests/recolor.rs`. Scores and estimates unchanged. - **Edit Colors parameters:** `edit.colors.saturate` needs a number `intensity`, the value from -100% to 100% that Saturate takes ([Adjusting colors](https://web.archive.org/web/20230128232631/https://helpx.adobe.com/illustrator/using/adjusting-colors.html)), and answers "missing number `intensity`" without one; a number outside the range counts as its nearest end. A value that is not a number, such as `"40"`, is refused with `` `intensity` must be a number, not "40" ``, as in every command that needs a number (`tests::params::a_malformed_required_number_is_not_reported_as_missing`). `edit.colors.adjustBalance` refuses a channel and `color.harmony` refuses `steps` or `amount` that is not a number; both read `null` as a value left out. `tests::editcolors` and `tests::colorguide` cover them. - **Convert to Indexed Color:** Edit › Edit Colors › Convert to Indexed Color… (`edit.colors.toIndexed`) stores the embedded images in the selection as indexed-color PNGs of at most 256 colors. The palette is chosen as for a PNG-8 export, as evenly spaced levels of red, green and blue, or from the document's swatches, with diffusion, pattern or noise dithering; pixels under half opacity become transparent. The dialog previews live, and OK is one undo step. This is VectorCraft's own command and counts toward no score. `tests::editcolors` and `encode::tests_palette` cover it. Scores and estimates unchanged. - **Working RGB numeric controls:** the Color panel and Color Picker read RGB, HSB, hex and Web Safe RGB values in the active working RGB space. Editing one RGB channel preserves the other native channels, including colors outside display sRGB. Regressions cover sRGB, Display P3, Wide Gamut RGB and ProPhoto RGB, picker initialization, native numeric round trips, and a slider click with one Undo step. Scores and estimates unchanged.