Merge pull request #7641 from dotCooCoo/feat/color-wheel-document-colors

Color Wheel: Show Document Colors lists the colors the art uses
This commit is contained in:
BFlat
2026-11-20 05:32:27 +07:00
committed by GitHub
43 changed files with 1001 additions and 54 deletions
@@ -153,6 +153,7 @@ pub(super) const ALLOWED: &[&str] = &[
"color.gamutCheck",
"color.harmony",
"color.plates",
"color.used",
"dataset.capture",
"dataset.delete",
"dataset.list",
+96 -33
View File
@@ -29,6 +29,15 @@ pub fn specs() -> Vec<CommandSpec> {
has_doc,
colors
),
cmd!(
query "color.used",
"Document Colors",
[],
None,
"{selection?: true (false: the objects select.all takes, also while something is selected), limit?: n (only the n most used; default all)} → {colors: [{key, hex, color: the color in its own model ({model, …}), count, swatch?: the global swatch it is linked to (from its first linked use in paint order, a plain use before a gradient stop that mixes the swatch's ink with process inks; left out when only such stops link it), tint?: 0..100 to three decimals (the percent of that swatch's color the same use stores)}] as recolor.colors lists them, selection: true when they are the selection's, uses: the uses of every color, those past limit included} the unique colors of the selection, or with nothing selected or selection false of the objects select.all takes without the hidden and locked objects inside them, most used first; the selection is left as it is",
has_doc,
used
),
cmd!(
"recolor.apply",
"Recolor Artwork",
@@ -952,16 +961,19 @@ fn pick_theme(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"colors": colors.iter().map(key_str).collect::<Vec<_>>(), "objects": theme.objects}))
}
/// A colour the art uses: how often, and the global swatch it is linked to.
/// A color the art uses: how often, and the global swatch of its first linked use in paint order.
struct Used {
color: Color,
count: usize,
swatch: Option<String>,
/// The global swatch of the first linked use that is not a gradient stop mixing the swatch's
/// ink with process inks, with the tint (0..1) its paint stores when the paint gives one.
plain: Option<(String, Option<f32>)>,
}
/// The unique colours of the objects `ids` and the objects inside them, most used first (ties by
/// key): fills, strokes, gradient stops, text, mesh points and the tiles of the patterns used as
/// fills or strokes. With `only`, an object not in it is left out with everything it holds.
/// key): fills, strokes, gradient stops, text, mesh points, the tiles of the patterns used as
/// fills or strokes, and the tiles of the patterns those tiles use. With `only`, an object not in it is left out with everything it holds.
fn used_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet<NodeId>>) -> Vec<Used> {
fn read<'a>(n: &'a Node, only: Option<&BTreeSet<NodeId>>, out: &mut Vec<&'a Node>) {
if only.is_some_and(|o| !o.contains(&n.id)) {
@@ -974,44 +986,64 @@ fn used_colors(d: &Document, ids: &[NodeId], only: Option<&BTreeSet<NodeId>>) ->
}
let mut index: HashMap<ColorKey, usize> = HashMap::new();
let mut used: Vec<(ColorKey, Used)> = vec![];
let mut count = |c: &Color, link: Option<&str>| {
let mut count_tint = |c: &Color, link: Option<&str>, tint: Option<f32>, mixed: bool| {
let k = ColorKey::of(c);
let i = *index.entry(k).or_insert_with(|| {
used.push((k, Used { color: *c, count: 0, swatch: None }));
used.push((k, Used { color: *c, count: 0, swatch: None, plain: None }));
used.len() - 1
});
let u = &mut used[i].1;
u.count += 1;
if u.swatch.is_none() {
u.swatch = link.filter(|l| d.swatch(l).is_some_and(|w| w.global && w.paint.color().is_some())).map(str::to_string);
if u.swatch.is_some() && (u.plain.is_some() || mixed) {
return;
}
if let Some(l) = link.filter(|l| d.swatch(l).is_some_and(|w| w.global && w.paint.color().is_some())) {
if u.swatch.is_none() {
u.swatch = Some(l.to_string());
}
if u.plain.is_none() && !mixed {
u.plain = Some((l.to_string(), tint));
}
}
};
// The patterns used as fills or strokes: their tiles count once each.
// The patterns used as fills or strokes, and the patterns their tiles use: each tile counts
// once, and a pattern whose tile uses itself, directly or through other patterns, counts once.
let mut patterns: Vec<&str> = vec![];
let mut nodes = vec![];
for n in ids.iter().filter_map(|id| d.node(*id)) {
read(n, only, &mut nodes);
}
for m in nodes {
for p in node_paints(m).chain(override_paints(m)) {
match p {
Paint::Solid { color, swatch, .. } => count(color, swatch.as_deref()),
Paint::Gradient(g) => g.gradient.stops.iter().for_each(|s| count(&s.color, s.swatch.as_deref())),
Paint::Pattern { pattern, .. } if !patterns.contains(&pattern.as_str()) => patterns.push(pattern),
_ => {}
}
}
if let NodeKind::Mesh(mesh) = &m.kind {
mesh.points.iter().for_each(|p| count(&p.color, None));
}
paints(m, &mut count_tint, &mut patterns);
}
for def in patterns.iter().filter_map(|p| d.pattern(p)) {
def.art.iter().for_each(|n| node_colors(n, &mut count));
let mut next = 0;
while let Some(&name) = patterns.get(next) {
next += 1;
for a in d.pattern(name).map(|def| def.art.as_slice()).unwrap_or_default() {
a.walk(&mut |m| paints(m, &mut count_tint, &mut patterns));
}
}
used.sort_by(|a, b| b.1.count.cmp(&a.1.count).then(a.0.cmp(&b.0)));
used.into_iter().map(|(_, u)| u).collect()
}
/// Count the colors `m` holds itself with `count` (the color, its swatch, the tint the paint
/// stores, and whether it is a gradient stop that mixes the swatch's ink with process inks), and
/// add the patterns it is painted with to `patterns`.
fn paints<'a>(m: &'a Node, count: &mut impl FnMut(&Color, Option<&str>, Option<f32>, bool), patterns: &mut Vec<&'a str>) {
for p in node_paints(m).chain(override_paints(m)) {
match p {
Paint::Solid { color, swatch, tint } => count(color, swatch.as_deref(), Some(*tint), false),
Paint::Gradient(g) => g.gradient.stops.iter().for_each(|s| count(&s.color, s.swatch.as_deref(), Some(s.tint), s.plates.is_some())),
Paint::Pattern { pattern, .. } if !patterns.contains(&pattern.as_str()) => patterns.push(pattern),
_ => {}
}
}
if let NodeKind::Mesh(mesh) = &m.kind {
mesh.points.iter().for_each(|p| count(&p.color, None, None, false));
}
}
/// The colors `n` shows, in paint order ([`node_colors`]), then the colors of the tiles of the
/// patterns it uses as fills or strokes, and of the patterns those tiles use (each pattern once).
fn shown_colors<'a>(d: &'a Document, n: &'a Node) -> Vec<Color> {
@@ -1054,30 +1086,61 @@ fn scope_ids(s: &Session, p: &Value, cmd: &str) -> Result<(Vec<NodeId>, Option<B
let st = s.doc()?;
let ids = match p.get("ids") {
Some(_) => checked_ids_param(s, p, "ids", cmd)?,
None if st.selection.is_empty() => {
let only = super::select::selectable_ids(&st.doc, st.isolation);
return Ok((super::select::selectable(&st.doc, st.isolation), Some(only)));
}
None if st.selection.is_empty() => return Ok(all_art(st)),
None => st.selection.objects.clone(),
};
let mut seen = BTreeSet::new();
Ok((super::edit::outermost(&st.doc, ids).into_iter().filter(|id| seen.insert(*id)).collect(), None))
}
fn colors(s: &mut Session, p: &Value) -> Result<Value> {
let (ids, only) = scope_ids(s, p, "recolor.colors")?;
let st = s.doc()?;
let v: Vec<Value> = used_colors(&st.doc, &ids, only.as_ref())
.iter()
/// The objects Select All takes, and the objects whose colors count ([`scope_ids`] with nothing
/// selected).
fn all_art(st: &crate::DocState) -> (Vec<NodeId>, Option<BTreeSet<NodeId>>) {
let only = super::select::selectable_ids(&st.doc, st.isolation);
(super::select::selectable(&st.doc, st.isolation), Some(only))
}
/// The `colors` list of `recolor.colors` and `color.used` for the objects `ids` (see
/// [`used_colors`]). Each names the swatch of its first linked use. With `with_color`, each has its
/// color in its own model, and the swatch and tint come from its first linked use that is not a
/// gradient stop mixing the swatch's ink with process inks (none when every linked use is one).
fn colors_json(used: &[Used], with_color: bool) -> Vec<Value> {
used.iter()
.map(|u| {
let mut v = json!({"key": key_str(&u.color), "hex": u.color.to_hex(), "count": u.count});
if let Some(w) = &u.swatch {
if with_color {
v["color"] = json!(u.color);
if let Some((w, tint)) = &u.plain {
v["swatch"] = json!(w);
if let Some(t) = tint {
v["tint"] = json!((f64::from(*t) * 100_000.0).round() / 1000.0);
}
}
} else if let Some(w) = &u.swatch {
v["swatch"] = json!(w);
}
v
})
.collect();
Ok(json!({ "colors": v }))
.collect()
}
fn colors(s: &mut Session, p: &Value) -> Result<Value> {
let (ids, only) = scope_ids(s, p, "recolor.colors")?;
let st = s.doc()?;
Ok(json!({ "colors": colors_json(&used_colors(&st.doc, &ids, only.as_ref()), false) }))
}
/// `color.used {selection?, limit?}`: the colors of the selection, or of the art Select All takes.
fn used(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "color.used";
let limit = super::index_opt(p, "limit", C)?.unwrap_or(usize::MAX);
let selection = switch_or(p, "selection", true, C)? && !s.doc()?.selection.is_empty();
let (ids, only) = if selection { scope_ids(s, &json!({}), C)? } else { all_art(s.doc()?) };
let st = s.doc()?;
let used = used_colors(&st.doc, &ids, only.as_ref());
let uses: usize = used.iter().map(|u| u.count).sum();
let shown = used.get(..limit.min(used.len())).unwrap_or_default();
Ok(json!({ "colors": colors_json(shown, true), "selection": selection, "uses": uses }))
}
/// `recolor.weigh`'s rows as given, each with `from` as a list (a `{current: new}` map gives a
+168
View File
@@ -133,6 +133,174 @@ fn colors_with_nothing_selected_leave_out_what_select_all_leaves_out() {
assert_eq!(hexes(&run(&mut s, "recolor.colors", json!({"ids": [hidden.0]}))), ["#0000ff"]);
}
#[test]
fn used_colors_list_the_most_used_first_with_their_colors() {
let mut s = session();
let reds: Vec<NodeId> = (0..3).map(|_| rect(&mut s, json!("#ff0000"))).collect();
let blue = rect(&mut s, json!({"c": 100, "m": 100, "y": 0, "k": 0}));
run(&mut s, "select.set", json!({"ids": []}));
let r = run(&mut s, "color.used", json!({}));
assert_eq!(r["selection"], false, "{r}");
let colors = r["colors"].as_array().unwrap();
assert_eq!(colors.len(), 2, "{r}");
assert_eq!((colors[0]["key"].as_str(), colors[0]["hex"].as_str(), colors[0]["count"].as_u64()), (Some("rgb 255 0 0"), Some("#ff0000"), Some(3)));
assert_eq!(colors[1]["count"], 1);
let first = run(&mut s, "color.used", json!({"limit": 1}));
assert_eq!(first["colors"], json!([colors[0]]), "`limit` keeps the most used");
assert_eq!((r["uses"].clone(), first["uses"].clone()), (json!(4), json!(4)), "`uses` counts every color");
// `color` is the color in its own model, which the paint commands take back.
assert_eq!(colors[1]["color"]["model"], "cmyk", "{r}");
assert!(close(color_value(&colors[1]["color"]).unwrap(), fill(&s, blue)));
// The selection's colors while something is selected; `selection: false` reads all the art.
run(&mut s, "select.set", json!({"ids": [blue.0]}));
let r = run(&mut s, "color.used", json!({}));
assert_eq!((r["selection"].clone(), r["colors"].as_array().unwrap().len()), (json!(true), 1), "{r}");
let all = run(&mut s, "color.used", json!({"selection": false}));
assert_eq!((all["selection"].clone(), all["colors"][0]["count"].clone()), (json!(false), json!(3)), "{all}");
assert_eq!(s.doc().unwrap().selection.objects, [blue], "the selection is left as it was");
// A hidden object's color is left out with nothing selected, as Select All leaves it out.
run(&mut s, "object.hide", json!({"ids": [reds[0].0]}));
assert_eq!(run(&mut s, "color.used", json!({"selection": false}))["colors"][0]["count"], 2);
let e = s.execute("color.used", &json!({"selection": "no"})).unwrap_err().to_string();
assert!(e.contains("`selection` must be true or false"), "{e}");
assert!(s.execute("color.used", &json!({"ids": [blue.0]})).is_err(), "an unknown key is refused");
}
#[test]
fn used_colors_name_the_swatch_and_tint_a_color_is_linked_to() {
let mut s = session();
run(&mut s, "swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
let tinted = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [tinted.0], "swatch": "Ink", "tint": 40}));
run(&mut s, "select.set", json!({"ids": []}));
let r = run(&mut s, "color.used", json!({}));
let c = &r["colors"][0];
assert_eq!(c["swatch"].as_str(), Some("Ink"), "{r}");
assert!((c["tint"].as_f64().unwrap() - 40.0).abs() < 1e-4, "{r}");
// recolor.colors keeps its own fields.
assert_eq!(run(&mut s, "recolor.colors", json!({}))["colors"][0].get("tint"), None);
// A swatch of paper white looks the same at every tint; the tint comes from the paint.
run(&mut s, "swatch.new", json!({"name": "Paper", "color": {"c": 0, "m": 0, "y": 0, "k": 0}, "spot": true}));
let paper = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [paper.0], "swatch": "Paper", "tint": 33.333}));
run(&mut s, "select.set", json!({"ids": [paper.0]}));
let c = run(&mut s, "color.used", json!({}))["colors"][0].clone();
assert_eq!(c["swatch"].as_str(), Some("Paper"), "{c}");
// The tint is the paint's own, unrounded.
let vectorcraft_color::Paint::Solid { tint, .. } = s.doc().unwrap().doc.node(paper).unwrap().appearance.fill_paint() else {
panic!("a solid fill")
};
assert_eq!((c["tint"].as_f64().unwrap() / 100.0) as f32, tint, "{c}");
assert!((tint - 0.33333).abs() < 1e-5);
// A pattern's tile keeps its tint as well.
run(&mut s, "select.set", json!({"ids": [paper.0]}));
run(&mut s, "object.pattern.make", json!({"name": "Sheet", "width": 20, "height": 20}));
run(&mut s, "object.pattern.done", json!({}));
let filled = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [filled.0], "swatch": "Sheet"}));
run(&mut s, "select.set", json!({"ids": [filled.0]}));
let c = run(&mut s, "color.used", json!({}))["colors"][0].clone();
assert_eq!(c["swatch"].as_str(), Some("Paper"), "{c}");
assert_eq!((c["tint"].as_f64().unwrap() / 100.0) as f32, tint, "{c}");
}
#[test]
fn used_colors_read_the_tiles_of_patterns_used_inside_pattern_tiles() {
let mut s = session();
let red = rect(&mut s, json!("#ff0000"));
run(&mut s, "select.set", json!({"ids": [red.0]}));
run(&mut s, "object.pattern.make", json!({"name": "Inner", "width": 20, "height": 20}));
run(&mut s, "object.pattern.done", json!({}));
let middle = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [middle.0], "swatch": "Inner"}));
run(&mut s, "select.set", json!({"ids": [middle.0]}));
run(&mut s, "object.pattern.make", json!({"name": "Outer", "width": 20, "height": 20}));
run(&mut s, "object.pattern.done", json!({}));
let square = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [square.0], "swatch": "Outer"}));
// The inner tile's square is stroked with the outer pattern, so the two patterns use each other.
let outer = s.doc().unwrap().doc.node(square).unwrap().appearance.fill_paint().clone();
let st = s.doc_mut().unwrap();
let doc = std::sync::Arc::make_mut(&mut st.doc);
let tile = doc.pattern_mut("Inner").unwrap().art.first_mut().unwrap();
std::sync::Arc::make_mut(tile).appearance.set_stroke(outer);
run(&mut s, "select.set", json!({"ids": [square.0]}));
let r = run(&mut s, "color.used", json!({}));
let colors = r["colors"].as_array().unwrap();
assert_eq!(colors.iter().map(|c| (c["hex"].as_str(), c["count"].as_u64())).collect::<Vec<_>>(), [(Some("#ff0000"), Some(1))], "{r}");
}
#[test]
fn used_colors_give_no_swatch_for_a_stop_that_mixes_its_ink_with_process_inks() {
use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop, Paint};
let mut s = session();
run(&mut s, "swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
let shape = rect(&mut s, json!("#000000"));
let mixed = Color::Cmyk { c: 0.3, m: 0.5, y: 0.3, k: 0.0 };
let stop = |color, plates| GradientStop { swatch: Some("Ink".into()), tint: 0.5, plates, ..GradientStop::new(0.0, color) };
let mut end = stop(Color::Cmyk { c: 0.0, m: 0.5, y: 0.3, k: 0.0 }, None);
end.offset = 1.0;
let g = Gradient::new(GradientKind::Linear, vec![stop(mixed, Some([0.3, 0.0, 0.0, 0.0])), end]);
let st = s.doc_mut().unwrap();
std::sync::Arc::make_mut(&mut st.doc).node_mut(shape).unwrap().appearance.set_fill(Paint::Gradient(Box::new(GradientPaint::new(g))));
let r = run(&mut s, "color.used", json!({}));
let entry = |key: &str| r["colors"].as_array().unwrap().iter().find(|c| c["key"] == key).cloned().unwrap();
let mix = entry("cmyk 30 50 30 0");
assert_eq!((mix.get("swatch"), mix.get("tint")), (None, None), "{r}");
assert_eq!(entry("cmyk 0 50 30 0")["swatch"], "Ink", "{r}");
// recolor.colors keeps the swatch it lists.
let listed = run(&mut s, "recolor.colors", json!({}));
assert!(listed["colors"].as_array().unwrap().iter().all(|c| c["swatch"] == "Ink"), "{listed}");
}
#[test]
fn used_colors_take_the_swatch_of_a_plain_use_painted_after_a_mixed_stop_of_the_same_color() {
use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop, Paint};
let mut s = session();
run(&mut s, "swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
let shape = rect(&mut s, json!("#000000"));
let plain = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [plain.0], "swatch": "Ink", "tint": 50}));
let ink = fill(&s, plain);
// The stop below the plain fill has the same color, and process plates that add nothing.
let stop = GradientStop { swatch: Some("Ink".into()), tint: 0.5, plates: Some([0.0; 4]), ..GradientStop::new(0.0, ink) };
let mut end = stop.clone();
end.offset = 1.0;
let g = Gradient::new(GradientKind::Linear, vec![stop, end]);
let st = s.doc_mut().unwrap();
std::sync::Arc::make_mut(&mut st.doc).node_mut(shape).unwrap().appearance.set_fill(Paint::Gradient(Box::new(GradientPaint::new(g))));
run(&mut s, "select.set", json!({"ids": []}));
let r = run(&mut s, "color.used", json!({}));
let c = r["colors"].as_array().unwrap().iter().find(|c| c["count"] == 3).cloned().unwrap();
assert_eq!((c["swatch"].as_str(), c["tint"].as_f64()), (Some("Ink"), Some(50.0)), "{r}");
}
#[test]
fn recolor_colors_keeps_the_swatch_of_the_first_linked_use_when_a_mixed_stop_comes_first() {
use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop, Paint};
let mut s = session();
run(&mut s, "swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
run(&mut s, "swatch.new", json!({"name": "Other", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true}));
let shape = rect(&mut s, json!("#000000"));
let plain = rect(&mut s, json!("#000000"));
run(&mut s, "paint.setFill", json!({"ids": [plain.0], "swatch": "Other", "tint": 50}));
let ink = fill(&s, plain);
// The stop below the plain fill has the same color, linked to another swatch, with process
// plates that add nothing.
let stop = GradientStop { swatch: Some("Ink".into()), tint: 0.5, plates: Some([0.0; 4]), ..GradientStop::new(0.0, ink) };
let mut end = stop.clone();
end.offset = 1.0;
let g = Gradient::new(GradientKind::Linear, vec![stop, end]);
let st = s.doc_mut().unwrap();
std::sync::Arc::make_mut(&mut st.doc).node_mut(shape).unwrap().appearance.set_fill(Paint::Gradient(Box::new(GradientPaint::new(g))));
run(&mut s, "select.set", json!({"ids": []}));
let three = |r: &Value| r["colors"].as_array().unwrap().iter().find(|c| c["count"] == 3).cloned().unwrap();
let used = run(&mut s, "color.used", json!({}));
assert_eq!(three(&used)["swatch"], "Other", "{used}");
let listed = run(&mut s, "recolor.colors", json!({}));
assert_eq!(three(&listed)["swatch"], "Ink", "recolor.colors names the first linked use: {listed}");
}
#[test]
fn colors_with_nothing_selected_leave_out_hidden_and_locked_objects_in_groups() {
let mut s = session();
+1 -1
View File
@@ -1579,7 +1579,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.colorWheel",
"Color Wheel Options",
"",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, gamut, harmony, harmonyRule, vision}",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool, documentColors?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; documentColors shows or hides the row the panel menu's Show Document Colors adds under the wheel or the box: the colors color.used {} lists, headed Selection Colors when something is selected and Document Colors otherwise, most used first and as many as fit in one row (a chip's tooltip gives its hex value and how many times the art uses it; a click applies it to the active proxy or to the selected gradient stop, keeping its color model and its link to a global swatch, or to the selected freeform point, which takes the color alone, and Alt+click applies it to the other proxy; the row reads the colors again when the document or the selection changes, not during a drag, and in art with more than 5,000 color uses at most once every half second after an edit); keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors}",
),
(
"ui.savePdfDialog",
+4
View File
@@ -594,6 +594,10 @@ font-technology Variable Променливи
Box Channel Канал на квадрата
Color box Цветови квадрат
Color Wheel Options Опции на цветното колело
Show Document Colors Показване на цветовете на документа
Document Colors Цветове на документа
Selection Colors Цветове на селекцията
@plural Used {n} time|Used {n} times Използван {n} път|Използван {n} пъти
Show Harmony Показване на хармонията
Harmony Rule Правило за хармония
Harmony color Цвят от хармонията
Can't render this file because it is too large.
+4
View File
@@ -823,6 +823,10 @@
Box Channel Kanal kvadrata
Color box Kvadrat boje
Color Wheel Options Opcije kotača boja
Show Document Colors Prikaži boje dokumenta
Document Colors Boje dokumenta
Selection Colors Boje odabira
@plural Used {n} time|Used {n} times Korišteno {n} put|Korišteno {n} puta|Korišteno {n} puta
Show Harmony Prikaži harmoniju
Harmony Rule Pravilo harmonije
Harmony color Boja harmonije
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -895,6 +895,10 @@ arrowhead Target Diana
Box Channel Canal del quadre
Color box Quadre de color
Color Wheel Options Opcions de la roda de colors
Show Document Colors Mostra els colors del document
Document Colors Colors del document
Selection Colors Colors de la selecció
@plural Used {n} time|Used {n} times Utilitzat {n} vegada|Utilitzat {n} vegades
Show Harmony Mostra l’harmonia
Harmony Rule Regla d’harmonia
Harmony color Color de l’harmonia
Can't render this file because it is too large.
+4
View File
@@ -835,6 +835,10 @@
Box Channel Kanál čtverce
Color box Barevný čtverec
Color Wheel Options Možnosti barevného kola
Show Document Colors Zobrazit barvy dokumentu
Document Colors Barvy dokumentu
Selection Colors Barvy výběru
@plural Used {n} time|Used {n} times Použito {n}krát|Použito {n}krát|Použito {n}krát
Show Harmony Zobrazit harmonii
Harmony Rule Pravidlo harmonie
Harmony color Barva harmonie
Can't render this file because it is too large.
+4
View File
@@ -3535,6 +3535,10 @@ liquify-list-end {0}, {1} {0} og {1}
Box Channel Kvadratets kanal
Color box Farvekvadrat
Color Wheel Options Indstillinger for farvehjul
Show Document Colors Vis dokumentfarver
Document Colors Dokumentfarver
Selection Colors Markeringens farver
@plural Used {n} time|Used {n} times Brugt {n} gang|Brugt {n} gange
Show Harmony Vis harmoni
Harmony Rule Harmoniregel
Harmony color Harmonifarve
Can't render this file because it is too large.
+4
View File
@@ -599,6 +599,10 @@ font-technology Variable Variabel
Box Channel Kanal des Quadrats
Color box Farbquadrat
Color Wheel Options Optionen für den Farbkreis
Show Document Colors Dokumentfarben einblenden
Document Colors Dokumentfarben
Selection Colors Farben der Auswahl
@plural Used {n} time|Used {n} times {n}-mal verwendet|{n}-mal verwendet
Show Harmony Harmonie einblenden
Harmony Rule Harmonieregel
Harmony color Harmoniefarbe
Can't render this file because it is too large.
+4
View File
@@ -573,6 +573,10 @@ font-technology Variable Μεταβλητές
Box Channel Κανάλι τετραγώνου
Color box Τετράγωνο χρώματος
Color Wheel Options Επιλογές χρωματικού τροχού
Show Document Colors Εμφάνιση χρωμάτων εγγράφου
Document Colors Χρώματα εγγράφου
Selection Colors Χρώματα επιλογής
@plural Used {n} time|Used {n} times Χρησιμοποιείται {n} φορά|Χρησιμοποιείται {n} φορές
Show Harmony Εμφάνιση αρμονίας
Harmony Rule Κανόνας χρωματικής αρμονίας
Harmony color Χρώμα αρμονίας
Can't render this file because it is too large.
+4
View File
@@ -618,6 +618,10 @@ font-technology Variable Variables
Box Channel Canal del cuadro
Color box Cuadro de color
Color Wheel Options Opciones de la rueda de color
Show Document Colors Mostrar colores del documento
Document Colors Colores del documento
Selection Colors Colores de la selección
@plural Used {n} time|Used {n} times Usado {n} vez|Usado {n} veces
Show Harmony Mostrar armonía
Harmony Rule Regla de armonía
Harmony color Color de la armonía
Can't render this file because it is too large.
+4
View File
@@ -821,6 +821,10 @@
Box Channel Ruudun kanava
Color box Väriruutu
Color Wheel Options Väriympyrän asetukset
Show Document Colors Näytä asiakirjan värit
Document Colors Asiakirjan värit
Selection Colors Valinnan värit
@plural Used {n} time|Used {n} times Käytetty {n} kerran|Käytetty {n} kertaa
Show Harmony Näytä harmonia
Harmony Rule Harmoniasääntö
Harmony color Harmonian väri
Can't render this file because it is too large.
+4
View File
@@ -619,6 +619,10 @@ font-technology Variable Variables
Box Channel Couche du carré
Color box Carré de couleur
Color Wheel Options Options de la roue chromatique
Show Document Colors Afficher les couleurs du document
Document Colors Couleurs du document
Selection Colors Couleurs de la sélection
@plural Used {n} time|Used {n} times Utilisée {n} fois|Utilisée {n} fois
Show Harmony Afficher l’harmonie
Harmony Rule Règle d’harmonie
Harmony color Couleur de l’harmonie
Can't render this file because it is too large.
+4
View File
@@ -4825,6 +4825,10 @@ arrowhead Feather પીંછું
Box Channel બૉક્સ ચેનલ
Color box રંગ બૉક્સ
Color Wheel Options રંગ વ્હીલ વિકલ્પો
Show Document Colors દસ્તાવેજના રંગો બતાવો
Document Colors દસ્તાવેજના રંગો
Selection Colors પસંદગીના રંગો
@plural Used {n} time|Used {n} times {n} વાર વપરાયો|{n} વાર વપરાયો
Show Harmony હાર્મની બતાવો
Harmony Rule હાર્મની નિયમ
Harmony color હાર્મની રંગ
Can't render this file because it contains an unexpected character in line 72 and column 5.
+4
View File
@@ -1281,6 +1281,10 @@ arrowhead Feather पंख
Box Channel बॉक्स चैनल
Color box कलर बॉक्स
Color Wheel Options कलर व्हील ऑप्शन्स
Show Document Colors डॉक्यूमेंट के रंग दिखाएँ
Document Colors डॉक्यूमेंट के रंग
Selection Colors चयन के रंग
@plural Used {n} time|Used {n} times {n} बार उपयोग किया गया|{n} बार उपयोग किया गया
Show Harmony सद्भाव दिखाएँ
Harmony Rule सद्भाव नियम
Harmony color सद्भाव रंग
Can't render this file because it is too large.
+4
View File
@@ -822,6 +822,10 @@ arrowhead Target Céltábla
Box Channel Négyzet csatornája
Color box Színnégyzet
Color Wheel Options Színkör beállításai
Show Document Colors Dokumentumszínek megjelenítése
Document Colors Dokumentumszínek
Selection Colors A kijelölés színei
@plural Used {n} time|Used {n} times {n} alkalommal használva
Show Harmony Harmónia megjelenítése
Harmony Rule Harmóniaszabály
Harmony color Harmóniaszín
Can't render this file because it is too large.
+4
View File
@@ -1412,6 +1412,10 @@
Box Channel Saluran kotak
Color box Kotak warna
Color Wheel Options Opsi roda warna
Show Document Colors Tampilkan warna dokumen
Document Colors Warna dokumen
Selection Colors Warna pilihan
@plural Used {n} time|Used {n} times Dipakai {n} kali
Show Harmony Tampilkan harmoni
Harmony Rule Aturan harmoni
Harmony color Warna harmoni
Can't render this file because it is too large.
+4
View File
@@ -621,6 +621,10 @@ font-technology Variable Variabili
Box Channel Canale del riquadro
Color box Riquadro colore
Color Wheel Options Opzioni ruota dei colori
Show Document Colors Mostra colori del documento
Document Colors Colori del documento
Selection Colors Colori della selezione
@plural Used {n} time|Used {n} times Usato {n} volta|Usato {n} volte
Show Harmony Mostra armonia
Harmony Rule Regola di armonia
Harmony color Colore dell’armonia
Can't render this file because it is too large.
+4
View File
@@ -872,6 +872,10 @@ digits Malayalam マラヤーラム数字
Box Channel ボックスのチャンネル
Color box カラーボックス
Color Wheel Options カラーホイールオプション
Show Document Colors ドキュメントのカラーを表示
Document Colors ドキュメントのカラー
Selection Colors 選択範囲のカラー
@plural Used {n} time|Used {n} times {n} 回使用
Show Harmony ハーモニーを表示
Harmony Rule ハーモニールール
Harmony color ハーモニーカラー
Can't render this file because it is too large.
+4
View File
@@ -2945,6 +2945,10 @@
Box Channel კვადრატის არხი
Color box ფერის კვადრატი
Color Wheel Options ფერთა წრის პარამეტრები
Show Document Colors დოკუმენტის ფერების ჩვენება
Document Colors დოკუმენტის ფერები
Selection Colors მონიშნულის ფერები
@plural Used {n} time|Used {n} times გამოყენებულია {n}-ჯერ
Show Harmony ჰარმონიის ჩვენება
Harmony Rule ჰარმონიის წესი
Harmony color ჰარმონიის ფერი
Can't render this file because it is too large.
+4
View File
@@ -865,6 +865,10 @@ digits Malayalam 말라얄람어
Box Channel 상자 채널
Color box 색상 상자
Color Wheel Options 색상환 옵션
Show Document Colors 문서 색상 표시
Document Colors 문서 색상
Selection Colors 선택 영역 색상
@plural Used {n} time|Used {n} times {n}회 사용
Show Harmony 하모니 표시
Harmony Rule 하모니 규칙
Harmony color 하모니 색상
Can't render this file because it is too large.
+4
View File
@@ -1401,6 +1401,10 @@ liquify-list-end {0}, {1} {0} en {1}
Box Channel Kanaal van het vak
Color box Kleurvak
Color Wheel Options Opties voor kleurenwiel
Show Document Colors Documentkleuren tonen
Document Colors Documentkleuren
Selection Colors Kleuren van de selectie
@plural Used {n} time|Used {n} times {n} keer gebruikt|{n} keer gebruikt
Show Harmony Harmonie tonen
Harmony Rule Harmonieregel
Harmony color Harmoniekleur
Can't render this file because it is too large.
+4
View File
@@ -784,6 +784,10 @@
Box Channel Kanał kwadratu
Color box Kwadrat koloru
Color Wheel Options Opcje koła kolorów
Show Document Colors Pokaż kolory dokumentu
Document Colors Kolory dokumentu
Selection Colors Kolory zaznaczenia
@plural Used {n} time|Used {n} times Użyty {n} raz|Użyty {n} razy|Użyty {n} razy
Show Harmony Pokaż harmonię
Harmony Rule Reguła harmonii
Harmony color Kolor harmonii
Can't render this file because it is too large.
+4
View File
@@ -557,6 +557,10 @@ antiAlias Sharp Nítido
Box Channel Canal da Caixa
Color box Caixa de cor
Color Wheel Options Opções da Roda de Cores
Show Document Colors Mostrar Cores do Documento
Document Colors Cores do Documento
Selection Colors Cores da Seleção
@plural Used {n} time|Used {n} times Usada {n} vez|Usada {n} vezes
Show Harmony Mostrar Harmonia
Harmony Rule Regra de Harmonia
Harmony color Cor da harmonia
Can't render this file because it is too large.
+4
View File
@@ -616,6 +616,10 @@ font-technology Variable Вариативные
Box Channel Канал квадрата
Color box Цветовой квадрат
Color Wheel Options Параметры цветового круга
Show Document Colors Показать цвета документа
Document Colors Цвета документа
Selection Colors Цвета выделения
@plural Used {n} time|Used {n} times Используется {n} раз|Используется {n} раза|Используется {n} раз
Show Harmony Показать гармонию
Harmony Rule Правило гармонии
Harmony color Цвет гармонии
Can't render this file because it is too large.
+4
View File
@@ -601,6 +601,10 @@ font-technology Variable Variabla
Box Channel Rutans kanal
Color box Färgruta
Color Wheel Options Alternativ för färghjulet
Show Document Colors Visa dokumentfärger
Document Colors Dokumentfärger
Selection Colors Markeringens färger
@plural Used {n} time|Used {n} times Används {n} gång|Används {n} gånger
Show Harmony Visa harmoni
Harmony Rule Harmoniregel
Harmony color Harmonifärg
Can't render this file because it is too large.
+4
View File
@@ -599,6 +599,10 @@ font-technology Variable Değişken
Box Channel Kutu Kanalı
Color box Renk kutusu
Color Wheel Options Renk Tekerleği Seçenekleri
Show Document Colors Belge Renklerini Göster
Document Colors Belge Renkleri
Selection Colors Seçim Renkleri
@plural Used {n} time|Used {n} times {n} kez kullanıldı
Show Harmony Uyumu Göster
Harmony Rule Uyum Kuralı
Harmony color Uyum rengi
Can't render this file because it is too large.
+4
View File
@@ -615,6 +615,10 @@ font-technology Variable Варіативні
Box Channel Канал квадрата
Color box Колірний квадрат
Color Wheel Options Параметри колірного кола
Show Document Colors Показати кольори документа
Document Colors Кольори документа
Selection Colors Кольори виділення
@plural Used {n} time|Used {n} times Використано {n} раз|Використано {n} рази|Використано {n} разів
Show Harmony Показати гармонію
Harmony Rule Правило гармонії
Harmony color Колір гармонії
Can't render this file because it is too large.
+4
View File
@@ -734,6 +734,10 @@ font-technology Variable Biến thiên
Box Channel Kênh của hộp
Color box Hộp màu
Color Wheel Options Tùy chọn bánh xe màu
Show Document Colors Hiện màu của tài liệu
Document Colors Màu của tài liệu
Selection Colors Màu của vùng chọn
@plural Used {n} time|Used {n} times Dùng {n} lần
Show Harmony Hiện hài hòa màu
Harmony Rule Quy tắc hài hòa màu
Harmony color Màu hài hòa
Can't render this file because it is too large.
+4
View File
@@ -565,6 +565,10 @@ antiAlias Sharp 锐利
Box Channel 方块色版
Color box 颜色方块
Color Wheel Options 色轮选项
Show Document Colors 显示文档颜色
Document Colors 文档颜色
Selection Colors 所选对象的颜色
@plural Used {n} time|Used {n} times 使用 {n} 次
Show Harmony 显示协调
Harmony Rule 协调规则
Harmony color 协调颜色
Can't render this file because it is too large.
+4
View File
@@ -583,6 +583,10 @@ font-technology Variable 可變
Box Channel 方塊色版
Color box 顏色方塊
Color Wheel Options 色輪選項
Show Document Colors 顯示文件顏色
Document Colors 文件顏色
Selection Colors 所選物件的顏色
@plural Used {n} time|Used {n} times 使用 {n} 次
Show Harmony 顯示色彩調和
Harmony Rule 色彩調和規則
Harmony color 調和色彩
Can't render this file because it is too large.
+1 -1
View File
@@ -1580,7 +1580,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
"ui.colorWheel",
"Color Wheel Options",
"",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, gamut, harmony, harmonyRule, vision}",
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, sliders?: none|oklch|hsl, gamut?: bool, harmony?: bool, harmonyRule?: complementary|splitComplementary|leftComplement|rightComplement|analogous|analogous2|triad|tetrad|tetrad2|tetrad3|compound|compound2|highContrast|highContrast3|pentagram, vision?: bool, documentColors?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, pick the box's channel, as Box Channel does, and show no slider rows under the wheel or the box (none), OKLCH Sliders (oklch) or HSL Sliders (hsl), as the menu items of those names do: the box is a color field with the channel's strip at its right, and the field shows the other two components (hue: saturation across and brightness up; saturation: hue across and brightness up; brightness: hue across and saturation up; red: blue across and green up; green: blue across and red up; blue: red across and green up); OKLCH Sliders edit lightness 0 to 100 %, chroma 0 to 100 % of 0.4 and hue 0 to 360°, CSS Color 4's OKLCH of the display sRGB, and a color outside sRGB keeps L and H and takes the largest chroma that fits; HSL Sliders edit hue 0 to 360°, saturation 0 to 100 % and lightness 0 to 100 %, CSS Color 4's HSL of the display sRGB; gamut true grays out the parts of the wheel's square and the box's field whose colors the CMYK space cannot print (the out-of-gamut warning's test, as color.gamutCheck answers it), as Show Out-of-Gamut Colors does, and false shows them again; the shading is approximate: each cell of a 16 by 16 grid over the square or the field is grayed out or not by the color at its center, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot print; harmony shows a marker on the wheel's ring for each other color of harmonyRule (the Color Guide's rule of that id; a rule's label is taken too), as Show Harmony and Harmony Rule do, and a click on a marker applies its color; vision shows Show Color Vision Preview's row under the wheel or the box, four chips with the current color as simulated for protanopia, deuteranopia and tritanopia (the simulations of view.proofSetup's protanopia, deuteranopia and tritanopia targets) and for achromatopsia (the gray with the color's CIE L*), each named with its hex value in its tooltip and to screen readers, and taking the keyboard focus; a click or a key on a chip does not apply its color; documentColors shows or hides the row the panel menu's Show Document Colors adds under the wheel or the box: the colors color.used {} lists, headed Selection Colors when something is selected and Document Colors otherwise, most used first and as many as fit in one row (a chip's tooltip gives its hex value and how many times the art uses it; a click applies it to the active proxy or to the selected gradient stop, keeping its color model and its link to a global swatch, or to the selected freeform point, which takes the color alone, and Alt+click applies it to the other proxy; the row reads the colors again when the document or the selection changes, not during a drag, and in art with more than 5,000 color uses at most once every half second after an edit); keys left out or null keep their values ({} reads them), params that are not an object, another key or a value off the list are an error and change nothing, oklch is an error while the working RGB space is not sRGB, the settings are kept with the preferences, and the command does not open the panel (window.panel {panel: \"colorWheel\"} does) (ui.inspect: ui.color_wheel) → {view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors}",
),
(
"ui.savePdfDialog",
+2
View File
@@ -890,6 +890,8 @@ mod tests_color_wheel;
#[cfg(test)]
mod tests_color_wheel_box;
#[cfg(test)]
mod tests_color_wheel_document_colors;
#[cfg(test)]
mod tests_color_wheel_gamut;
#[cfg(test)]
mod tests_color_wheel_harmony;
+184 -10
View File
@@ -27,6 +27,11 @@
//! Setup uses, and for achromatopsia as the gray with the color's CIE L*. The chips only show the
//! simulation.
//!
//! The panel menu's Show Document Colors adds a row under the wheel or the box with the colors
//! of the selection, or with nothing selected of the art Select All takes, most used first
//! (`color.used`). A click on one applies it as a pick does. The active proxy and a selected
//! gradient stop keep its swatch link; a freeform point takes the color alone.
//!
//! Panel menu › OKLCH Sliders shows L, C and H rows under the wheel or the box that edit the color
//! by OKLCH lightness, chroma and hue (CSS Color 4:
//! <https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch>), while the active document's RGB
@@ -36,8 +41,12 @@
//! (<https://www.w3.org/TR/css-color-4/#the-hsl-notation>). The choice is kept with the
//! preferences too.
//!
//! The view, the channel, the slider rows, Show Out-of-Gamut Colors, Show Harmony, Harmony Rule
//! and Show Color Vision Preview are kept with the preferences (`ui.colorWheel`).
//! The view, the channel, the slider rows, Show Out-of-Gamut Colors, Show Harmony, Harmony Rule,
//! Show Color Vision Preview and Show Document Colors are kept with the preferences
//! (`ui.colorWheel`).
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use egui::{Color32, Rect, Sense, Stroke, StrokeKind, Ui, UiBuilder, pos2, vec2};
use serde::{Deserialize, Serialize};
@@ -112,6 +121,9 @@ pub struct Settings {
/// `true` shows the row and any other value hides it.
#[serde(deserialize_with = "crate::panels::color::deserialize_rgb_percent")]
pub vision: bool,
/// Show Document Colors: the row of the colors the art uses, under the wheel or the box.
#[serde(deserialize_with = "deserialize_flag")]
pub document_colors: bool,
}
/// The slider rows under the wheel or the box (panel menu, `ui.colorWheel {sliders}`).
@@ -158,6 +170,7 @@ impl Default for Settings {
harmony: false,
harmony_rule: Harmony::Complementary,
vision: false,
document_colors: false,
}
}
}
@@ -208,11 +221,12 @@ pub fn deserialize_settings<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Se
Ok(serde_json::from_value(v).unwrap_or_default())
}
/// `ui.colorWheel {view?, channel?, sliders?, gamut?, harmony?, harmonyRule?, vision?}`: show the
/// wheel or the box, pick the box's channel, show OKLCH Sliders, HSL Sliders or neither, show or
/// hide the out-of-gamut shading, show the colors of a harmony rule on the wheel, and show or hide
/// the color vision row. Keys left out or null keep their values; params that are not an object,
/// another key or a value off the list are an error and change nothing.
/// `ui.colorWheel {view?, channel?, sliders?, gamut?, harmony?, harmonyRule?, vision?,
/// documentColors?}`: show the wheel or the box, pick the box's channel, show OKLCH Sliders, HSL
/// Sliders or neither, show or hide the out-of-gamut shading, show the colors of a harmony rule on
/// the wheel, and show or hide the color vision row and the Show Document Colors row. Keys left
/// out or null keep their values; params that are not an object, another key or a value off the
/// list are an error and change nothing.
/// `sliders: "oklch"` is an error while the active document's RGB space (its assigned profile,
/// else the working RGB space) is not sRGB. → the settings.
pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
@@ -223,7 +237,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, Stri
/// Set the keys of `ui.colorWheel` params `p` in `settings`, with the color settings `cms`; on an
/// error `settings` stay as they were.
pub(crate) fn set(settings: &mut Settings, p: &Value, cms: &Cms) -> Result<(), String> {
const KEYS: [&str; 7] = ["view", "channel", "sliders", "gamut", "harmony", "harmonyRule", "vision"];
const KEYS: [&str; 8] = ["view", "channel", "sliders", "gamut", "harmony", "harmonyRule", "vision", "documentColors"];
match p {
Value::Null => {}
Value::Object(o) => {
@@ -275,13 +289,16 @@ pub(crate) fn set(settings: &mut Settings, p: &Value, cms: &Cms) -> Result<(), S
if let Some(on) = crate::menus::opt_bool(p, "vision")? {
set.vision = on;
}
if let Some(on) = crate::menus::opt_bool(p, "documentColors")? {
set.document_colors = on;
}
*settings = set;
Ok(())
}
/// The panel menu: Wheel View and Box View, and Box Channel while the box shows; Show Out-of-Gamut
/// Colors; HSL Sliders and OKLCH Sliders; Show Harmony and Harmony Rule while the wheel shows; and
/// Show Color Vision Preview.
/// Colors; HSL Sliders and OKLCH Sliders; Show Harmony and Harmony Rule while the wheel shows; Show
/// Color Vision Preview; and Show Document Colors.
pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
let set = app.ui.color_wheel.clone();
for (label, view) in [(tl!("Wheel View"), View::Wheel), (tl!("Box View"), View::Box)] {
@@ -333,6 +350,157 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
if menu_item(ui, tl!("Show Color Vision Preview"), true, set.vision) {
command(app, &json!({ "vision": !set.vision })).ok();
}
if menu_item(ui, tl!("Show Document Colors"), true, set.document_colors) {
command(app, &json!({ "documentColors": !set.document_colors })).ok();
}
}
/// Panel state: the Show Document Colors row's colors, with the [`UsedKey`] they were read for.
const USED: &str = "color-wheel-used";
/// The fewest chips the row asks `color.used` for; a row wider than this many chips asks for as
/// many as it holds.
const MAX_CHIPS: usize = 128;
/// Above this many color uses, an edit makes the row read the colors again at most once every
/// [`LARGE_EVERY`] seconds; a change of document or selection still reads them at once.
const LARGE_USES: u64 = 5_000;
const LARGE_EVERY: f64 = 0.5;
/// What the Show Document Colors row depends on: the document, its revision, and the number of
/// selected objects with a hash of their ids.
type UsedKey = Option<(u64, u64, usize, u64)>;
/// The row's colors as last read, kept in the panel state behind an `Arc`, so a frame that reads
/// them back copies no list.
#[derive(Debug, PartialEq)]
struct UsedCache {
key: UsedKey,
/// The frame time the colors were read at.
at: f64,
/// The uses of every color (`color.used`'s `uses`).
uses: u64,
/// Whether the colors are the selection's.
selected: bool,
/// The most colors asked for.
limit: usize,
colors: Vec<Used>,
}
/// A color of the row: the color, its hex value, how many times the art uses it, and the global
/// swatch it is linked to with the tint (0..1) of that swatch it is.
#[derive(Clone, Debug, PartialEq)]
struct Used {
color: Color,
hex: String,
count: u64,
link: Option<(String, f32)>,
}
impl Used {
/// The paint the color applies and drags: linked to its swatch at its tint when it has one.
fn paint(&self) -> Paint {
match &self.link {
Some((name, tint)) => Paint::Solid { color: self.color, swatch: Some(name.clone()), tint: *tint },
None => Paint::solid(self.color),
}
}
}
/// The colors the row shows and whether they are the selection's, read with `color.used` once per
/// document revision and selection and kept as they are while an interaction is in progress (a
/// preview raises the revision on every frame of a drag). In art with more than [`LARGE_USES`]
/// color uses, an edit reads them again only after [`LARGE_EVERY`] seconds. A row that holds more
/// than the colors last asked for reads them again once no interaction is in progress, and in such
/// art only after the same wait.
fn used_colors(app: &mut VectorcraftApp, ui: &Ui, per_row: usize) -> Arc<UsedCache> {
let limit = per_row.max(MAX_CHIPS);
let key: UsedKey = app.session.active().map(|d| {
let mut h = std::collections::hash_map::DefaultHasher::new();
d.selection.objects.hash(&mut h);
(d.uid, d.revision, d.selection.objects.len(), h.finish())
});
let now = ui.input(|i| i.time);
if let Some(cache) = pstate::<Option<Arc<UsedCache>>>(ui.ctx(), USED) {
let fits = cache.limit >= per_row || cache.colors.len() < cache.limit;
if app.session.in_interaction() || (cache.key == key && fits) {
return cache;
}
let scope = |k: &UsedKey| k.map(|(doc, _, n, h)| (doc, n, h));
let wait = LARGE_EVERY - (now - cache.at);
if cache.uses > LARGE_USES && scope(&cache.key) == scope(&key) && wait > 0.0 {
ui.ctx().request_repaint_after_secs(wait as f32);
return cache;
}
}
let r = key.as_ref().and_then(|_| app.session.execute("color.used", &json!({ "limit": limit })).ok());
let colors: Vec<Used> = r
.as_ref()
.and_then(|r| r["colors"].as_array())
.map(|a| {
a.iter()
.filter_map(|c| {
let color = serde_json::from_value::<Color>(c["color"].clone()).ok()?;
let hex = c["hex"].as_str().map_or_else(|| color.to_hex(), str::to_string);
let link = c["swatch"].as_str().zip(c["tint"].as_f64()).map(|(n, t)| (n.to_string(), (t / 100.0).clamp(0.0, 1.0) as f32));
Some(Used { color, hex, count: c["count"].as_u64().unwrap_or(0), link })
})
.collect()
})
.unwrap_or_default();
let selected = r.as_ref().is_some_and(|r| r["selection"] == true);
let uses = r.as_ref().and_then(|r| r["uses"].as_u64()).unwrap_or(0);
let cache = Arc::new(UsedCache { key, at: now, uses, selected, limit, colors });
set_pstate(ui.ctx(), USED, Some(Arc::clone(&cache)));
cache
}
/// The Show Document Colors row: a heading (Selection Colors or Document Colors) and the colors,
/// most used first, as many as fit in one row. Returns the color clicked.
fn document_colors_row(app: &mut VectorcraftApp, ui: &mut Ui) -> Option<Used> {
let width = ui.available_width();
// Chips are 16 px on a 19 px pitch, inset 3 px, with 2 px kept clear of the right edge, as
// in the Recent Colors row.
let per_row = (((width - 21.0) / 19.0).floor().max(0.0) as usize + 1).max(1);
let cache = used_colors(app, ui, per_row);
widgets::subheader(ui, if cache.selected { tl!("Selection Colors") } else { tl!("Document Colors") });
let t = Tokens::get(ui.ctx());
let (r, _) = ui.allocate_exact_size(vec2(width, 22.0), Sense::hover());
ui.painter().rect_stroke(r, 0.0, egui::Stroke::new(1.0, t.input_border), egui::StrokeKind::Inside);
let mut chosen = None;
for (i, u) in cache.colors.iter().take(per_row).enumerate() {
let cell = Rect::from_min_size(r.min + vec2(3.0 + i as f32 * 19.0, 3.0), vec2(16.0, 16.0));
let resp = ui.interact(cell, ui.scope_id().with(("document-color", i)), Sense::click_and_drag());
let paint = u.paint();
widgets::drag_source(ui, &resp, || widgets::PanelDrag::paint(paint.clone()));
widgets::swatch_tile(ui, cell, &paint, false, resp.hovered());
let tip = format!("{}\n{}", u.hex, crate::i18n::tn(u.count, "Used {n} time", "Used {n} times"));
resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &tip));
if resp.on_hover_text(&tip).clicked() {
chosen = Some(u.clone());
}
}
chosen
}
/// Apply a color of the Show Document Colors row as a pick does, to the inactive proxy when
/// `behind`. A color linked to a swatch stays linked at its tint, except at a freeform gradient's
/// point, which takes the color alone.
fn apply_used(app: &mut VectorcraftApp, tgt: &Target, u: &Used, behind: bool) {
let Some((name, tint)) = &u.link else { return apply(app, tgt, u.color, Live::Released, behind) };
match tgt {
Target::Stop { paint: Paint::Gradient(g), index, .. } if !behind => {
let mut stops = g.gradient.stops.clone();
if let Some(s) = stops.get_mut(*index) {
s.set_color(u.color, Some((name.clone(), *tint)));
}
super::gradient::set_stops(app, &stops, None, Live::Released);
}
Target::Point { .. } if !behind => apply(app, tgt, u.color, Live::Released, behind),
_ => {
let mut p = super::paint_params(&u.paint());
p["focus"] = json!(!behind);
super::live_run(app, "Color", super::proxy_cmd(app, behind), p, Live::Released);
}
}
}
/// The cells across and down of the grid the out-of-gamut shading tests.
@@ -953,6 +1121,12 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
vision_row(ui, &cms, color.as_ref());
}
let behind = super::alt_held(ui);
if app.ui.color_wheel.document_colors
&& let Some(u) = document_colors_row(app, ui)
{
apply_used(app, &tgt, &u, behind);
return;
}
let cmyk_doc = app.session.active().is_some_and(|d| d.doc.color_mode == ColorMode::Cmyk);
let rows = match (picked_hsl, picked_lch) {
(Some((hsl, phase)), _) => Some((hsl_to_rgb(hsl), phase, HSL_MEMORY, Remembered::Hsl(hsl))),
@@ -1072,7 +1072,7 @@ fn ui_color_wheel_sets_and_reads_the_sliders() {
assert_eq!(app.run("ui.colorWheel", json!({})).unwrap()["sliders"], json!("none"));
assert_eq!(app.run("ui.colorWheel", json!({"sliders": "hwb"})).unwrap_err(), "`sliders` must be none, oklch or hsl");
let got = app.run("ui.colorWheel", json!({"sliders": "oklch"})).unwrap();
let want = json!({"view": "box", "channel": "red", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": false, "sliders": "oklch"});
let want = json!({"view": "box", "channel": "red", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": false, "sliders": "oklch", "documentColors": false});
assert_eq!(got, want);
let e = app.run("ui.colorWheel", json!({"view": "wheel", "sliders": "hwb"})).unwrap_err();
assert_eq!(e, "`sliders` must be none, oklch or hsl");
@@ -167,7 +167,8 @@ fn the_strip_takes_the_arrow_keys_and_screen_readers_actions() {
#[test]
fn ui_color_wheel_sets_and_reads_the_view_and_the_channel() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let harmony = json!({"sliders": "none", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": false});
let harmony =
json!({"sliders": "none", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": false, "documentColors": false});
let with = |v: serde_json::Value| {
let mut v = v;
v.as_object_mut().unwrap().extend(harmony.as_object().unwrap().clone());
@@ -217,9 +218,9 @@ fn ui_color_wheel_rejects_other_params() {
let e = app.run("ui.colorWheel", json!([1])).unwrap_err();
assert_eq!(e, "the params must be an object, not [1]");
let e = app.run("ui.colorWheel", json!({"veiw": "wheel"})).unwrap_err();
assert_eq!(e, "unknown parameter `veiw`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision");
assert_eq!(e, "unknown parameter `veiw`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors");
let e = app.run("ui.colorWheel", json!({"view": "wheel", "chanel": "blue"})).unwrap_err();
assert_eq!(e, "unknown parameter `chanel`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision");
assert_eq!(e, "unknown parameter `chanel`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors");
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, channel: Channel::Red, ..Default::default() }, "an error changes nothing");
}
@@ -0,0 +1,410 @@
//! The Color Wheel panel's Show Document Colors row drawn headless: its colors and their order,
//! the heading that follows the selection, the colors that fit in one row, a click and an Alt+click
//! on a color, swatch links, gradient stops and freeform points, the colors kept during a drag, the panel menu,
//! `ui.colorWheel {documentColors}` and the saved setting.
use egui::{Event, Modifiers, PointerButton, Pos2, vec2};
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use serde_json::{Value, json};
use vectorcraft_color::Paint;
use vectorcraft_engine::Session;
use super::color_wheel::show;
use crate::VectorcraftApp;
/// A rectangle filled with `fill` (any paint `paint.setFill` takes), without a stroke, which
/// becomes the selection. → its id.
fn rect(app: &mut VectorcraftApp, x: f64, fill: Value) -> Value {
let id = app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 30, "height": 30})).unwrap()["id"].clone();
app.run("paint.setFill", fill).unwrap();
app.run("paint.setStroke", json!({"none": true, "focus": false})).unwrap();
id
}
/// A document with three red rectangles and one blue one (selected), with Show Document Colors on.
/// → the app, the ids of the red rectangles and the id of the blue one.
fn app() -> (VectorcraftApp, Vec<Value>, Value) {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
let reds = (0..3).map(|i| rect(&mut app, 10.0 + 40.0 * i as f64, json!({"color": "#ff0000"}))).collect();
let blue = rect(&mut app, 130.0, json!({"color": "#0000ff"}));
app.run("ui.colorWheel", json!({"documentColors": true})).unwrap();
(app, reds, blue)
}
fn harness(app: VectorcraftApp) -> Harness<'static, VectorcraftApp> {
let mut h = Harness::builder().with_size(vec2(260.0, 360.0)).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(2);
h
}
fn label(hex: &str, n: u64) -> String {
format!("{hex}\n{}", if n == 1 { "Used 1 time".to_string() } else { format!("Used {n} times") })
}
fn has(h: &Harness<'static, VectorcraftApp>, label: &str) -> bool {
h.query_by_label(label).is_some()
}
fn press(h: &mut Harness<'static, VectorcraftApp>, pos: Pos2, pressed: bool, modifiers: Modifiers) {
h.event(Event::ModifiersChanged(modifiers));
h.event(Event::PointerMoved(pos));
h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers });
h.run_steps(1);
}
fn click(h: &mut Harness<'static, VectorcraftApp>, pos: Pos2, modifiers: Modifiers) {
press(h, pos, true, modifiers);
press(h, pos, false, modifiers);
h.event(Event::ModifiersChanged(Modifiers::NONE));
h.run_steps(1);
}
/// The hex value of the one color object `id` uses (its fill: it has no stroke).
fn fill_of(app: &mut VectorcraftApp, id: &Value) -> String {
let r = app.session.execute("recolor.colors", &json!({"ids": [id]})).unwrap();
assert_eq!(r["colors"].as_array().map(Vec::len), Some(1), "{r}");
r["colors"][0]["hex"].as_str().unwrap().to_string()
}
/// With nothing selected, the row is headed Document Colors and lists the art's colors, the red
/// that three rectangles use before the blue that one uses.
#[test]
fn show_document_colors_lists_the_art_colors_most_used_first() {
let (mut app, _, _) = app();
app.run("select.none", json!({})).unwrap();
let h = harness(app);
assert!(has(&h, "Document Colors"));
let red = h.get_by_label(&label("#ff0000", 3)).rect();
let blue = h.get_by_label(&label("#0000ff", 1)).rect();
assert!(red.left() < blue.left(), "red {red:?} comes before blue {blue:?}");
}
/// With something selected the row is headed Selection Colors and lists the selection's colors.
#[test]
fn the_heading_and_the_colors_follow_the_selection() {
let (app, _, _) = app();
let mut h = harness(app);
assert!(has(&h, "Selection Colors"));
assert!(has(&h, &label("#0000ff", 1)));
assert!(!has(&h, &label("#ff0000", 3)));
h.state_mut().run("select.none", json!({})).unwrap();
h.run_steps(2);
assert!(has(&h, "Document Colors") && !has(&h, "Selection Colors"));
assert!(has(&h, &label("#ff0000", 3)));
}
/// The row shows the most used colors that fit in one row and leaves out the rest.
#[test]
fn the_row_shows_only_the_colors_that_fit() {
let (mut app, _, _) = app();
for i in 0..30 {
rect(&mut app, 170.0 + i as f64, json!({"color": format!("#00{:02x}00", 40 + 6 * i)}));
}
app.run("select.none", json!({})).unwrap();
let h = harness(app);
let red = h.get_by_label(&label("#ff0000", 3)).rect();
let shown: Vec<_> = (0..30).filter_map(|i| h.query_by_label(&label(&format!("#00{:02x}00", 40 + 6 * i), 1)).map(|n| n.rect())).collect();
assert!(!shown.is_empty() && shown.len() < 30, "{} of the 30 greens show", shown.len());
assert!(shown.iter().all(|r| (r.top() - red.top()).abs() < 0.5 && r.right() <= 260.0), "one row inside the panel: {shown:?}");
}
/// A row wide enough for more than 128 chips shows as many colors as fit.
#[test]
fn a_wide_row_shows_more_than_128_colors() {
let (mut app, _, _) = app();
let hex = |i: usize| format!("#{:02x}{:02x}80", i % 256, i / 256 + 1);
for i in 0..160 {
rect(&mut app, 170.0, json!({"color": hex(i)}));
}
app.run("select.none", json!({})).unwrap();
let mut h = Harness::builder().with_size(vec2(3400.0, 360.0)).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(2);
let shown = (0..160).filter(|i| has(&h, &label(&hex(*i), 1))).count();
assert!(shown > 128, "{shown} of the 160 colors show");
}
/// A click on a color fills the selection with it, as one undo step.
#[test]
fn a_click_on_a_color_sets_the_fill() {
let (mut app, reds, blue) = app();
app.run("select.set", json!({"ids": [reds[0], blue]})).unwrap();
let undo = app.session.doc().unwrap().history.undo.len();
let mut h = harness(app);
let at = h.get_by_label(&label("#0000ff", 1)).rect().center();
click(&mut h, at, Modifiers::NONE);
let app = h.state_mut();
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1);
assert_eq!(fill_of(app, &reds[0]), "#0000ff");
assert_eq!(fill_of(app, &blue), "#0000ff");
assert_eq!(fill_of(app, &reds[1]), "#ff0000");
}
/// Alt+click applies the color to the inactive proxy (the stroke) and leaves the fill in front.
#[test]
fn alt_click_on_a_color_sets_the_stroke() {
let (mut app, reds, blue) = app();
app.run("select.set", json!({"ids": [reds[0], blue]})).unwrap();
let mut h = harness(app);
let at = h.get_by_label(&label("#ff0000", 1)).rect().center();
click(&mut h, at, Modifiers::ALT);
let app = h.state_mut();
assert!(app.session.fill_active, "the fill stays in front");
let st = app.session.doc().unwrap();
let paints = |id: &Value| {
let n = st.doc.node(vectorcraft_doc::NodeId(id.as_u64().unwrap())).unwrap();
(n.appearance.fill_paint().color().map(|c| c.to_hex()), n.appearance.stroke_paint().color().map(|c| c.to_hex()))
};
assert_eq!(paints(&blue), (Some("#0000ff".into()), Some("#ff0000".into())));
}
/// A color linked to a spot swatch stays linked at its tint when a click applies it.
#[test]
fn a_click_keeps_a_swatch_link_and_its_tint() {
let (mut app, _, blue) = app();
app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true})).unwrap();
let ink = rect(&mut app, 170.0, json!({"swatch": "Ink", "tint": 40}));
app.run("select.set", json!({"ids": [ink, blue]})).unwrap();
let hex = app.session.execute("color.used", &json!({})).unwrap()["colors"]
.as_array()
.unwrap()
.iter()
.find(|c| c["swatch"] == "Ink")
.expect("the tint is listed")["hex"]
.as_str()
.unwrap()
.to_string();
let mut h = harness(app);
let at = h.get_by_label(&label(&hex, 1)).rect().center();
click(&mut h, at, Modifiers::NONE);
let st = h.state().session.doc().unwrap();
let fill = st.doc.node(vectorcraft_doc::NodeId(blue.as_u64().unwrap())).unwrap().appearance.fill_paint().clone();
let Paint::Solid { swatch, tint, .. } = fill else { panic!("a solid fill, not {fill:?}") };
assert_eq!(swatch.as_deref(), Some("Ink"));
assert!((tint - 0.4).abs() < 1e-3, "tint {tint}");
}
/// A click recolors the selected gradient stop, linking it to a color's swatch at its tint.
#[test]
fn a_click_recolors_the_selected_gradient_stop() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true})).unwrap();
let stops = json!([{"offset": 0, "color": "#000000", "swatch": "Ink", "tint": 40}, {"offset": 1, "color": "#0000ff"}]);
rect(&mut app, 10.0, json!({"gradient": {"stops": stops, "start": [10, 25], "end": [40, 25]}}));
app.select_tool("gradient");
app.run("gradient.selectStop", json!({"index": 1})).unwrap();
app.run("ui.colorWheel", json!({"documentColors": true})).unwrap();
let hex = app.session.execute("color.used", &json!({})).unwrap()["colors"]
.as_array()
.unwrap()
.iter()
.find(|c| c["swatch"] == "Ink")
.expect("the stop's color is listed")["hex"]
.as_str()
.unwrap()
.to_string();
let mut h = harness(app);
let at = h.get_by_label(&label(&hex, 1)).rect().center();
click(&mut h, at, Modifiers::NONE);
let Paint::Gradient(g) = crate::panels::current_paints(h.state()).0 else { panic!("still a gradient") };
let stop = &g.gradient.stops[1];
assert_eq!((stop.color.to_hex(), stop.swatch.as_deref()), (hex, Some("Ink")));
assert!((stop.tint - 0.4).abs() < 1e-3, "tint {}", stop.tint);
}
/// A click on a color linked to a swatch gives a selected freeform point the color alone and keeps
/// the freeform fill.
#[test]
fn a_click_gives_a_freeform_point_the_color_alone() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
app.run("swatch.new", json!({"name": "Ink", "color": {"c": 0, "m": 100, "y": 60, "k": 0}, "spot": true})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 100, "height": 100})).unwrap();
app.run("paint.editGradient", json!({"kind": "freeform"})).unwrap();
app.run("paint.setStroke", json!({"swatch": "Ink", "tint": 40, "focus": false})).unwrap();
app.select_tool("gradient");
app.run("paint.freeform.selectPoint", json!({"index": 1})).unwrap();
app.run("ui.colorWheel", json!({"documentColors": true})).unwrap();
let hex = app.session.execute("color.used", &json!({})).unwrap()["colors"]
.as_array()
.unwrap()
.iter()
.find(|c| c["swatch"] == "Ink")
.expect("the stroke's color is listed")["hex"]
.as_str()
.unwrap()
.to_string();
let mut h = harness(app);
let at = h.get_by_label(&label(&hex, 1)).rect().center();
click(&mut h, at, Modifiers::NONE);
let Paint::Gradient(g) = crate::panels::current_paints(h.state()).0 else { panic!("still a gradient") };
let points = g.freeform.expect("still freeform").points;
assert_eq!(points[1].color.to_hex(), hex);
}
/// While a drag on the wheel recolors the selection, the row keeps the colors from before the
/// drag; once it ends, it lists the new color.
#[test]
fn a_drag_on_the_wheel_does_not_read_the_colors_again_until_it_ends() {
let (app, _, blue) = app();
let revision = app.session.active().unwrap().revision;
let mut h = harness(app);
let ring = h.get_by_label("Hue ring").rect();
// The left of the ring (cyan), then its bottom, in the middle of the band.
let r = ring.width() / 2.0 - 11.0;
let (a, b) = (ring.center() - vec2(r, 0.0), ring.center() + vec2(0.0, r));
press(&mut h, a, true, Modifiers::NONE);
for p in [a, b, b] {
h.event(Event::PointerMoved(p));
h.run_steps(1);
}
assert!(h.state().session.in_interaction(), "the drag is in progress");
assert_ne!(h.state().session.active().unwrap().revision, revision, "the drag changed the document");
assert!(has(&h, &label("#0000ff", 1)), "the row keeps the colors from before the drag");
press(&mut h, b, false, Modifiers::NONE);
h.run_steps(2);
let now = fill_of(h.state_mut(), &blue);
assert_ne!(now, "#0000ff");
assert!(!has(&h, &label("#0000ff", 1)));
assert!(has(&h, &label(&now, 1)), "the row lists {now} after the drag");
}
/// In art with more than 5,000 color uses, the row reads the colors again after an edit at most
/// once every half second of frames, and a change of selection reads them at once.
#[test]
fn in_large_art_an_edit_reads_the_colors_again_after_half_a_second() {
let (mut app, reds, _) = app();
app.run("select.set", json!({"ids": [reds[0]]})).unwrap();
for _ in 0..11 {
app.run("select.all", json!({})).unwrap();
app.run("edit.duplicate", json!({})).unwrap();
}
app.run("select.none", json!({})).unwrap();
let uses = app.session.execute("color.used", &json!({})).unwrap()["uses"].as_u64().unwrap();
assert!(uses > 5_000, "{uses} uses");
let reds_used = app.session.execute("color.used", &json!({})).unwrap()["colors"][0]["count"].as_u64().unwrap();
let mut h = Harness::builder().with_size(vec2(260.0, 360.0)).with_step_dt(0.1).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(6);
assert!(has(&h, &label("#ff0000", reds_used)));
// Half a second after the last read, an edit is read at once.
h.state_mut().run("paint.setFill", json!({"ids": [reds[0]], "color": "#00ff00"})).unwrap();
h.run_steps(1);
assert!(has(&h, &label("#ff0000", reds_used - 1)) && has(&h, &label("#00ff00", 1)), "the first edit is read at once");
// The next edit within half a second waits.
h.state_mut().run("paint.setFill", json!({"ids": [reds[1]], "color": "#00ff00"})).unwrap();
h.run_steps(1);
assert!(has(&h, &label("#00ff00", 1)), "the row waits after the second edit");
h.run_steps(5);
assert!(has(&h, &label("#ff0000", reds_used - 2)) && has(&h, &label("#00ff00", 2)), "the row reads the colors again");
h.state_mut().run("paint.setFill", json!({"ids": [reds[2]], "color": "#00ff00"})).unwrap();
h.state_mut().run("select.set", json!({"ids": [reds[2]]})).unwrap();
h.run_steps(1);
assert!(has(&h, "Selection Colors") && has(&h, &label("#00ff00", 1)), "a new selection reads the colors at once");
assert!(!has(&h, &label("#00ff00", 3)));
}
/// A row widened past the 128 colors last read keeps them while an interaction is in progress, and
/// in art with more than 5,000 color uses until half a second after the last read.
#[test]
fn a_widened_row_waits_for_the_interaction_and_the_half_second() {
let (mut app, reds, _) = app();
let hex = |i: usize| format!("#{:02x}{:02x}80", i % 256, i / 256 + 1);
for i in 0..160 {
rect(&mut app, 170.0, json!({"color": hex(i)}));
}
for _ in 0..5 {
app.run("select.all", json!({})).unwrap();
app.run("edit.duplicate", json!({})).unwrap();
}
app.run("select.none", json!({})).unwrap();
let uses = app.session.execute("color.used", &json!({})).unwrap()["uses"].as_u64().unwrap();
assert!(uses > 5_000, "{uses} uses");
let (narrow, wide) = (vec2(260.0, 360.0), vec2(3400.0, 360.0));
let mut h = Harness::builder().with_size(narrow).with_step_dt(0.1).build_ui_state(|ui, app: &mut VectorcraftApp| show(app, ui), app);
h.run_steps(6);
let shown = |h: &Harness<'static, VectorcraftApp>| (0..160).filter(|i| has(h, &label(&hex(*i), 32))).count();
// During an interaction the wide row keeps the 128 colors read for the narrow one.
h.state_mut().session.begin_interaction("test").unwrap();
h.set_size(wide);
h.run_steps(6);
assert!(shown(&h) <= 128, "{} colors show during the interaction", shown(&h));
h.state_mut().session.cancel_interaction().unwrap();
h.run_steps(6);
assert!(shown(&h) > 128, "{} colors show after the interaction", shown(&h));
// An edit read in the narrow row, then a wide row within half a second, waits for the half second.
h.set_size(narrow);
h.run_steps(1);
h.state_mut().run("paint.setFill", json!({"ids": [reds[0]], "color": "#00ff00"})).unwrap();
h.run_steps(1);
assert!(has(&h, &label("#ff0000", 95)), "the edit is read at once");
h.set_size(wide);
h.run_steps(1);
assert!(shown(&h) <= 128, "{} colors show within half a second", shown(&h));
h.run_steps(5);
assert!(shown(&h) > 128, "{} colors show after half a second", shown(&h));
}
/// Without the setting the row is not drawn, and the panel menu's Show Document Colors turns it on.
#[test]
fn the_panel_menu_turns_the_row_on_and_off() {
let off = || {
let (mut a, _, _) = app();
a.run("ui.colorWheel", json!({"documentColors": false})).unwrap();
a
};
let mut h = harness(off());
assert!(!has(&h, "Selection Colors"));
// The menu in a context of its own, as the other panel menu tests draw it.
let mut app = off();
let ctx = egui::Context::default();
let raw = |events| egui::RawInput { events, screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(240.0, 320.0))), ..Default::default() };
let click_item = |app: &mut VectorcraftApp| {
let mut out = ctx.run_ui(raw(vec![]), |ui| super::color_wheel::menu(app, ui));
out.textures_delta.clear();
let item = out
.shapes
.iter()
.find_map(|c| match &c.shape {
egui::Shape::Text(t) if t.galley.text().ends_with("Show Document Colors") => Some(t.visual_bounding_rect().center()),
_ => None,
})
.expect("the menu shows Show Document Colors");
let button = |pressed| Event::PointerButton { pos: item, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
ctx.run_ui(raw(vec![Event::PointerMoved(item), button(true), button(false)]), |ui| super::color_wheel::menu(app, ui)).textures_delta.clear();
};
click_item(&mut app);
assert!(app.ui.color_wheel.document_colors);
click_item(&mut app);
assert!(!app.ui.color_wheel.document_colors);
h.state_mut().run("ui.colorWheel", json!({"documentColors": true})).unwrap();
h.run_steps(2);
assert!(has(&h, "Selection Colors"));
}
/// `ui.colorWheel {documentColors}` sets the row's setting, keeps the others, and refuses a value
/// that is not a bool, changing nothing.
#[test]
fn ui_color_wheel_sets_document_colors() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
assert_eq!(app.run("ui.colorWheel", json!({})).unwrap()["documentColors"], json!(false));
app.run("ui.colorWheel", json!({"view": "box"})).unwrap();
let r = app.run("ui.colorWheel", json!({"documentColors": true})).unwrap();
assert_eq!((r["documentColors"].clone(), r["view"].clone()), (json!(true), json!("box")));
assert_eq!(app.run("ui.colorWheel", json!({"documentColors": "no"})).unwrap_err(), "`documentColors` must be true or false");
assert!(app.ui.color_wheel.document_colors);
assert_eq!(app.run("ui.colorWheel", json!({"documentColors": null})).unwrap()["documentColors"], json!(true));
}
/// The saved setting reads leniently: a value this build does not know reads as off, and the other
/// settings and preferences are kept.
#[test]
fn the_saved_setting_reads_leniently() {
let read = |v: Value| serde_json::from_value::<crate::UiState>(v).expect("the preferences read");
let s = read(json!({"color_wheel": {"documentColors": true, "view": "box"}, "color_rgb_percent": true}));
assert!(s.color_wheel.document_colors && s.color_rgb_percent);
let s = read(json!({"color_wheel": {"documentColors": "yes", "view": "box"}, "color_rgb_percent": true}));
assert!(!s.color_wheel.document_colors && s.color_rgb_percent);
assert_eq!(s.color_wheel.view, super::color_wheel::View::Box);
}
@@ -158,7 +158,7 @@ fn ui_color_wheel_sets_gamut() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let with = |v: serde_json::Value| {
let mut v = v;
let rest = json!({"sliders": "none", "harmony": false, "harmonyRule": "complementary", "vision": false});
let rest = json!({"sliders": "none", "harmony": false, "harmonyRule": "complementary", "vision": false, "documentColors": false});
v.as_object_mut().unwrap().extend(rest.as_object().unwrap().clone());
v
};
@@ -225,7 +225,7 @@ fn the_panel_menu_turns_the_row_on_and_off() {
#[test]
fn ui_color_wheel_sets_and_reads_the_settings() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let settings = |view: &str, vision: bool| json!({"view": view, "channel": "hue", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": vision, "sliders": "none"});
let settings = |view: &str, vision: bool| json!({"view": view, "channel": "hue", "gamut": false, "harmony": false, "harmonyRule": "complementary", "vision": vision, "sliders": "none", "documentColors": false});
assert_eq!(app.run("ui.colorWheel", json!({})).unwrap(), settings("wheel", false));
assert_eq!(app.run("ui.colorWheel", json!({"vision": true})).unwrap(), settings("wheel", true));
assert_eq!(crate::control::inspect(&app, &egui::Context::default())["ui"]["color_wheel"]["vision"], true);
@@ -236,7 +236,7 @@ fn ui_color_wheel_sets_and_reads_the_settings() {
assert_eq!(app.run("ui.colorWheel", json!(5)).unwrap_err(), "the params must be an object, not 5");
assert_eq!(
app.run("ui.colorWheel", json!({"visoin": false})).unwrap_err(),
"unknown parameter `visoin`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision"
"unknown parameter `visoin`; the command takes: view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors"
);
assert!(app.ui.color_wheel.vision);
assert_eq!(app.run("ui.colorWheel", json!({"vision": null})).unwrap()["vision"], true);
+10
View File
@@ -336,6 +336,16 @@ The dialog previews
step; with no art selected only the group changes). In the Swatches panel, double-clicking a colour group's folder,
or the options button while a group is selected, opens it.
`color.used {selection?, limit?}` lists the colors of the selection, or with nothing selected the colors of the art
`select.all` takes, most used first, as `recolor.colors {}` counts them. Each entry adds `color`, the color in its own
model as the paint commands take it, and `tint`, the percent of its global `swatch` it is, to three decimals. The
swatch and tint come from the color's first linked use in paint order; a plain use goes before a gradient stop that
mixes a spot ink with process inks, and a color only such stops link has no `swatch` here. `selection: false` reads
the art `select.all` takes while something is selected, and the answer's `selection` says whether the colors are
the selection's. `limit` keeps only the most used entries, and the answer's `uses` counts the uses of every color.
The selection does not change. The Color Wheel panel's Show Document Colors row (`ui.colorWheel {documentColors:
true}`) shows these colors.
Library panel: `engine.execute {command: "window.swatchLibrary", params: {library}}` opens the read-only library
panel on a swatch library (`ui.inspect` shows it as `library_panel: {kind, id}`; `library: null` closes it).
Clicking a swatch there runs `swatch.library.add {library, names: [name], apply}` (the active proxy, or the other
+7 -2
View File
@@ -692,8 +692,9 @@ whole cell or none of it, so a grayed cell can hold printable colors and a clear
print. `{"harmony": true, "harmonyRule": "triad"}` puts a marker on the wheel's ring for each other
color of a Color Guide harmony rule, as Show Harmony and Harmony Rule do; the wheel takes the 15 rules whose colors
each have a hue of their own (not `monochromatic`, `shades`, `complementary2`, `triad2`, `triad3` or
`highContrast2`). Keys left out keep their values. Params that are not an object, another key or a value off
the list return an error and change nothing. The command returns `{view, channel, sliders, gamut, harmony, harmonyRule, vision}`,
`highContrast2`). `{"documentColors": true}` shows the row the panel menu's Show Document Colors adds under the wheel
or the box. Keys left out keep their values. Params that are not an object, another key or a value off
the list return an error and change nothing. The command returns `{view, channel, sliders, gamut, harmony, harmonyRule, vision, documentColors}`,
and the settings are kept with the preferences.
`ui.colorWheel {"sliders": "oklch"}` shows the Color Wheel panel's OKLCH Sliders (L, C and H rows under the wheel or
@@ -711,6 +712,10 @@ does: a row of four chips under the wheel or the box shows the current color thr
and tritanopia simulations of `view.proofSetup`, and for achromatopsia as the gray with the color's CIE L*. Each
chip reports its name and hex value to screen readers, and a click on a chip does not apply its color. `false`
hides the row, and `null` keeps the setting. Any other value returns an error and changes nothing.
`ui.colorWheel {"documentColors": true}` shows the Color Wheel panel's row of the colors the selection uses, or with
nothing selected the colors of the art `select.all` takes, in the order `color.used {}` lists them. A click on a color
applies it to the active proxy, keeping its link to a global swatch. The answer includes `documentColors`
with the other settings, and the setting is kept with the preferences.
In remote desktop mode, `invoke_menu` with `{"command":"ui.sampleScreenColor","params":{}}` shows the system's
screen color sampler and returns `null` before a color is picked: the system's sampler on macOS, the XDG desktop
+1
View File
@@ -1966,6 +1966,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Swatch library and Recolor Artwork parameters:** the `swatch.library.*` commands, `swatch.resetDefaults`, the graphic style library save, load and add, the `recolor.*` commands and `color.harmony`'s `limitTo` refuse parameters of the wrong form, such as `names: "Grays"`, `limitTo: 5` or `includeImages: "false"`. Errors name the parameter, except that a `limitTo` that is not a string, such as `5`, gets an unknown-library error. A `null` counts as left out except for `recolor.apply`'s `model`, which must be a string when given.
- **OKLCH Sliders (Color Wheel panel):** as VectorCraft's own addition, the Color Wheel panel's menu item OKLCH Sliders (`ui.colorWheel {sliders: "oklch"}`, kept with the preferences) shows L, C and H rows under the wheel or the box that edit the color by the OKLCH lightness (0 to 100 %), chroma (0 to 100 % of 0.4) and hue (0 to 360°) of its display sRGB, as CSS Color 4 defines them (https://www.w3.org/TR/css-color-4/#specifying-oklab-oklch). Each track dims the colors outside sRGB, and a tick on the C track marks the largest chroma sRGB holds at the row's L and H; a color outside sRGB keeps L and H and takes the largest chroma that fits, and the C row keeps the chroma asked for. The rows take the arrow keys after a click and report their names, values, ranges and adjust actions to screen readers. While the active document's RGB space (its assigned profile, else the working RGB space of Edit › Color Settings) is not sRGB, the unchecked item is gray and `ui.colorWheel {sliders: "oklch"}` answers an error; rows shown before the space changed are gray, and the checked item still hides them. `color.convert {color, to: "oklch"}` answers the same L, C and H for a color inside sRGB. For a color outside sRGB, it clips the display RGB to 0 to 1 first, so its L, C and H can differ from the rows' values. Evidence: `crates/color/src/oklab.rs` tests; `convert_to_oklch_answers_lightness_chroma_and_hue` in `crates/engine/src/tests/colormgmt.rs`; the OKLCH tests in `crates/ui-egui/src/panels/tests_color_wheel.rs`, `the_oklch_tracks_dim_the_colors_outside_srgb_and_the_tick_marks_the_largest_chroma` and `oklch_sliders_are_gray_after_the_working_space_changes` among them. Scores and estimates are unchanged.
- **HSL Sliders (Color Wheel panel):** as VectorCraft's own addition, the Color Wheel panel's menu item HSL Sliders (`ui.colorWheel {sliders: "hsl"}`, kept with the preferences) shows H, S and L rows in place of OKLCH Sliders that edit the color by the hue (0 to 360°), saturation and lightness (0 to 100 %) of its display sRGB, as CSS Color 4 defines HSL (https://www.w3.org/TR/css-color-4/#the-hsl-notation). A pick goes from display sRGB into the working RGB space as the wheel's picks do, and the rows keep the hue of a gray. The rows take the arrow keys after a click and report their names, values, ranges and adjust actions to screen readers. Evidence: `hsl_follows_css_color_4` and `hsl_roundtrip` in `crates/color/src/lib.rs`; the HSL tests in `crates/ui-egui/src/panels/tests_color_wheel.rs`, `a_gray_keeps_the_hsl_hue_it_was_given` among them. Scores and estimates are unchanged.
- **Color Wheel document colors (part of #978):** the Color Wheel panel menu's Show Document Colors adds a row under the wheel or the box with the colors of the selection, headed Selection Colors, or with nothing selected of the art Select All takes, headed Document Colors, most used first and as many as fit in one row (`color.used`, `ui.colorWheel {documentColors}`). A color's tooltip gives its hex value and how many times the art uses it, and a click applies it as a pick does, keeping its color model; the active proxy and a selected gradient stop also keep its link to a global swatch. Tests: `crates/engine/src/tests/recolor.rs`, `crates/ui-egui/src/panels/tests_color_wheel_document_colors.rs`.
- **Color Wheel panel (part of #978):** Window › Color Wheel shows the Fill and Stroke proxy beside a hue ring around a square with saturation across and brightness up. It edits what the Color panel's sliders edit (the active proxy's color, the selected gradient stop or freeform point) through the same paint commands, and a drag is one undo step. Alt paints the other proxy, and Shift steps the ring by 45°. A pick goes from display sRGB into the working RGB space; an RGB, CMYK or Lab color keeps its model, and a Gray color or a tint of a global swatch becomes a process color in the document's color mode. A click gives the ring or the square the keyboard focus, and the arrow keys then step the color; both report their names and values to screen readers, and the Color Picker's color field takes the same keys. The panel menu's Box View puts a box in the wheel's place: a color field with a channel strip at its right for Hue, Saturation, Brightness, Red, Green or Blue (Box Channel), on the Color Picker's axes, kept with the preferences (`ui.colorWheel`); the strip and the Color Picker's channel slider take the arrow keys after a click. Show Out-of-Gamut Colors grays out the parts of the square and the box's field whose colors the CMYK space cannot print, by the out-of-gamut warning's test on a 16 by 16 grid (`ui.colorWheel {gamut}`). The panel menu's Show Harmony marks the other colors of a harmony rule (Harmony Rule) on the ring; the markers follow the current color, and a click on a marker applies its color (`ui.colorWheel {harmony, harmonyRule}`). Scores and estimates are unchanged.
- **Colour:** a Color Picker (colour field, H/S/B/R/G/B channel slider, HSB/RGB/Lab/CMYK fields, hex, web-only snapping, out-of-gamut correction); the Color panel shows a selected colour in its own model and, with nothing selected, the new-art defaults in the mode picked last, which it keeps between sessions; Alt-click paints the other proxy; proxies look through groups and show "?" for mixed paint; Invert, Complement, Apply Last Color (`,`) and Apply Last Gradient (`.`) keep the colour model; every paint command feeds the recent colours. The Color Guide has 21 harmony rules, Steps and Variation options and Limit to Library. Adjust Color Balance (its Global mode shifts tints) and Saturate preview live; Edit Colors and Recolor also reach meshes, images and patterns. Recolor Artwork has colour reduction, five recolour methods, presets, Limit to Library, a colour-wheel Edit tab and Edit Color Group; a local Color Themes panel saves five-colour themes. Fill/Stroke chips open swatch and mixer popovers (the Properties panel has the Control bar's Fill and Stroke chips, Stroke link and weight spinner, with nothing selected too), panels have Illustrator's Window menu keys (Align Shift+F7, Transform Shift+F8, Pathfinder Cmd+Shift+F9, Layers F7, Character Cmd+T…; every panel can be given one in Edit › Keyboard Shortcuts), and Eyedropper Options pick up and apply chosen attributes (Alt and Shift+Alt, image pixels). An ICC CMYK profile converts straight into the RGB working space (not through sRGB, so a wider space such as Wide Gamut RGB keeps colours sRGB can't hold) with the colour settings' black-point compensation, on the canvas and in RGB exports alike (the built-in Generic CMYK compensates both ways, so RGB black separated to a rich black displays as black again). Fills and strokes can overprint (Attributes panel, Overprint Black options), and CMYK documents blend in inks on screen, in PDF and when flattening. Document Color Mode converts the art, symbols, pattern tiles and swatches through the colour settings: Gray stays Gray, RGB grays separate into light grays in cyan, magenta and yellow only, darker four-color grays and a rich black, or go on the black plate only with `grays: "black"` (also for `document.open {colorMode}`).