Recolor Artwork: Edit tab right-click menus set the base color, pick a shade and add colors

A right-click on a wheel marker or a color bar offers Set As Base Color,
Select Shade (a 7 by 7 grid of the color's hue), Color Picker and Remove
Color. A right-click elsewhere on the wheel offers Add New Color, and a
color added on a marker's line moves with that marker while the colors
are unlinked. Set Current Color As Base Color makes the selected color
the base.

The base color is stored on its row (`base: true`) instead of being the
first selected row, so the harmony rules build from it whichever color
is selected for the sliders. Merge, Separate, Randomize and Prominent
Colors keep the marks, and the rows sent to `recolor.apply` leave them
out.
This commit is contained in:
dotCooCoo committed 2026-11-15 09:07:57 -08:00
1 parent a6b73c467d
commit c0550a00a7
34 files changed
+812 -51

No files matched your search

+467 -36
View File
@@ -27,7 +27,14 @@
//! Remove Color tool removes the color whose marker is clicked; a bar's right-click menu has Remove
//! Color too. The base color can't be removed. A removed color's row goes, unless it has current
//! colors and art or a group is open: it then keeps them, with no new color, so that art keeps its
//! colors and the group's swatch at that place goes. With art, the Prominent Colors bar under the wheel shows the new
//! colors and the group's swatch at that place goes. The base color is the one the harmony rules
//! build from, drawn with the larger marker; it stays the base when another color is selected for
//! the sliders. A right-click on a marker or a color bar offers Set As Base Color, Select Shade (a
//! grid of the color's hue at 7 saturations by 7 brightnesses; a click moves the marker there as a
//! drag would), Color Picker and Remove Color; a right-click elsewhere on the wheel offers Add New
//! Color, which adds the hue and saturation there as the Add Color tool does, and a color added on
//! the line from the centre to a marker moves with that marker when the colors are unlinked. Set
//! Current Color As Base Color, before the color chips, makes the selected color the base. With art, the Prominent Colors bar under the wheel shows the new
//! colors, each part as wide as its row's share of the art's uses, the largest first; dragging the
//! edge between two parts moves width between them, and when the drag ends the rows' current
//! colors move toward those widths (`recolor.weigh`), and the art previews them. The New Color
@@ -48,7 +55,10 @@
//!
//! Fields (`ui.dialog.set`): `rows` ([{from: [keys], to: key, exclude?, tint?: percent of a spot
//! color, added?}]; a row with no current colors, `from: []`, recolors no art, and with `added: true`
//! (a color the Add Color tool added) adds its new color to the color group; `to: null`, no new color), `colors` (null: Auto, or a count), `method`, `preserveWhite`, `preserveBlack`,
//! (a color the Add Color tool added) adds its new color to the color group; `to: null`, no new color;
//! `base: true`, the base color, else the first color the Edit tab shows; `tie: n` on a marker and
//! `follows: n` on a color added on its line, which moves with it; the dialog sends `recolor.apply`
//! the rows without these three), `colors` (null: Auto, or a count), `method`, `preserveWhite`, `preserveBlack`,
//! `preserveGrays`, `limitTo` (library id, "document" for the document's swatches, "" for none),
//! `group`, `groupName`, `tab` (`assign` or `edit`), `rule` (harmony id), `linked`, `preview`,
//! `sliderMode` (`hsb`, `rgb`, `cmyk`, `lab` or `tint`; unset: the row color's own model, HSB for
@@ -280,7 +290,9 @@ fn sync_weights(app: &mut VectorcraftApp, d: &mut Dialog) {
match app.session.execute("recolor.weigh", &json!({"map": rows(d), "weights": w})) {
Ok(r) => {
if let Some(m) = r["map"].as_array() {
d.fields.insert("rows".into(), Value::Array(m.clone()));
let mut m = m.clone();
keep_marks(&rows(d), &mut m);
d.fields.insert("rows".into(), Value::Array(m));
}
}
Err(e) => app.status(e.to_string()),
@@ -599,8 +611,10 @@ fn apply_params(d: &Dialog) -> Value {
let rename = (!name.trim().is_empty() && name != g).then_some(name);
json!({"group": g, "groupColors": colors, "rename": rename})
});
// A row edited with the sliders carries `model: "new"`: its art takes the mode they showed.
let mut p = json!({"map": rs, "method": d.str("method"), "limitTo": d.str("limitTo")});
// A row edited with the sliders carries `model: "new"`: its art takes the mode they showed. The
// Edit tab's own marks (the base color, colors tied to a marker) stay in the dialog.
let map: Vec<Value> = rs.iter().map(without_marks).collect();
let mut p = json!({"map": map, "method": d.str("method"), "limitTo": d.str("limitTo")});
// The Global Adjust amounts, kept while the sliders show another mode; at 0% they are left out.
let values = adjust_values(d);
if values.iter().any(|v| *v != 0.0) {
@@ -647,7 +661,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog) -> bool {
}
let mut rs = rows(d);
let top = ui.cursor().top();
let (changed, pick) = if d.str("tab") == "edit" { (edit_tab(app, ui, d, &mut rs), None) } else { assign_tab(app, ui, d, &mut rs) };
let (changed, pick) = if d.str("tab") == "edit" { edit_tab(app, ui, d, &mut rs) } else { assign_tab(app, ui, d, &mut rs) };
if d.str("tab") != "edit" {
ui.add_space((TAB_H - (ui.cursor().top() - top)).max(0.0));
}
@@ -892,7 +906,9 @@ fn assign_tab(app: &mut VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut
let p = json!({"map": rows, "order": !sb, "saturationBrightness": sb, "seed": seed});
match app.session.execute("recolor.randomize", &p) {
Ok(r) => {
*rows = r["map"].as_array().cloned().unwrap_or_default();
let mut shuffled = r["map"].as_array().cloned().unwrap_or_default();
keep_marks(rows, &mut shuffled);
*rows = shuffled;
if !sb {
d.fields.insert(SHUFFLED.into(), json!(true));
}
@@ -1244,6 +1260,21 @@ fn merge(rows: &mut Vec<Value>, sel: &[usize]) {
for &i in rest.iter().rev() {
let row = rows.remove(i);
moved.splice(0..0, row["from"].as_array().cloned().unwrap_or_default());
// The base color merged into another row makes that row the base, and the colors that
// followed the merged row's marker follow that row's.
if row[BASE] == json!(true) {
rows[first][BASE] = json!(true);
}
if let Some(t) = row[TIE].as_u64() {
match rows[first][TIE].as_u64() {
Some(to) => {
for r in rows.iter_mut().filter(|r| r[FOLLOWS].as_u64() == Some(t)) {
r[FOLLOWS] = json!(to);
}
}
None => rows[first][TIE] = json!(t),
}
}
}
if let Some(dst) = rows[first]["from"].as_array_mut() {
dst.extend(moved);
@@ -1255,7 +1286,17 @@ fn separate(rows: &mut Vec<Value>, sel: &[usize]) {
let mut out = vec![];
for (i, row) in rows.drain(..).enumerate() {
match row["from"].as_array() {
Some(a) if sel.contains(&i) && a.len() > 1 => out.extend(a.iter().map(|k| json!({"from": [k], "to": k}))),
Some(a) if sel.contains(&i) && a.len() > 1 => {
let at = out.len();
out.extend(a.iter().map(|k| json!({"from": [k], "to": k})));
// A separated row's marks (the base color, a marker's tie, a color it follows) go
// to the row of its first color.
for k in [BASE, TIE, FOLLOWS] {
if let Some(v) = row.get(k) {
out[at][k] = v.clone();
}
}
}
_ => out.push(row),
}
}
@@ -1278,13 +1319,29 @@ fn active_rows(rows: &[Value]) -> Vec<usize> {
}
/// Set row `i`'s new colour to hue/saturation/brightness `hsb` ([`move_on_wheel`]: with `linked`
/// the other rows keep their relation to it). Excluded rows stay.
/// the other rows keep their relation to it; unlinked, the colors added on its marker's line, which
/// follow its `tie`, and those that follow theirs, keep theirs). Excluded rows stay.
fn move_color(rows: &mut [Value], i: usize, hsb: [f32; 3], linked: bool) {
let active = active_rows(rows);
let all = active_rows(rows);
let active: Vec<usize> = if linked {
all
} else {
// Row `i` and the rows that follow it, directly or through another follower.
let mut moving = vec![i];
let mut n = 0;
while let Some(&j) = moving.get(n) {
if let Some(t) = rows.get(j).and_then(|r| r[TIE].as_u64()) {
let next: Vec<usize> = all.iter().copied().filter(|&k| rows[k][FOLLOWS].as_u64() == Some(t) && !moving.contains(&k)).collect();
moving.extend(next);
}
n += 1;
}
all.into_iter().filter(|j| moving.contains(j)).collect()
};
let Some(k) = active.iter().position(|&j| j == i) else { return };
let before: Vec<Color> = active.iter().filter_map(|&j| to_color(&rows[j])).collect();
let mut colors = before.clone();
move_on_wheel(&mut colors, k, hsb, linked);
move_on_wheel(&mut colors, k, hsb, true);
for ((&j, c), old) in active.iter().zip(&colors).zip(&before) {
if key(c) != key(old) {
set_to(&mut rows[j], c);
@@ -1299,8 +1356,8 @@ const DRAG: &str = "__drag";
const WHEEL_TOOL: &str = "wheelTool";
/// The new color the Add Color tool gives a click at hue `h` (degrees) and saturation `s`: at the
/// brightness of `base` (the base color, whose brightness the wheel shows; full without one), the
/// segmented wheel's patch color with `segmented`, in `base`'s model.
/// brightness of `base` (the selected color, whose brightness the wheel shows; full without one),
/// the segmented wheel's patch color with `segmented`, in `base`'s model.
fn added_color(base: Option<Color>, h: f32, s: f32, segmented: bool) -> Color {
let v = base.map_or(1.0, |b| b.to_hsb()[2]);
let c = if segmented { widgets::segment_color(h, s, v) } else { Color::from_hsb(h, s, v) };
@@ -1348,14 +1405,221 @@ fn removed(d: &mut Dialog, base: usize) {
d.fields.remove(COMPS);
}
/// The Edit tab. Returns true when the rows changed.
fn edit_tab(app: &VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Value>) -> bool {
/// A row's mark as the base color, the color the harmony rules build from (`true`).
const BASE: &str = "base";
/// A row's number on a marker that the colors added on its line follow.
const TIE: &str = "tie";
/// A row's mark as a color added on a marker's line: the marker's `tie`, which it moves with.
const FOLLOWS: &str = "follows";
/// The target of the wheel's right-click menu: `{marker, line, hs}` (row indexes and the hue and
/// saturation clicked).
const MENU_AT: &str = "__wheelMenu";
/// Select Shade's grid: saturations across, from 0% to 100%, and brightnesses down, from 100%.
const SHADE_COLS: usize = 7;
const SHADE_ROWS: usize = 7;
const SHADE_CELL: f32 = 16.0;
/// The base color's row: the row of `active` (the rows the Edit tab shows) marked `base`, else
/// the first of them.
fn base_row(rows: &[Value], active: &[usize]) -> Option<usize> {
active.iter().copied().find(|&i| rows[i][BASE] == json!(true)).or(active.first().copied())
}
/// Whether Set As Base Color would change anything for row `i`: it is shown on the Edit tab, and it
/// isn't the base already, or it is the base only because the marked row is hidden (excluded, or
/// with no new color), whose mark would make it the base again once shown.
fn can_set_base(rows: &[Value], i: usize) -> bool {
let active = active_rows(rows);
active.contains(&i) && (base_row(rows, &active) != Some(i) || rows.iter().enumerate().any(|(k, r)| k != i && r[BASE] == json!(true)))
}
/// Make row `i` the base color (Set As Base Color). Returns false when that changes nothing
/// ([`can_set_base`]).
fn set_base(rows: &mut [Value], i: usize) -> bool {
if !can_set_base(rows, i) {
return false;
}
for r in rows.iter_mut() {
if let Some(o) = r.as_object_mut() {
o.remove(BASE);
}
}
rows[i][BASE] = json!(true);
true
}
/// Make row `follower` move with the marker of row `leader`: the leader keeps its `tie` (a new
/// number, past every `tie` and `follows`, when it has none, so that colors left from a removed
/// marker follow no other) and the follower takes it as `follows`.
fn tie_to(rows: &mut [Value], leader: usize, follower: usize) {
if leader == follower || leader >= rows.len() || follower >= rows.len() {
return;
}
let used = rows.iter().flat_map(|r| [r[TIE].as_u64(), r[FOLLOWS].as_u64()]).flatten().max();
let t = rows[leader][TIE].as_u64().unwrap_or_else(|| used.map_or(1, |m| m.saturating_add(1)));
rows[leader][TIE] = json!(t);
rows[follower][FOLLOWS] = json!(t);
}
/// Give each row of `after` the base, tie and follows marks of the row at its place in `before`,
/// when the two have as many rows (the engine's `recolor.randomize` and `recolor.weigh` keep the
/// rows in order and return them without the dialog's own marks).
fn keep_marks(before: &[Value], after: &mut [Value]) {
if before.len() != after.len() {
return;
}
for (a, b) in after.iter_mut().zip(before) {
for k in [BASE, TIE, FOLLOWS] {
if a.get(k).is_none()
&& let Some(v) = b.get(k)
{
a[k] = v.clone();
}
}
}
}
/// `row` without the dialog's base, tie and follows marks.
fn without_marks(row: &Value) -> Value {
let mut r = row.clone();
if let Some(o) = r.as_object_mut() {
for k in [BASE, TIE, FOLLOWS] {
o.remove(k);
}
}
r
}
/// The saturation and brightness of Select Shade's cell in column `col` and row `row`.
fn shade_at(col: usize, row: usize) -> [f32; 2] {
[col as f32 / (SHADE_COLS - 1) as f32, 1.0 - row as f32 / SHADE_ROWS as f32]
}
/// Select Shade's grid of `c`'s hue, the cell nearest `c` framed. Returns the saturation and
/// brightness of the cell clicked.
fn shade_grid(ui: &mut Ui, c: &Color) -> Option<[f32; 2]> {
let t = Tokens::get(ui.ctx());
let [h, s0, v0] = c.to_hsb();
let near = ((s0 * (SHADE_COLS - 1) as f32).round() as usize, (((1.0 - v0) * SHADE_ROWS as f32).round() as usize).min(SHADE_ROWS - 1));
let mut out = None;
egui::Grid::new("recolor-shades").spacing([2.0, 2.0]).show(ui, |ui| {
for row in 0..SHADE_ROWS {
for col in 0..SHADE_COLS {
let [s, v] = shade_at(col, row);
let (r, resp) = ui.allocate_exact_size(vec2(SHADE_CELL, SHADE_CELL), Sense::click());
ui.painter().rect_filled(r, 1.0, c32(&Color::from_hsb(h, s, v)));
if (col, row) == near {
ui.painter().rect_stroke(r, 1.0, egui::Stroke::new(1.5, t.accent), egui::StrokeKind::Outside);
}
let name = format!("{} {}%, {} {}%", tl!("Saturation"), (s * 100.0).round(), tl!("Brightness"), (v * 100.0).round());
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &name));
if resp.clicked() {
out = Some([s, v]);
ui.close();
}
}
ui.end_row();
}
});
out
}
/// What a marker's or a color bar's right-click menu, or the wheel's, chose.
enum MenuChoice {
/// Set As Base Color for the row.
Base(usize),
/// Select Shade: the row's color at this saturation and brightness.
Shade(usize, [f32; 2]),
/// Color Picker for the row.
Picker(usize),
/// Remove Color for the row.
Remove(usize),
/// Add New Color at this hue and saturation, moving with the marker of the row on whose line
/// it is.
Add([f32; 2], Option<usize>),
}
/// A marker's or a color bar's right-click menu for row `i`: Set As Base Color and Remove Color
/// (neither for the base color `base`), Select Shade and Color Picker.
fn color_menu(ui: &mut Ui, rows: &[Value], i: usize, base: Option<usize>) -> Option<MenuChoice> {
let mut choice = None;
if widgets::menu_item_name(ui, tl!("Set As Base Color"), can_set_base(rows, i), false) {
choice = Some(MenuChoice::Base(i));
}
if let Some(c) = rows.get(i).and_then(to_color) {
// Indented like the items beside it (their check column).
ui.menu_button(format!(" {}", tl!("Select Shade")), |ui| {
if let Some(sv) = shade_grid(ui, &c) {
choice = Some(MenuChoice::Shade(i, sv));
}
});
}
if widgets::menu_item_name(ui, tl!("Color Picker"), true, false) {
choice = Some(MenuChoice::Picker(i));
}
if widgets::menu_item_name(ui, tl!("Remove Color"), Some(i) != base, false) {
choice = Some(MenuChoice::Remove(i));
}
choice
}
/// Carry out a right-click menu's `choice` on the rows (`base`: the base color's row; `shown`: the
/// color whose brightness the wheel shows; `segmented`: the menu was on the segmented wheel).
/// Returns whether the rows changed and the row whose new color the Color Picker is to edit.
fn choose(
d: &mut Dialog,
rows: &mut Vec<Value>,
choice: MenuChoice,
base: Option<usize>,
shown: Option<Color>,
segmented: bool,
) -> (bool, Option<usize>) {
match choice {
MenuChoice::Base(i) => (set_base(rows, i), None),
MenuChoice::Shade(i, [s, v]) => {
let Some(h) = rows.get(i).and_then(to_color).map(|c| c.to_hsb()[0]) else { return (false, None) };
let before = rows.clone();
move_color(rows, i, [h, s, v], d.bool("linked"));
d.fields.insert("__sel".into(), json!([i]));
d.fields.remove(COMPS);
(*rows != before, None)
}
MenuChoice::Picker(i) => {
d.fields.insert("__sel".into(), json!([i]));
(false, Some(i))
}
MenuChoice::Remove(i) => match remove_color(rows, i, base, keeps_rows(d)) {
Some(b) => {
removed(d, b);
(true, None)
}
None => (false, None),
},
MenuChoice::Add([h, s], line) => {
let i = add_color(rows, &added_color(shown, h, s, segmented));
if let Some(l) = line {
tie_to(rows, l, i);
}
d.fields.insert("__sel".into(), json!([i]));
d.fields.remove(COMPS);
(true, None)
}
}
}
/// The Edit tab. Returns whether the rows changed and the row whose new color a right-click menu's
/// Color Picker is to edit.
fn edit_tab(app: &VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Value>) -> (bool, Option<usize>) {
let top = ui.cursor().top();
let t = Tokens::get(ui.ctx());
let mut changed = false;
let mut pick = None;
let linked = d.bool("linked");
let active = active_rows(rows);
let base = selection(d).into_iter().find(|i| active.contains(i)).or(active.first().copied());
// The harmony rules build from the base color; the sliders and the Brightness slider edit the
// selected color (the base color when none is selected).
let base = base_row(rows, &active);
let sel = selection(d).into_iter().find(|i| active.contains(i)).or(base);
let target = SliderTarget::of(app, d, rows);
ui.horizontal(|ui| {
ui.label(egui::RichText::new(tl!("Harmony Rules:")).color(t.text_dim));
@@ -1401,6 +1665,9 @@ fn edit_tab(app: &VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Va
}
let colors: Vec<Color> = active.iter().filter_map(|&i| to_color(&rows[i])).collect();
let marked = base.and_then(|b| active.iter().position(|&i| i == b));
let selected = sel.and_then(|s| active.iter().position(|&i| i == s));
let shown = sel.and_then(|s| to_color(&rows[s]));
let mut choice = None;
let display = d.str("display");
let tool = d.str(WHEEL_TOOL);
// The tools act on either wheel, not on the color bars.
@@ -1429,16 +1696,56 @@ fn edit_tab(app: &VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Va
}
});
ui.vertical(|ui| match display.as_str() {
"segmented" => w = widgets::segmented_wheel(ui, "recolor-wheel", WHEEL, &colors, marked),
"bars" => changed |= color_bars(ui, d, rows, &active, base),
_ => w = widgets::harmony_wheel(ui, "recolor-wheel", WHEEL, &colors, marked),
"bars" => {
let (moved, chosen) = color_bars(ui, d, rows, &active, base);
changed |= moved;
choice = chosen;
}
_ => w = widgets::recolor_wheel(ui, "recolor-wheel", WHEEL, &colors, marked, selected, display == "segmented"),
});
});
// A right-click on the wheel: a marker's menu, or Add New Color elsewhere. Its target is kept
// while the menu stays open.
if let Some((hit, line, hs)) = w.secondary {
d.fields.insert(MENU_AT.into(), json!({"marker": hit.map(|k| active[k]), "line": line.map(|k| active[k]), "hs": hs}));
} else if w.response.as_ref().is_some_and(egui::Response::secondary_clicked) {
// A right-click off the wheel (in a corner of its square) targets nothing: its menu's Add
// New Color is off, and no earlier marker is changed.
d.fields.remove(MENU_AT);
}
if let Some(resp) = &w.response {
let at = d.fields.get(MENU_AT).cloned().unwrap_or_default();
let row = |k: &str| at[k].as_u64().map(|i| i as usize).filter(|i| active.contains(i));
let hs = at["hs"].as_array().and_then(|a| Some([a.first()?.as_f64()? as f32, a.get(1)?.as_f64()? as f32]));
resp.context_menu(|ui| match row("marker") {
Some(i) => choice = color_menu(ui, rows, i, base),
None => {
if widgets::menu_item_name(ui, tl!("Add New Color"), hs.is_some(), false)
&& let Some(hs) = hs
{
choice = Some(MenuChoice::Add(hs, row("line")));
}
}
});
}
// A menu's choice changes the rows the wheel's indexes were for, so the wheel's own clicks and
// drags of this frame are left alone.
let chosen = choice.is_some();
if let Some(c) = choice {
let (did, picked) = choose(d, rows, c, base, shown, display == "segmented");
changed |= did;
pick = picked;
}
if chosen {
w.pressed = None;
w.moved = None;
w.clicked = None;
}
// A click with a wheel tool adds a color there, or removes the color of the marker clicked.
let clicked = w.clicked.filter(|_| on_wheel && matches!(tool.as_str(), "add" | "remove"));
if let Some((hit, [h, s])) = clicked {
if tool == "add" {
let c = added_color(base.and_then(|b| to_color(&rows[b])), h, s, display == "segmented");
let c = added_color(shown, h, s, display == "segmented");
let i = add_color(rows, &c);
d.fields.insert("__sel".into(), json!([i]));
d.fields.remove(COMPS);
@@ -1482,43 +1789,57 @@ fn edit_tab(app: &VectorcraftApp, ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Va
}
// A color added or removed above changed the rows, so the sliders and chips read them afresh.
let active = active_rows(rows);
let base = selection(d).into_iter().find(|i| active.contains(i)).or(active.first().copied());
let base = base_row(rows, &active);
let sel = selection(d).into_iter().find(|i| active.contains(i)).or(base);
if d.str("sliderMode") == GLOBAL {
let sample = base.and_then(|b| to_color(&rows[b])).unwrap_or(Color::rgb(0.8, 0.45, 0.25));
let sample = sel.and_then(|b| to_color(&rows[b])).unwrap_or(Color::rgb(0.8, 0.45, 0.25));
global_sliders(ui, d, sample);
} else {
changed |= sliders(app, ui, d, rows);
}
// The new colours: click one to make it the base colour.
// The new colours: click one to select it; Set Current Color As Base Color, before them, makes
// the selected one the base color, which carries a double ring as its marker does.
let min_height = (TAB_H - (ui.cursor().top() - top)).max(0.0);
let mut make_base = None;
super::modal::scrolled_rows(ui, "recolor-edit-colors", |ui| {
// Keep the usual tab height when it fits; the empty space scrolls with the chips.
ui.set_min_height(min_height);
ui.horizontal_wrapped(|ui| {
let can = sel.is_some_and(|s| can_set_base(rows, s));
if widgets::icon_button_enabled(ui, "circle-dot", tl!("Set Current Color As Base Color"), false, can, 20.0).clicked() {
make_base = sel;
}
for &i in &active {
let (r, resp) = ui.allocate_exact_size(vec2(28.0, 20.0), Sense::click());
chip(ui, r, to_color(&rows[i]).unwrap_or_default(), false);
if Some(i) == base {
if Some(i) == sel {
ui.painter().rect_stroke(r.expand(1.5), 2.0, egui::Stroke::new(1.5, t.accent), egui::StrokeKind::Outside);
}
if Some(i) == base {
ui.painter().circle_stroke(r.center(), 4.0, egui::Stroke::new(1.5, egui::Color32::WHITE));
ui.painter().circle_stroke(r.center(), 5.5, egui::Stroke::new(1.0, egui::Color32::BLACK));
}
if resp.on_hover_text(rows[i]["to"].as_str().unwrap_or_default()).clicked() {
d.fields.insert("__sel".into(), json!([i]));
}
}
});
});
changed
if let Some(i) = make_base {
changed |= set_base(rows, i);
}
(changed, pick)
}
/// The Edit tab's color bars: a solid bar per row of `active` with its new color, in row order, the
/// base row's framed, scrolling past the wheel's height. A click on a bar selects its row (the
/// sliders under it edit that row's new color); a drag moves the bar's row to where the line under
/// the pointer shows, keeping every new color. A bar's right-click menu has Remove Color (not for the
/// base row's). Returns true when the rows moved or a color was removed.
fn color_bars(ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Value>, active: &[usize], base: Option<usize>) -> bool {
/// the pointer shows, keeping every new color. A bar's right-click menu is a marker's
/// ([`color_menu`]). Returns true when the rows moved, and the menu's choice.
fn color_bars(ui: &mut Ui, d: &mut Dialog, rows: &mut [Value], active: &[usize], base: Option<usize>) -> (bool, Option<MenuChoice>) {
let t = Tokens::get(ui.ctx());
let mut rects: Vec<Rect> = Vec::with_capacity(active.len());
let (mut dragging, mut released, mut dropped, mut remove) = (None, None, None, None);
let (mut dragging, mut released, mut dropped, mut choice) = (None, None, None, None);
// The area is given its full height first: in the row beside the display buttons a scroll area
// alone is only as tall as the room the row has.
let area = vec2(ui.available_width(), BARS_H);
@@ -1551,8 +1872,8 @@ fn color_bars(ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Value>, active: &[usiz
rects.push(r);
let resp = resp.on_hover_text(rows[i]["to"].as_str().unwrap_or_default());
resp.context_menu(|ui| {
if widgets::menu_item_name(ui, tl!("Remove Color"), Some(i) != base, false) {
remove = Some(i);
if let Some(c) = color_menu(ui, rows, i, base) {
choice = Some(c);
}
});
}
@@ -1569,15 +1890,14 @@ fn color_bars(ui: &mut Ui, d: &mut Dialog, rows: &mut Vec<Value>, active: &[usiz
dropped = released.zip(at);
});
});
if let Some(b) = remove.and_then(|i| remove_color(rows, i, base, keeps_rows(d))) {
removed(d, b);
return true;
if choice.is_some() {
return (false, choice);
}
let Some(moved) = dropped.and_then(|(n, to)| move_bar(rows, active, n, to)) else { return false };
let Some(moved) = dropped.and_then(|(n, to)| move_bar(rows, active, n, to)) else { return (false, None) };
d.fields.insert("__sel".into(), json!([moved]));
// The slider values held are those of a row index that may now hold another row.
d.fields.remove(COMPS);
true
(true, None)
}
/// Move the row of the `from`th active row (of `active`, ascending row indexes) to before the
@@ -1796,6 +2116,117 @@ mod tests {
assert_eq!([&r[0]["to"], &r[1]["to"], &r[2]["to"]], ["rgb 255 0 0", "rgb 0 255 0", "rgb 0 0 255"]);
}
/// The base color is the row marked `base`, else the first row shown; Set As Base Color moves the
/// mark, and does nothing for the base row already or a row the Edit tab doesn't show.
#[test]
fn set_base_moves_the_base_mark() {
let mut r = rows();
assert_eq!(base_row(&r, &active_rows(&r)), Some(0));
assert!(!set_base(&mut r, 0), "the first row is the base already");
assert!(set_base(&mut r, 2));
assert_eq!(base_row(&r, &active_rows(&r)), Some(2));
assert!(set_base(&mut r, 1));
assert_eq!(r.iter().filter(|x| x[BASE] == json!(true)).count(), 1, "one base mark: {r:?}");
assert!(!set_base(&mut r, 1));
r[2]["exclude"] = json!(true);
assert!(!set_base(&mut r, 2), "an excluded row isn't shown");
assert!(!set_base(&mut r, 9));
// An excluded base row leaves the first row shown as the base.
r[1]["exclude"] = json!(true);
assert_eq!(base_row(&r, &active_rows(&r)), Some(0));
// Setting that row as the base keeps it the base once the marked row is shown again.
assert!(set_base(&mut r, 0), "the hidden row's mark moves to it");
r[1]["exclude"] = json!(false);
assert_eq!(base_row(&r, &active_rows(&r)), Some(0), "{r:?}");
}
/// Merge and Separate keep the base mark on a row of the base color's colors; Randomize's rows
/// (as the engine returns them) take the marks at their places again; `recolor.apply` gets no marks.
#[test]
fn the_base_mark_follows_merge_separate_and_randomize() {
let mut r = rows();
set_base(&mut r, 2);
merge(&mut r, &[0, 2]);
assert_eq!(r[0][BASE], json!(true), "merged into the first row: {r:?}");
let mut r = rows();
set_base(&mut r, 1);
separate(&mut r, &[1]);
assert_eq!(r.len(), 4);
assert_eq!((r[1][BASE].clone(), r[2].get(BASE)), (json!(true), None), "{r:?}");
// A marker's tie goes with it too.
let mut t = rows();
t[1][TIE] = json!(1);
separate(&mut t, &[1]);
assert_eq!((t[1][TIE].clone(), t[2].get(TIE)), (json!(1), None));
let mut t = rows();
t[0][TIE] = json!(1);
t[2][TIE] = json!(3);
t.push(json!({"from": [], "to": "rgb 1 2 3", "follows": 3}));
merge(&mut t, &[0, 2]);
assert_eq!((t[0][TIE].clone(), t[2][FOLLOWS].clone()), (json!(1), json!(1)), "its follower follows the row merged into: {t:?}");
let before = r.clone();
let mut shuffled: Vec<Value> = r.iter().map(without_marks).collect();
assert!(shuffled.iter().all(|x| x.get(BASE).is_none()));
keep_marks(&before, &mut shuffled);
assert_eq!(shuffled, before);
let mut fewer = vec![json!({"from": [], "to": "rgb 1 1 1"})];
keep_marks(&before, &mut fewer);
assert!(fewer[0].get(BASE).is_none(), "rows of another count take no marks");
let mut d = Dialog::new(KIND, json!({}));
d.fields.insert("rows".into(), json!(before));
assert!(apply_params(&d)["map"].as_array().unwrap().iter().all(|x| x.get(BASE).is_none()));
}
/// A color added on a marker's line moves with that marker when the colors are unlinked; it
/// moves alone itself, and linked colors all move together as before.
#[test]
fn a_color_added_on_a_markers_line_moves_with_it() {
let hue = |r: &[Value], i: usize| to_color(&r[i]).unwrap().to_hsb()[0];
let mut r = rows();
let added = add_color(&mut r, &Color::from_hsb(240.0, 0.5, 1.0));
tie_to(&mut r, 1, added);
assert_eq!((r[1][TIE].clone(), r[added][FOLLOWS].clone()), (json!(1), json!(1)));
move_color(&mut r, 1, [270.0, 1.0, 1.0], false);
assert!((hue(&r, added) - 270.0).abs() < 0.5, "the added color turns with its marker: {}", hue(&r, added));
assert!((hue(&r, 0) - 0.0).abs() < 0.5 && (hue(&r, 2) - 120.0).abs() < 0.5, "the others stay");
move_color(&mut r, added, [300.0, 0.5, 1.0], false);
assert!((hue(&r, 1) - 270.0).abs() < 0.5, "its marker stays");
// A second color tied to the same marker shares its number.
let next = add_color(&mut r, &Color::from_hsb(270.0, 0.2, 1.0));
tie_to(&mut r, 1, next);
assert_eq!(r[next][FOLLOWS], json!(1));
let other = add_color(&mut r, &Color::from_hsb(0.0, 0.2, 1.0));
tie_to(&mut r, 0, other);
assert_eq!(r[0][TIE], json!(2), "another marker takes a new number");
tie_to(&mut r, 0, 0);
assert!(r[0].get(FOLLOWS).is_none(), "a row isn't tied to itself");
// Colors left from a removed marker follow no marker tied later.
let mut r = rows();
let added = add_color(&mut r, &Color::from_hsb(240.0, 0.5, 1.0));
tie_to(&mut r, 1, added);
r.remove(1);
let next = add_color(&mut r, &Color::from_hsb(0.0, 0.5, 1.0));
tie_to(&mut r, 0, next);
assert_eq!(r[0][TIE], json!(2), "{r:?}");
// A color added on an added color's line moves with the first marker too.
let mut r = rows();
let added = add_color(&mut r, &Color::from_hsb(240.0, 0.5, 1.0));
tie_to(&mut r, 1, added);
let chained = add_color(&mut r, &Color::from_hsb(240.0, 0.25, 1.0));
tie_to(&mut r, added, chained);
move_color(&mut r, 1, [250.0, 1.0, 1.0], false);
assert!((hue(&r, chained) - 250.0).abs() < 0.5, "{r:?}");
}
/// Select Shade's grid runs from 0% to 100% saturation across and from 100% brightness down.
#[test]
fn the_shade_grid_spans_saturation_and_brightness() {
assert_eq!(shade_at(0, 0), [0.0, 1.0]);
assert_eq!(shade_at(SHADE_COLS - 1, 0)[0], 1.0);
let last = shade_at(0, SHADE_ROWS - 1)[1];
assert!(last > 0.0 && last < 0.2, "{last}");
}
/// A rule or a wheel move that gives a row a new color drops the row's tint; a row whose
/// color stays keeps it.
#[test]
+4
View File
@@ -1496,6 +1496,10 @@ font-technology Variable Променливи
Add Color Tool Инструмент „Добавяне на цвят“
Remove Color Tool Инструмент „Премахване на цвят“
Remove Color Премахване на цвят
Set As Base Color Задаване като основен цвят
Select Shade Избор на нюанс
Add New Color Добавяне на нов цвят
Set Current Color As Base Color Задаване на текущия цвят като основен
Harmony Sets Набори от хармонии
Height Височина
Height: Височина:
Can't render this file because it is too large.
+4
View File
@@ -2909,6 +2909,10 @@ digits Malayalam Malajalam
Add Color Tool Alat za dodavanje boje
Remove Color Tool Alat za uklanjanje boje
Remove Color Ukloni boju
Set As Base Color Postavi kao osnovnu boju
Select Shade Odaberi nijansu
Add New Color Dodaj novu boju
Set Current Color As Base Color Postavi trenutnu boju kao osnovnu
Harmony Rules Pravila harmonije
Keep this row's colors (exclude) Zadrži boje ovog reda (isključi)
Limit to Library: Ograniči na biblioteku:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -2026,6 +2026,10 @@ digits Malayalam Malaiàlam
Add Color Tool Eina Afegeix color
Remove Color Tool Eina Elimina color
Remove Color Elimina el color
Set As Base Color Defineix com a color base
Select Shade Selecciona el to
Add New Color Afegeix un color nou
Set Current Color As Base Color Defineix el color actual com a color base
Harmony Sets Conjunts d’harmonia
HDTV 1080p HDTV 1080p
HDTV 720p HDTV 720p
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -2987,6 +2987,10 @@ digits Malayalam Malajálamské
Add Color Tool Nástroj Přidat barvu
Remove Color Tool Nástroj Odstranit barvu
Remove Color Odstranit barvu
Set As Base Color Nastavit jako základní barvu
Select Shade Vybrat odstín
Add New Color Přidat novou barvu
Set Current Color As Base Color Nastavit aktuální barvu jako základní
Harmony Rules Pravidla harmonie
Keep this row's colors (exclude) Ponechat barvy tohoto řádku (vyloučit)
Limit to Library: Omezit na knihovnu:
Can't render this file because it is too large.
+4
View File
@@ -3385,6 +3385,10 @@ digits Malayalam Malayalam
Add Color Tool Værktøjet Tilføj farve
Remove Color Tool Værktøjet Fjern farve
Remove Color Fjern farve
Set As Base Color Angiv som grundfarve
Select Shade Vælg nuance
Add New Color Tilføj ny farve
Set Current Color As Base Color Angiv aktuel farve som grundfarve
Harmony Rules Harmoniregler
Keep this row's colors (exclude) Behold farverne i denne række (ekskludér)
Limit to Library: Begræns til bibliotek:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -1539,6 +1539,10 @@ file-filter Templates Vorlagen
Add Color Tool Farbe-hinzufügen-Werkzeug
Remove Color Tool Farbe-entfernen-Werkzeug
Remove Color Farbe entfernen
Set As Base Color Als Grundfarbe festlegen
Select Shade Schattierung auswählen
Add New Color Neue Farbe hinzufügen
Set Current Color As Base Color Aktuelle Farbe als Grundfarbe festlegen
Harmony Sets Harmoniesätze
Height Höhe
Height: Höhe:
Can't render this file because it is too large.
+4
View File
@@ -1471,6 +1471,10 @@ font-technology Variable Μεταβλητές
Add Color Tool Εργαλείο προσθήκης χρώματος
Remove Color Tool Εργαλείο αφαίρεσης χρώματος
Remove Color Αφαίρεση χρώματος
Set As Base Color Ορισμός ως βασικό χρώμα
Select Shade Επιλογή απόχρωσης
Add New Color Προσθήκη νέου χρώματος
Set Current Color As Base Color Ορισμός τρέχοντος χρώματος ως βασικού
Harmony Sets Σύνολα χρωματικής αρμονίας
Height Ύψος
Height: Ύψος:
Can't render this file because it is too large.
+4
View File
@@ -1550,6 +1550,10 @@ font-technology Variable Variables
Add Color Tool Herramienta Añadir color
Remove Color Tool Herramienta Eliminar color
Remove Color Eliminar color
Set As Base Color Establecer como color base
Select Shade Seleccionar matiz
Add New Color Añadir nuevo color
Set Current Color As Base Color Establecer el color actual como color base
Harmony Sets Conjuntos de armonía
Height Altura
Height: Altura:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -2931,6 +2931,10 @@ digits Malayalam Malajalam
Add Color Tool Lisää väri -työkalu
Remove Color Tool Poista väri -työkalu
Remove Color Poista väri
Set As Base Color Aseta perusväriksi
Select Shade Valitse sävy
Add New Color Lisää uusi väri
Set Current Color As Base Color Aseta nykyinen väri perusväriksi
Harmony Rules Harmoniasäännöt
Keep this row's colors (exclude) Säilytä tämän rivin värit (jätä pois)
Limit to Library: Rajoita kirjastoon:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -1543,6 +1543,10 @@ font-technology Variable Variables
Add Color Tool Outil Ajouter une couleur
Remove Color Tool Outil Supprimer une couleur
Remove Color Supprimer la couleur
Set As Base Color Définir comme couleur de base
Select Shade Sélectionner une nuance
Add New Color Ajouter une nouvelle couleur
Set Current Color As Base Color Définir la couleur actuelle comme couleur de base
Harmony Rules: Règles d’harmonie :
Harmony Sets Ensembles d’harmonies
Height Hauteur
Can't render this file because it is too large.
+4
View File
@@ -3564,6 +3564,10 @@
Add Color Tool રંગ ઉમેરો સાધન
Remove Color Tool રંગ દૂર કરો સાધન
Remove Color રંગ દૂર કરો
Set As Base Color આધાર રંગ તરીકે સેટ કરો
Select Shade છાયા પસંદ કરો
Add New Color નવો રંગ ઉમેરો
Set Current Color As Base Color વર્તમાન રંગને આધાર રંગ તરીકે સેટ કરો
Show handles when multiple anchors are selected બહુવિધ એન્કર પસંદ હોય ત્યારે હૅન્ડલ બતાવો
Show in Folder ફોલ્ડરમાં બતાવો
Show its progress, see Cancel and write log lines તેની પ્રગતિ બતાવવી, રદ કરવાની વિનંતી જોવી અને લૉગ લાઇનો લખવી
Can't render this file because it contains an unexpected character in line 72 and column 5.
+4
View File
@@ -4650,6 +4650,10 @@ antiAlias Sharp शार्प
Add Color Tool रंग जोड़ें टूल
Remove Color Tool रंग हटाएँ टूल
Remove Color रंग हटाएँ
Set As Base Color आधार रंग के रूप में सेट करें
Select Shade शेड चुनें
Add New Color नया रंग जोड़ें
Set Current Color As Base Color वर्तमान रंग को आधार रंग के रूप में सेट करें
Show Color Groups रंग समूह दिखाएँ
Show Color Swatches रंग स्वॉचेस दिखाएँ
Show Corner Widget शो कॉर्नर विजेट
Can't render this file because it is too large.
+4
View File
@@ -1954,6 +1954,10 @@ file-filter Templates Sablonok
Add Color Tool Szín hozzáadása eszköz
Remove Color Tool Szín eltávolítása eszköz
Remove Color Szín eltávolítása
Set As Base Color Beállítás alapszínként
Select Shade Árnyalat kiválasztása
Add New Color Új szín hozzáadása
Set Current Color As Base Color Aktuális szín beállítása alapszínként
Harmony Sets Harmóniakészletek
HDTV 1080p HDTV 1080p
HDTV 720p HDTV 720p
Can't render this file because it is too large.
+4
View File
@@ -2719,6 +2719,10 @@ digits Malayalam Malayalam
Add Color Tool Alat Tambah Warna
Remove Color Tool Alat Hapus Warna
Remove Color Hapus Warna
Set As Base Color Atur sebagai Warna Dasar
Select Shade Pilih Corak
Add New Color Tambah Warna Baru
Set Current Color As Base Color Atur Warna Saat Ini sebagai Warna Dasar
Harmony Rules Aturan harmoni
Keep this row's colors (exclude) Pertahankan warna baris ini (kecualikan)
Limit to Library: Batasi ke pustaka:
Can't render this file because it contains an unexpected character in line 2469 and column 5.
+4
View File
@@ -1569,6 +1569,10 @@ file-filter Templates Modelli
Add Color Tool Strumento Aggiungi colore
Remove Color Tool Strumento Rimuovi colore
Remove Color Rimuovi colore
Set As Base Color Imposta come colore base
Select Shade Seleziona sfumatura
Add New Color Aggiungi nuovo colore
Set Current Color As Base Color Imposta il colore corrente come colore base
Harmony Sets Gruppi di armonia
Height Altezza
Height: Altezza:
Can't render this file because it is too large.
+4
View File
@@ -1941,6 +1941,10 @@ antiAlias Sharp シャープ
Add Color Tool カラー追加ツール
Remove Color Tool カラー削除ツール
Remove Color カラーを削除
Set As Base Color ベースカラーに設定
Select Shade シェードを選択
Add New Color 新規カラーを追加
Set Current Color As Base Color 現在のカラーをベースカラーに設定
Height 高さ
Height: 高さ:
Help › Search Commands… ヘルプ › コマンドを検索…
Can't render this file because it is too large.
+4
View File
@@ -4763,6 +4763,10 @@ digits Malayalam მალაიალამური
Add Color Tool ფერის დამატების ხელსაწყო
Remove Color Tool ფერის წაშლის ხელსაწყო
Remove Color ფერის წაშლა
Set As Base Color საბაზო ფერად დაყენება
Select Shade ელფერის არჩევა
Add New Color ახალი ფერის დამატება
Set Current Color As Base Color მიმდინარე ფერის საბაზო ფერად დაყენება
Keep this row's colors (exclude) ამ სტრიქონის ფერების შენარჩუნება (გამორიცხვა)
Limit to Library: ბიბლიოთეკით შეზღუდვა:
Link harmony colors ჰარმონიის ფერების დაკავშირება
Can't render this file because it is too large.
+4
View File
@@ -1931,6 +1931,10 @@ antiAlias Sharp 날카롭게
Add Color Tool 색상 추가 도구
Remove Color Tool 색상 제거 도구
Remove Color 색상 제거
Set As Base Color 기본 색상으로 설정
Select Shade 음영 선택
Add New Color 새 색상 추가
Set Current Color As Base Color 현재 색상을 기본 색상으로 설정
Height 높이
Height: 높이:
Help › Search Commands… 도움말 › 명령 검색…
Can't render this file because it is too large.
+4
View File
@@ -3281,6 +3281,10 @@ digits Malayalam Malayalam
Add Color Tool Gereedschap Kleur toevoegen
Remove Color Tool Gereedschap Kleur verwijderen
Remove Color Kleur verwijderen
Set As Base Color Instellen als basiskleur
Select Shade Schakering selecteren
Add New Color Nieuwe kleur toevoegen
Set Current Color As Base Color Huidige kleur instellen als basiskleur
Harmony Rules Harmonieregels
Keep this row's colors (exclude) De kleuren van deze rij behouden (uitsluiten)
Limit to Library: Beperken tot bibliotheek:
Can't render this file because it is too large.
+4
View File
@@ -2897,6 +2897,10 @@ digits Malayalam Malajalam
Add Color Tool Narzędzie Dodaj kolor
Remove Color Tool Narzędzie Usuń kolor
Remove Color Usuń kolor
Set As Base Color Ustaw jako kolor bazowy
Select Shade Wybierz odcień
Add New Color Dodaj nowy kolor
Set Current Color As Base Color Ustaw bieżący kolor jako bazowy
Keep this row's colors (exclude) Zachowaj kolory tego wiersza (wyklucz)
Limit to Library: Ogranicz do biblioteki:
Link harmony colors Połącz kolory harmonii
Can't render this file because it is too large.
+4
View File
@@ -1337,6 +1337,10 @@ antiAlias Sharp Nítido
Add Color Tool Ferramenta Adicionar cor
Remove Color Tool Ferramenta Remover cor
Remove Color Remover cor
Set As Base Color Definir como cor base
Select Shade Selecionar tonalidade
Add New Color Adicionar nova cor
Set Current Color As Base Color Definir cor atual como cor base
Harmony Sets Conjuntos de Harmonia
Height Altura
Height: Altura:
Can't render this file because it is too large.
+4
View File
@@ -1560,6 +1560,10 @@ file-filter Templates Шаблоны
Add Color Tool Инструмент «Добавить цвет»
Remove Color Tool Инструмент «Удалить цвет»
Remove Color Удалить цвет
Set As Base Color Сделать базовым цветом
Select Shade Выбрать оттенок
Add New Color Добавить новый цвет
Set Current Color As Base Color Сделать текущий цвет базовым
Harmony Sets Наборы гармонии
Height Высота
Height: Высота:
Can't render this file because it is too large.
+4
View File
@@ -1507,6 +1507,10 @@ font-technology Variable Variabla
Add Color Tool Verktyget Lägg till färg
Remove Color Tool Verktyget Ta bort färg
Remove Color Ta bort färg
Set As Base Color Ange som grundfärg
Select Shade Välj nyans
Add New Color Lägg till ny färg
Set Current Color As Base Color Ange aktuell färg som grundfärg
Harmony Sets Harmoniuppsättningar
Height Höjd
Height: Höjd:
Can't render this file because it is too large.
+4
View File
@@ -1464,6 +1464,10 @@ font-technology Variable Değişken
Add Color Tool Renk Ekle aracı
Remove Color Tool Renk Kaldır aracı
Remove Color Rengi kaldır
Set As Base Color Temel renk olarak ayarla
Select Shade Ton seç
Add New Color Yeni renk ekle
Set Current Color As Base Color Geçerli rengi temel renk olarak ayarla
Harmony Sets Armoni Setleri
Height Yükseklik
Height: Yükseklik:
Can't render this file because it is too large.
+4
View File
@@ -1563,6 +1563,10 @@ file-filter Templates Шаблони
Add Color Tool Інструмент «Додати колір»
Remove Color Tool Інструмент «Вилучити колір»
Remove Color Вилучити колір
Set As Base Color Зробити базовим кольором
Select Shade Вибрати відтінок
Add New Color Додати новий колір
Set Current Color As Base Color Зробити поточний колір базовим
Harmony Sets Набори гармонії
Height Висота
Height: Висота:
Can't render this file because it is too large.
+4
View File
@@ -1801,6 +1801,10 @@ file-filter Templates Mẫu
Add Color Tool Công cụ Thêm màu
Remove Color Tool Công cụ Xóa màu
Remove Color Xóa màu
Set As Base Color Đặt làm màu cơ sở
Select Shade Chọn sắc độ
Add New Color Thêm màu mới
Set Current Color As Base Color Đặt màu hiện tại làm màu cơ sở
Harmony Sets Bộ hài hòa màu
Height Chiều cao
Height: Chiều cao:
Can't render this file because it contains an unexpected character in line 205 and column 5.
+4
View File
@@ -1497,6 +1497,10 @@ file-filter Templates 模板
Add Color Tool 添加颜色工具
Remove Color Tool 删除颜色工具
Remove Color 删除颜色
Set As Base Color 设为基色
Select Shade 选择色调
Add New Color 添加新颜色
Set Current Color As Base Color 将当前颜色设为基色
Harmony Sets 色彩调和组
Height 高度
Height: 高度:
Can't render this file because it is too large.
+4
View File
@@ -1534,6 +1534,10 @@ file-filter Templates 範本
Add Color Tool 新增顏色工具
Remove Color Tool 移除顏色工具
Remove Color 移除顏色
Set As Base Color 設為基色
Select Shade 選取色調
Add New Color 新增顏色
Set Current Color As Base Color 將目前顏色設為基色
Harmony Sets 色彩調和組
Height 高度
Height: 高度:
Can't render this file because it is too large.
+163
View File
@@ -1339,3 +1339,166 @@ fn a_color_bars_menu_removes_its_color() {
assert!(h.query_by_role_and_label(egui::accesskit::Role::Button, "Color 2").is_none(), "its bar goes");
assert_eq!(field(h.state(), "__sel"), json!([0]));
}
/// Right-clicks the point `at`.
fn right_click_at(h: &mut egui_kittest::Harness<'_, VectorcraftApp>, at: Pos2) {
h.event(Event::PointerMoved(at));
h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed: true, modifiers: Modifiers::NONE });
h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed: false, modifiers: Modifiers::NONE });
h.run_steps(2);
}
/// The smaller angle between hues `a` and `b`, in degrees.
fn hue_gap(a: f32, b: f32) -> f32 {
(a - b).rem_euclid(360.0).min((b - a).rem_euclid(360.0))
}
/// A marker's right-click menu has Set As Base Color, Select Shade, Color Picker and Remove Color.
/// Set As Base Color marks the row as the base, whose menu then has neither Set As Base Color nor
/// Remove Color; with another color selected, a harmony rule builds from the base color, and OK
/// recolors the art.
#[test]
fn a_markers_menu_sets_the_base_color_that_the_rules_build_from() {
let mut h = edit_harness(&["#ff0000", "#0000ff", "#00ff00"]);
let hsb = new_hsb(h.state());
let at = wheel_at(&h, hsb[1][0], hsb[1][1]);
right_click_at(&mut h, at);
for item in [" Set As Base Color", " Select Shade", " Color Picker", " Remove Color"] {
assert!(h.query_by_label(item).is_some(), "{item}");
}
h.get_by_label(" Set As Base Color").click();
h.run_steps(3);
let rows = field(h.state(), "rows");
assert_eq!(rows[1]["base"], json!(true), "{rows}");
assert!(rows[0].get("base").is_none() && rows[2].get("base").is_none());
right_click_at(&mut h, at);
assert!(h.get_by_label(" Set As Base Color").accesskit_node().is_disabled(), "it is the base already");
assert!(h.get_by_label(" Remove Color").accesskit_node().is_disabled(), "the base color can't be removed");
h.key_press(egui::Key::Escape);
h.run_steps(2);
// The selected color is another one; the rule still builds from the base.
set(h.state_mut(), "__sel", json!([0]));
h.run_steps(3);
h.get_by_role_and_label(egui::accesskit::Role::ComboBox, "Harmony Rules:").click();
h.run_steps(2);
h.get_by_label("Triad").click();
h.run_steps(3);
let now = new_hsb(h.state());
assert!(hue_gap(now[1][0], hsb[1][0]) < 1.0, "the base color keeps its hue: {hsb:?} -> {now:?}");
assert!(hue_gap(now[0][0], now[1][0]) > 110.0 && hue_gap(now[2][0], now[1][0]) > 110.0, "the others are a triad from it: {now:?}");
assert_eq!(field(h.state(), "rows")[1]["base"], json!(true), "the rule keeps the base mark");
let before = fills(h.state());
let app = h.state_mut();
dialogs::confirm(app).unwrap();
assert_eq!(fills(app), before, "OK keeps the previewed colors");
}
/// Select Shade on a marker's menu shows a grid of the color's hue; a click on a cell gives the color
/// that saturation and brightness, keeping its hue, and closes the menu. Unlinked, the other colors
/// stay; linked, they move as a drag would move them.
#[test]
fn select_shade_gives_a_marker_the_shade_clicked() {
for linked in [false, true] {
let mut h = edit_harness(&["rgb 200 100 100", "rgb 100 200 200"]);
set(h.state_mut(), "linked", json!(linked));
h.run_steps(3);
let hsb = new_hsb(h.state());
let at = wheel_at(&h, hsb[0][0], hsb[0][1]);
right_click_at(&mut h, at);
h.get_by_label(" Select Shade").click();
h.run_steps(2);
let cell = "Saturation 50%, Brightness 57%";
h.get_by_label(cell).click();
h.run_steps(3);
let now = new_hsb(h.state());
assert!(hue_gap(now[0][0], hsb[0][0]) < 1.0 && (now[0][1] - 0.5).abs() < 0.01 && (now[0][2] - 4.0 / 7.0).abs() < 0.01, "{now:?}");
let other_moved = (now[1][2] - hsb[1][2]).abs() > 0.01;
assert_eq!(other_moved, linked, "linked {linked}: {hsb:?} -> {now:?}");
assert!(h.query_by_label(cell).is_none(), "the menu closes");
assert_eq!(field(h.state(), "__sel"), json!([0]));
}
}
/// Color Picker on a marker's menu opens the Color Picker for that color.
#[test]
fn a_markers_menu_opens_the_color_picker() {
let mut h = edit_harness(&["rgb 200 100 100", "rgb 100 200 200"]);
let hsb = new_hsb(h.state());
let at = wheel_at(&h, hsb[1][0], hsb[1][1]);
right_click_at(&mut h, at);
h.get_by_label(" Color Picker").click();
h.run_steps(3);
assert_eq!(h.state().ui.dialog.as_ref().map(|d| d.kind.as_str()), Some("colorPicker"));
}
/// A right-click on the wheel away from the markers offers Add New Color, which adds the hue and
/// saturation there as a new color. A color added on the line from the centre to a marker moves
/// with that marker when the colors are unlinked, and the others stay.
#[test]
fn add_new_color_on_a_markers_line_moves_with_that_marker() {
let mut h = edit_harness(&["rgb 200 100 100", "rgb 100 200 200"]);
set(h.state_mut(), "linked", json!(false));
set(h.state_mut(), "__sel", json!([0]));
h.run_steps(4);
let hsb = new_hsb(h.state());
let at = wheel_at(&h, 90.0, 0.6);
right_click_at(&mut h, at);
assert!(h.query_by_label(" Set As Base Color").is_none(), "no marker there");
h.get_by_label(" Add New Color").click();
h.run_steps(3);
let rows = field(h.state(), "rows");
assert_eq!(rows.as_array().unwrap().len(), 3, "{rows}");
assert_eq!((&rows[2]["from"], &rows[2]["added"]), (&json!([]), &json!(true)));
assert!(rows[2].get("follows").is_none(), "off every marker's line");
let [hue, s, v] = new_hsb(h.state())[2];
assert!((hue - 90.0).abs() < 1.0 && (s - 0.6).abs() < 0.01 && (v - hsb[0][2]).abs() < 0.01, "{:?}", [hue, s, v]);
assert_eq!(field(h.state(), "__sel"), json!([2]));
// Halfway along the second color's line.
let on_line = wheel_at(&h, hsb[1][0], hsb[1][1] / 2.0);
right_click_at(&mut h, on_line);
h.get_by_label(" Add New Color").click();
h.run_steps(3);
let rows = field(h.state(), "rows");
assert_eq!(rows.as_array().unwrap().len(), 4);
assert!(rows[1]["tie"].is_u64() && rows[3]["follows"] == rows[1]["tie"], "{rows}");
// Drag the second color's marker a little way round: the color on its line turns with it.
let before = new_hsb(h.state());
let start = wheel_at(&h, before[1][0], before[1][1]);
h.hover_at(start);
h.run_steps(1);
h.drag_at(start);
h.run_steps(1);
let mut p = start;
for k in 1..=6 {
p = wheel_at(&h, before[1][0] + 5.0 * k as f32, before[1][1]);
h.hover_at(p);
h.run_steps(1);
}
h.drop_at(p);
h.run_steps(2);
let after = new_hsb(h.state());
let turned = hue_gap(after[1][0], before[1][0]);
assert!(turned > 20.0, "the marker turned: {before:?} -> {after:?}");
assert!((hue_gap(after[3][0], before[3][0]) - turned).abs() < 1.0, "the color on its line turned as far: {before:?} -> {after:?}");
assert!(hue_gap(after[0][0], before[0][0]) < 0.5 && hue_gap(after[2][0], before[2][0]) < 0.5, "the others stay: {before:?} -> {after:?}");
}
/// Set Current Color As Base Color makes the selected color the base; it is off while the selected
/// color is the base. A color bar's menu has Set As Base Color too.
#[test]
fn set_current_color_as_base_color_marks_the_selected_color() {
let mut h = edit_harness(&["#ff0000", "#0000ff", "#00ff00"]);
let name = "Set Current Color As Base Color";
assert!(h.get_by_role_and_label(egui::accesskit::Role::Button, name).accesskit_node().is_disabled(), "the base color is the selected one");
set(h.state_mut(), "__sel", json!([2]));
h.run_steps(3);
click_button(&mut h, name);
assert_eq!(field(h.state(), "rows")[2]["base"], json!(true));
assert!(h.get_by_role_and_label(egui::accesskit::Role::Button, name).accesskit_node().is_disabled());
show_display(&mut h, "Show color bars");
right_click_bar(&mut h, "Color 1");
h.get_by_label(" Set As Base Color").click();
h.run_steps(3);
let rows = field(h.state(), "rows");
assert_eq!((&rows[0]["base"], rows[2].get("base")), (&json!(true), None), "{rows}");
}
+1 -1
View File
@@ -37,7 +37,7 @@ pub use chips::{ProxyClicks, chip_button, chip_button_named, fill_stroke_proxy,
pub use color::{
FieldAxis, Live, RingResponse, SliderValue, WheelResponse, channel_slider, channel_slider_named, channel_slider_valued, color_field, color_mesh,
color_slider, color_slider_named, color_slider_stepped, color_slider_valued, harmony_wheel, hex_field, hex_field_named, hsb32, hue_ring,
region_texture, ring_square, segment_color, segmented_wheel, stepped_area,
recolor_wheel, region_texture, ring_square, segment_color, stepped_area,
};
pub(crate) use color::{HEX_FIELD_CHARS, hex_text, pointer_phase};
pub use drag::{
+53 -9
View File
@@ -926,6 +926,12 @@ pub struct WheelResponse {
/// A click on the wheel: the color whose marker is within reach of it (if any), and the hue
/// (degrees) and saturation under the pointer (1 for a marker past the wheel's edge).
pub clicked: Option<(Option<usize>, [f32; 2])>,
/// A right-click on the wheel, or on a marker past its edge: the color whose marker is within
/// reach of it (if any), the color on whose line from the centre it is (when it is on no
/// marker), and the hue (degrees) and saturation under the pointer.
pub secondary: Option<(Option<usize>, Option<usize>, [f32; 2])>,
/// The wheel's own response, for a right-click menu.
pub response: Option<egui::Response>,
}
/// The harmony wheel of Recolor Artwork's Edit tab and the Color Themes panel: a hue and saturation
@@ -933,21 +939,40 @@ pub struct WheelResponse {
/// marker per colour joined to the centre (the selected colour, `base`, larger) and a Brightness
/// slider for the selected colour below it.
pub fn harmony_wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>) -> WheelResponse {
wheel(ui, id, size, colors, base, false)
wheel(ui, id, size, colors, base, base, false)
}
/// [`harmony_wheel`] drawn as solid patches (24 hues by 5 saturations, each in its
/// [`segment_color`]). The markers sit at their colors' own hue and
/// Recolor Artwork's wheel: [`harmony_wheel`] with the base color's marker (`base`) larger and the
/// selected color's (`selected`, when another) ringed, at the selected color's brightness, with the
/// Brightness slider for it. With `segmented` it is drawn as solid patches (24 hues by 5
/// saturations, each in its [`segment_color`]); the markers sit at their colors' own hue and
/// saturation, and a drag moves them as freely as on the smooth wheel.
pub fn segmented_wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>) -> WheelResponse {
wheel(ui, id, size, colors, base, true)
pub fn recolor_wheel(
ui: &mut Ui,
id: &str,
size: f32,
colors: &[Color],
base: Option<usize>,
selected: Option<usize>,
segmented: bool,
) -> WheelResponse {
wheel(ui, id, size, colors, base, selected.or(base), segmented)
}
/// [`harmony_wheel`], or with `segmented` [`segmented_wheel`].
fn wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>, segmented: bool) -> WheelResponse {
/// The distance from `p` to the segment from `a` to `b`.
fn segment_distance(p: egui::Pos2, a: egui::Pos2, b: egui::Pos2) -> f32 {
let ab = b - a;
let len2 = ab.length_sq();
let t = if len2 > 0.0 { ((p - a).dot(ab) / len2).clamp(0.0, 1.0) } else { 0.0 };
p.distance(a + ab * t)
}
/// [`harmony_wheel`] or [`recolor_wheel`]: the big marker is `base`'s, and the wheel's brightness
/// and the Brightness slider are `selected`'s.
fn wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>, selected: Option<usize>, segmented: bool) -> WheelResponse {
let t = Tokens::get(ui.ctx());
let mut out = WheelResponse::default();
let base_hsb = base.and_then(|b| colors.get(b)).map(Color::to_hsb);
let base_hsb = selected.and_then(|b| colors.get(b)).map(Color::to_hsb);
let v = base_hsb.map_or(1.0, |c| c[2]);
ui.horizontal(|ui| {
ui.add_space(((ui.available_width() - size) / 2.0).max(0.0));
@@ -965,6 +990,24 @@ fn wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>
painter.line_segment([c, p], Stroke::new(1.0, Color32::from_white_alpha(160)));
painter.circle(p, if big { 8.0 } else { 5.5 }, crate::panels::c32(col), Stroke::new(1.5, Color32::WHITE));
painter.circle_stroke(p, if big { 9.0 } else { 6.5 }, Stroke::new(1.0, Color32::BLACK));
if Some(i) == selected && selected != base {
painter.circle_stroke(p, 8.5, Stroke::new(1.5, t.accent));
}
}
// A right-click: the marker under it, or else the line from the centre to a marker.
if resp.secondary_clicked()
&& let Some(p) = resp.interact_pointer_pos()
{
let near = colors.iter().map(at).enumerate().map(|(i, m)| (i, m.distance(p))).filter(|x| x.1 <= 14.0).min_by(|a, b| a.1.total_cmp(&b.1));
let dv = p - c;
if dv.length() <= r || near.is_some() {
let line = near.is_none().then(|| {
let on = colors.iter().map(at).enumerate().map(|(i, m)| (i, segment_distance(p, c, m))).filter(|x| x.1 <= 4.0);
on.min_by(|a, b| a.1.total_cmp(&b.1)).map(|x| x.0)
});
let h = (-dv.y).atan2(dv.x).to_degrees().rem_euclid(360.0);
out.secondary = Some((near.map(|x| x.0), line.flatten(), [h, (dv.length() / r).clamp(0.0, 1.0)]));
}
}
// Drag a marker: the nearest one within reach of the press.
let drag = ui.scope_id().with((id, "drag"));
@@ -991,6 +1034,7 @@ fn wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>
}
let name = if segmented { tl!("Segmented color wheel") } else { tl!("Color wheel") };
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Slider, ui.is_enabled(), name));
out.response = Some(resp);
});
ui.add_space(6.0);
ui.horizontal(|ui| {
@@ -998,7 +1042,7 @@ fn wheel(ui: &mut Ui, id: &str, size: f32, colors: &[Color], base: Option<usize>
ui.add_sized([70.0, 22.0], egui::Label::new(egui::RichText::new(tl!("Brightness")).color(t.text_dim)));
// Screen readers get the brightness in percent, as the Color panel's HSB B field shows it.
let shown = SliderValue::field((f64::from(v) * 100.0).round(), 0.0..=100.0, "%", 0);
if let (Some(b), Some([h, s, _])) = (base, base_hsb)
if let (Some(b), Some([h, s, _])) = (selected, base_hsb)
&& let (Some(nv), _) = color_slider_valued(ui, (id, "brightness"), tl!("Brightness"), Some(shown), v, size, &|x| {
crate::panels::c32(&Color::from_hsb(h, s, x))
})
+14 -4
View File
@@ -291,13 +291,23 @@ colors; colors opened alone are saved as a group with the change. `display` sets
colors: `smooth` (the smooth wheel, also when unset; each opening starts there), `segmented` (a wheel of solid patches,
24 hues by 5 saturations, whose markers move as freely) or `bars` (a solid bar per recolored color in row order; a click
selects its row for the sliders and a drag moves the row without changing a color). `wheelTool` turns on a wheel tool
on either wheel: `add` (the Add Color tool) adds a click as a new color, the hue and saturation clicked at the base
color's brightness (the patch's color on the segmented wheel), in a new row with no current colors (`from: []`) and
`added: true` that becomes the selected row; `remove` (the Remove Color tool) removes the color of the marker clicked. A color bar's
right-click menu has Remove Color too. The base color can't be removed. A removed color's row is dropped, unless it
on either wheel: `add` (the Add Color tool) adds a click as a new color, the hue and saturation clicked at the selected
color's brightness (the base color's when none is selected; the patch's color on the segmented wheel), in a new row with no current colors (`from: []`) and
`added: true` that becomes the selected row; `remove` (the Remove Color tool) removes the color of the marker clicked. The base color can't be removed. A removed color's row is dropped, unless it
has current colors and art or a group is open: it then keeps them with `to: null`, that art keeps its colors, and the
group's swatch at that place is removed. A row with no current colors recolors no art; with a group, the new color of
one with `added: true` is added to the group after the group's other colors, and a row made with New Row adds none.
The base color is the row with `base: true`, or the first color the Edit tab shows when no row has it; the harmony rules
build from it, and selecting another color for the sliders leaves it the base. A right-click on a wheel marker or a
color bar opens a menu with Set As Base Color (moves `base: true` to that row), Select Shade (a grid of the color's hue
at 7 saturations, 0% to 100%, by 7 brightnesses, 100% down to 14%; a click moves the color there as a drag of its
marker would, so linked colors follow), Color Picker and Remove Color; the base color's menu has neither Set As Base
Color nor Remove Color. A right-click elsewhere on either wheel offers Add New Color, which adds a color as the Add
Color tool does. A color added on the line from the centre to a marker moves with that marker while the colors are
unlinked: the marker's row gets `tie: n` and the added row `follows: n`, and dragging the marker, or Select Shade on
it, moves every row that follows its `tie` by the same change. Set Current Color As Base Color, before the color chips,
makes the selected color the base. The rows keep these marks when Randomize (`recolor.randomize`) or Prominent Colors
(`recolor.weigh`) changes them, and the rows the dialog sends `recolor.apply` leave `base`, `tie` and `follows` out.
Setting `colors`, a preserve flag or `limitTo` reduces the rows again (also on `ui.dialog.confirm`). The dialog previews
`recolor.apply` on the canvas; confirm keeps it as one undo step (with a group, the group is rewritten in the same
step; with no art selected only the group changes). In the Swatches panel, double-clicking a colour group's folder,
+2 -1
View File
@@ -1628,7 +1628,8 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Document Color Mode for effects and graphs:** File › Document Color Mode and `document.open {colorMode}` convert the colors of effects (Drop Shadow, Inner Glow, Outer Glow and the other effects with a color, on objects, their fills and strokes and in graphic styles) and the series paints and label styles that a graph keeps, so a graph drawn again from new data keeps the converted colors; File › Document Color Mode also converts the fill and stroke that new art takes. Undo restores the original new-art fill and stroke and Redo applies the conversion again.
- **Recolor Artwork layout (#3416):** the Edit chip list uses the modal scroll helper and its actual remaining height; the tab's minimum-height space scrolls with the chips. `tests_recolor` covers 5/20/200/400 colors, window resizing, 100/125/150/200% UI scaling, scrolling to and editing the final chip, Preview, Cancel, Confirm and Undo, alongside the existing #1733 drag regressions. Scores and estimates unchanged.
- **Recolor Artwork Edit displays:** buttons beside the Edit tab's wheel show the colors on a smooth color wheel, a segmented color wheel or as color bars ([Edit colors using Recolor Artwork](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/edit-colors-using-edit-colors-dialog.html)). The segmented wheel draws 24 hues by 5 saturations as solid patches, and its markers move freely as on the smooth wheel. The bars show one solid bar per recolored color in row order: a click selects a bar for the color sliders, and a drag moves its row without changing a color ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html)). The dialog opens on the smooth wheel; `display` (`smooth`, `segmented`, `bars`) is the dialog field. `tests_recolor` covers switching, the dialog height, segmented dragging and Brightness, and bar selection, editing, reordering, scrolling, Preview, Cancel and OK. Scores and estimates unchanged.
- **Recolor Artwork Add Color and Remove Color tools:** under the display buttons beside the Edit tab's wheel, the Add Color tool adds the color clicked on either wheel to the color group, and the Remove Color tool removes the color whose marker is clicked; a color bar's right-click menu has Remove Color, and the base color can't be removed ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html), [Edit swatch groups using the color wheel](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/edit-color-groups-using-the-color-wheel.html)). An added color is a new row with no current colors and `added: true`; unlike a row made with New Row, it adds its new color to a rewritten color group, after the group's other colors. VectorCraft's own rules: an added color takes the base color's brightness, and with art or a group a removed color's row stays with its current colors and no new color, so that art keeps its colors and the group's swatch at that place is removed. `wheelTool` (`add`, `remove`) is the dialog field. Tests: `the_add_color_tool_adds_a_row_with_no_current_colors`, `an_added_color_joins_the_color_group`, `the_remove_color_tool_removes_a_marker_but_not_the_base_colors` and `a_color_bars_menu_removes_its_color` in `crates/ui-egui/src/tests/recolor.rs`, `apply_params_give_the_group_added_colors_and_keep_its_other_colors` in `crates/ui-egui/src/dialogs/recolor.rs`, and `an_added_empty_row_gives_the_group_its_color_after_the_others` in `crates/engine/src/tests/recolor.rs`. Scores and estimates unchanged.
- **Recolor Artwork Add Color and Remove Color tools:** under the display buttons beside the Edit tab's wheel, the Add Color tool adds the color clicked on either wheel to the color group, and the Remove Color tool removes the color whose marker is clicked; a color bar's right-click menu has Remove Color, and the base color can't be removed ([Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html), [Edit swatch groups using the color wheel](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/edit-color-groups-using-the-color-wheel.html)). An added color is a new row with no current colors and `added: true`; unlike a row made with New Row, it adds its new color to a rewritten color group, after the group's other colors. VectorCraft's own rules: an added color takes the selected color's brightness (the base color's when none is selected), and with art or a group a removed color's row stays with its current colors and no new color, so that art keeps its colors and the group's swatch at that place is removed. `wheelTool` (`add`, `remove`) is the dialog field. Tests: `the_add_color_tool_adds_a_row_with_no_current_colors`, `an_added_color_joins_the_color_group`, `the_remove_color_tool_removes_a_marker_but_not_the_base_colors` and `a_color_bars_menu_removes_its_color` in `crates/ui-egui/src/tests/recolor.rs`, `apply_params_give_the_group_added_colors_and_keep_its_other_colors` in `crates/ui-egui/src/dialogs/recolor.rs`, and `an_added_empty_row_gives_the_group_its_color_after_the_others` in `crates/engine/src/tests/recolor.rs`. Scores and estimates unchanged.
- **Recolor Artwork base color and right-click menus:** a right-click on an Edit tab wheel marker or a color bar offers Set As Base Color, Select Shade, Color Picker and Remove Color, and a right-click elsewhere on the wheel offers Add New Color; a color added on a marker's line moves with that marker; Set Current Color As Base Color makes the selected color the base, and the harmony rules build from the base color whichever color is selected ([Edit swatch groups using the color wheel](https://helpx.adobe.com/illustrator/desktop/manage-colors/modify-colors/edit-color-groups-using-the-color-wheel.html), [Advanced recolor options overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/edit-colors-dialog-overview.html), [Using Illustrator CS5, pages 137 to 140](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf)). The base color is the row with `base: true`, or the first color shown; a color added on a marker's line follows the marker's `tie` with `follows`. VectorCraft's own rules: Select Shade's grid is 7 saturations by 7 brightnesses of the color's hue and moves the color as a drag of its marker would, and a tied color follows its marker only while the colors are unlinked (linked, every color moves). Tests: `a_markers_menu_sets_the_base_color_that_the_rules_build_from`, `select_shade_gives_a_marker_the_shade_clicked`, `a_markers_menu_opens_the_color_picker`, `add_new_color_on_a_markers_line_moves_with_that_marker` and `set_current_color_as_base_color_marks_the_selected_color` in `crates/ui-egui/src/tests/recolor.rs`, and `set_base_moves_the_base_mark`, `the_base_mark_follows_merge_separate_and_randomize`, `a_color_added_on_a_markers_line_moves_with_it` and `the_shade_grid_spans_saturation_and_brightness` in `crates/ui-egui/src/dialogs/recolor.rs`. Scores and estimates unchanged.
- **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. Tests: `a_new_row_goes_above_the_selection_and_takes_merged_colors`, `an_empty_row_gives_the_group_no_color` 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`.
- **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.