From 5625781b4c12fa63f2ed247abfb706dc2802b728 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:57:54 -0800 Subject: [PATCH] Recolor Artwork: pin craft-web-api and pdf-deps to the workspace craft-libs revision - apps/vectorcraft-web pins craft-web-api to aa7e668e, the craft-libs revision the workspace uses, and xtask pdf-deps checks the patched PDF crates against that revision, so `cargo xtask pdf-deps` passes again. - The new color chip takes the Global Adjust without Limit to Library too, as recolor.apply gives the art; an excluded row's chip keeps its color. - OK in a dialog without artwork reports no missing swatch links, since it sends no artwork map. - The MCP guide and the progress line say when a picked swatch stays linked. - The tint test requires darker grays to take strictly higher tints. --- Cargo.lock | 2 +- apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/dialogs/recolor.rs | 46 +++++++++++++++++++++++++-- crates/ui-egui/src/tests/recolor.rs | 2 +- docs/mcp.md | 3 +- docs/target-app-parity.md | 2 +- xtask/src/pdf_deps.rs | 2 +- 7 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c83657f076..f229c9e792 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2361,7 +2361,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=186a229c8da8db5916f8a863dfd894f1879af735#186a229c8da8db5916f8a863dfd894f1879af735" +source = "git+https://github.com/storytold/craft-libs?rev=aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b#aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b" dependencies = [ "js-sys", "serde_json", diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index ce4d1d3d44..0a3a273fcc 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "186a229c8da8db5916f8a863dfd894f1879af735", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index e5cac5ad8b..1bd96add15 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -2600,15 +2600,17 @@ fn spot_tinted(app: &VectorcraftApp, c: Color, t: f32) -> Color { /// of the library as [`spot_tinted`] shows it). fn new_shown(app: &VectorcraftApp, d: &Fields, links: &RowLinks, row: &Value) -> Color { let to = to_color(row).unwrap_or_default(); + // `recolor.apply` skips an excluded row, so without a library its chip takes no Global Adjust. + let effective = if excluded(row) && links.library.is_none() { to } else { links.effective_color(&to) }; if d.bool("__art") && let Some(c) = linked_spot(app, d, links, row, &to).and_then(|w| w.paint.color()) { spot_tinted(app, c, row_tint(row)) } else if row_tint(row) < 1.0 && tint_applies(app, d, links, row, &to) { - links.effective_color(&to).tinted(row_tint(row)) + effective.tinted(row_tint(row)) } else { // The swatch the tint was for no longer links the art, which takes the full color. - links.effective_color(&to) + effective } } @@ -2702,8 +2704,11 @@ impl RowLinks { Self { library, adjust: global_adjust(adjust_values(d)), rewritten } } + /// The color `recolor.apply` gives the art for new color `c`: `c` after the Global Adjust, + /// then the nearest Limit to Library color when a library is set. fn effective_color(&self, c: &Color) -> Color { - self.library.as_ref().map_or(*c, |(palette, _)| palette.nearest(self.adjust.apply(*c))) + let adjusted = self.adjust.apply(*c); + self.library.as_ref().map_or(adjusted, |(palette, _)| palette.nearest(adjusted)) } /// The library swatch (Limit to Library) that `recolor.apply` gives new color `c`: the first @@ -2832,6 +2837,10 @@ fn row_swatch(app: &VectorcraftApp, row: &Value, c: &Color) -> Option Vec { let mut names: Vec = Vec::new(); + // Without artwork, OK sends no artwork map, so no art links to a row's swatch. + if !d.bool("__art") { + return names; + } for r in rows(d).iter().filter(|r| !excluded(r) && !no_current(r) && to_color(r).is_some()) { let Some((name, lib)) = swatch_ref(r) else { continue }; let there = limit_swatches(app, lib).is_some_and(|l| l.iter().any(|w| w.name == name)); @@ -4752,10 +4761,41 @@ mod tests { ])); let mut d = rc.fields(); assert_eq!(swatches_not_found(&rc.app(), &d), vec!["Missing Ink"]); + // A dialog without artwork links nothing, so it reports nothing either. + d.fields.insert("__art".into(), json!(false)); + assert!(swatches_not_found(&rc.app(), &d).is_empty()); + d.fields.insert("__art".into(), json!(true)); d.fields.insert("rows".into(), json!([{"from": [], "to": "cmyk 0 100 0 0", "swatch": {"name": "Unused Ink"}}])); assert!(swatches_not_found(&rc.app(), &d).is_empty()); } + /// Without Limit to Library, the color the art takes (and the new color chip shows) is the new + /// color after the Global Adjust, as `recolor.apply` gives it; with no adjustment it is the new + /// color itself. + #[test] + fn the_effective_color_takes_the_global_adjust_without_a_library() { + let red = Color::rgb(1.0, 0.0, 0.0); + let darker = RowLinks { library: None, adjust: global_adjust([0.0, -50.0, 0.0, 0.0]), rewritten: Vec::new() }; + assert_eq!(darker.effective_color(&red), darker.adjust.apply(red)); + assert_ne!(darker.effective_color(&red), red, "brightness -50 darkens the color"); + let plain = RowLinks { library: None, adjust: global_adjust([0.0; 4]), rewritten: Vec::new() }; + assert_eq!(plain.effective_color(&red), red); + } + + /// Without a library, an excluded row's chip keeps its new color under a Global Adjust, since + /// `recolor.apply` leaves its art as it is. + #[test] + fn excluded_new_chips_keep_their_color_under_global_adjust() { + let app = app(100); + let d = Fields::new(json!({"globalAdjust": {"brightness": -50}})); + let mut row = json!({"from": ["rgb 255 0 0"], "to": "rgb 255 0 0"}); + let links = RowLinks::new(&app, &d); + let red = to_color(&row).unwrap(); + assert_ne!(new_shown(&app, &d, &links, &row), red); + row["exclude"] = json!(true); + assert_eq!(new_shown(&app, &d, &links, &row), red); + } + /// 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. diff --git a/crates/ui-egui/src/tests/recolor.rs b/crates/ui-egui/src/tests/recolor.rs index 12c1d7da0c..b32a5d0769 100644 --- a/crates/ui-egui/src/tests/recolor.rs +++ b/crates/ui-egui/src/tests/recolor.rs @@ -1707,7 +1707,7 @@ fn a_swatch_picked_for_a_row_links_the_art_to_it_without_a_library() { for &j in &inked { let (li, lj) = (mid_gray(&before[i].1).unwrap_or(0.0), mid_gray(&before[j].1).unwrap_or(0.0)); if li < lj - 0.02 { - assert!(after[i].3 >= after[j].3, "{kind}: paint {i} is darker than {j} and at a higher tint"); + assert!(after[i].3 > after[j].3, "{kind}: paint {i} is darker than {j} and at a higher tint"); } } } diff --git a/docs/mcp.md b/docs/mcp.md index 5fb0375d25..c80b69db1e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6834,7 +6834,8 @@ deleted after it was picked), links nothing, and the row recolors as its new col 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 +picked from a global or spot swatch in the Color Picker's swatch list in Recolor Artwork carries it when the dialog +has art and no earlier solid swatch (other than a linked tint) in the same library has the same name and color, 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` moves a row's `tint` and `swatch` with its new color and removes them from a color it changes, and moves a row's `model` with its new color. `swatch.editGroup {group, colors, rename?}` rewrites a colour group in one undo diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 23a47c70f5..50e50869b9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2194,7 +2194,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, 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. + - **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 for a row of the selected art stays that swatch, unless an earlier solid swatch (other than a linked tint) in the same library has the same name and color, 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. diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index f4f02f8627..d69afcd0a8 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "186a229c8da8db5916f8a863dfd894f1879af735"; +const REV: &str = "aa7e668ec6e2f2b723de34dceeb7d756f5ff9f4b"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV),