mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 00:54:06 +00:00
Color Wheel: document null params and the sampled gamut shading
ui.colorWheel's params text and docs/mcp.md now say that a key set to null keeps its value while the other keys apply, and that the out-of-gamut shading is approximate: each cell of the 16 by 16 grid is grayed out or not by the color at its center. A test checks that null keeps view and channel while another key applies.
This commit is contained in:
@@ -1418,7 +1418,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.colorWheel",
|
||||
"Color Wheel Options",
|
||||
"",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: 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); 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; keys left out keep their values, params that are not an object, another key or a value off the list are an error and change nothing, all three 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, gamut}",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: 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); 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; keys left out or set to null keep their values while the other keys apply, params that are not an object, another key or a value off the list are an error and change nothing, all three 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, gamut}",
|
||||
),
|
||||
(
|
||||
"ui.savePdfDialog",
|
||||
|
||||
@@ -1419,7 +1419,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.colorWheel",
|
||||
"Color Wheel Options",
|
||||
"",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: 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); 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; keys left out keep their values, params that are not an object, another key or a value off the list are an error and change nothing, all three 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, gamut}",
|
||||
"{view?: wheel|box, channel?: hue|saturation|brightness|red|green|blue, gamut?: bool} show the Color Wheel panel's wheel or its box, as the panel menu's Wheel View and Box View do, and pick the box's channel, as Box Channel does: 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); 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; keys left out or set to null keep their values while the other keys apply, params that are not an object, another key or a value off the list are an error and change nothing, all three 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, gamut}",
|
||||
),
|
||||
(
|
||||
"ui.savePdfDialog",
|
||||
|
||||
@@ -104,8 +104,9 @@ pub fn deserialize_settings<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Se
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {view?, channel?, gamut?}`: show the wheel or the box, pick the box's channel,
|
||||
/// and show or hide the out-of-gamut shading. Keys left out keep their values; params that are not
|
||||
/// an object, another key or a value off the list are an error and change nothing. → the settings.
|
||||
/// and show or hide the out-of-gamut shading. Keys left out or set to null keep their values, and
|
||||
/// the other keys still apply; params that are not an object, another key or a value off the list
|
||||
/// are an error and change nothing. → the settings.
|
||||
pub(crate) fn command(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
|
||||
const KEYS: [&str; 3] = ["view", "channel", "gamut"];
|
||||
match p {
|
||||
|
||||
@@ -150,8 +150,9 @@ fn with_the_setting_off_no_grid_is_computed() {
|
||||
assert_eq!(drawn(&h), None);
|
||||
}
|
||||
|
||||
/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a value that is not true or
|
||||
/// false is an error that changes nothing, translated where messages are.
|
||||
/// `ui.colorWheel {gamut}` sets the setting and keeps the others; a key set to null keeps its value
|
||||
/// while the other keys apply; a value that is not true or false is an error that changes nothing,
|
||||
/// translated where messages are.
|
||||
#[test]
|
||||
fn ui_color_wheel_sets_gamut() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
@@ -161,6 +162,9 @@ fn ui_color_wheel_sets_gamut() {
|
||||
assert_eq!(e, "`gamut` must be true or false");
|
||||
assert_eq!(app.ui.color_wheel, Settings { view: View::Box, gamut: true, ..Default::default() }, "an error changes nothing");
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"gamut": null})).unwrap()["gamut"], json!(true), "null keeps the value");
|
||||
app.run("ui.colorWheel", json!({"channel": "red"})).unwrap();
|
||||
let got = app.run("ui.colorWheel", json!({"view": "wheel", "channel": null, "gamut": null})).unwrap();
|
||||
assert_eq!(got, json!({"view": "wheel", "channel": "red", "gamut": true}), "null keeps a value while the other keys apply");
|
||||
assert_eq!(app.run("ui.colorWheel", json!({"gamut": false})).unwrap()["gamut"], json!(false));
|
||||
for code in ["de", "fr", "ja", "zh-hans"] {
|
||||
let lang = crate::i18n::Lang::from_code(code).expect("registered");
|
||||
|
||||
+5
-2
@@ -674,8 +674,11 @@ and answers true when the fields show in percent.
|
||||
strip at its right) in place of the wheel, as the panel menu's Box View and Box Channel do, and `"view": "wheel"`
|
||||
shows the wheel again. `"gamut": true` grays out the parts of the wheel's square and the box's field whose colors
|
||||
the CMYK space cannot print, as the panel menu's Show Out-of-Gamut Colors does, and `false` shows them again. The
|
||||
test is the out-of-gamut warning's, which `color.gamutCheck` answers for one color. 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
|
||||
test is the out-of-gamut warning's, which `color.gamutCheck` answers for one color. The shading is approximate: the
|
||||
panel tests the color at the center of each cell of a 16 by 16 grid over the square or the field and grays out the
|
||||
whole cell or none of it, so a grayed cell can hold printable colors and a clear cell can hold colors that cannot
|
||||
print. Keys left out or set to `null` keep their values, and the other keys still apply. 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, gamut}`, and the settings are kept with the preferences.
|
||||
|
||||
In remote desktop mode, `invoke_menu` with `{"command":"ui.sampleScreenColor","params":{}}` shows the system's
|
||||
|
||||
Reference in New Issue
Block a user