mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(engine): complete schema docs for ATN keys, nulls, and clamp ranges
Corpus on a546a2091 failed 10 engine tests because dispatch rejected
keys and values the commands already accept: Calculations flat
source/mask fields, artboard From Group ATN bookkeeping, an older
Close `force` flag, Selective Color per-range arrays and optional
null/out-of-range inks, and Camera Raw exposure values that clamp
to the documented range. Document those keys, treat the clamp ranges
like other dialog-range exceptions, and stop the layer-mask depth
tests passing fill/gradient params to invert.
Signed-off-by: FredApps <[email protected]>
This commit is contained in:
1 parent
a546a2091e
commit
6f5615f741
5 files changed
+20
-9
No files matched your search
@@ -347,7 +347,7 @@ fn build() -> Vec<CommandSpec> {
|
||||
"Close",
|
||||
["File"],
|
||||
Some("Cmd+W"),
|
||||
r##"{"document":index?,"save":"discard|ask"|false="discard"} (false means discard; ask refuses to close a changed document in headless playback)"##,
|
||||
r##"{"document":index?,"save":"discard|ask"|false="discard","force":bool?} (false means discard; ask refuses to close a changed document in headless playback; force is an older recorded Close and is ignored)"##,
|
||||
has_doc,
|
||||
|s, p| {
|
||||
let i = p.get("document").and_then(Value::as_u64).map(|v| v as usize).or(s.active_index()).ok_or(EngineError::NoDocument)?;
|
||||
@@ -1258,7 +1258,7 @@ fn build() -> Vec<CommandSpec> {
|
||||
(
|
||||
"selectiveColor",
|
||||
"Selective Color…",
|
||||
r##"{"method":"relative|absolute"="relative","colors":"reds|yellows|greens|cyans|blues|magentas|whites|neutrals|blacks"="reds","cyan":-100..100=0,"magenta":-100..100=0,"yellow":-100..100=0,"black":-100..100=0,"reds":json} (per-range [c,m,y,k] arrays: reds yellows greens cyans blues magentas whites neutrals blacks)"##,
|
||||
r##"{"method":"relative|absolute"?="relative","relative":bool? (false = absolute; method wins when both are set),"colors":"reds|yellows|greens|cyans|blues|magentas|whites|neutrals|blacks"?="reds","cyan":-100..100?=0,"magenta":-100..100?=0,"yellow":-100..100?=0,"black":-100..100?=0,"reds":json?,"yellows":json?,"greens":json?,"cyans":json?,"blues":json?,"magentas":json?,"whites":json?,"neutrals":json?,"blacks":json?} (per-range [c,m,y,k] arrays)"##,
|
||||
),
|
||||
(
|
||||
"colorLookup",
|
||||
|
||||
@@ -843,7 +843,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"layer.new.artboardFromGroup",
|
||||
"Artboard from Group",
|
||||
&["Layer", "New"],
|
||||
r##"{"layer":id? (a top-level group; default active),"background":…?,"color":[r,g,b]|"#rrggbb"?,"preset":str? (tag only; does not resize),"guideIDs":[int]? (ignored recording metadata),"changeBackground":int? (1 or absent applies background/color; other integers give white; legacy true = 1)} → {layer, rect}"##,
|
||||
r##"{"layer":id? (a top-level group; default active),"background":…?,"color":[r,g,b]|"#rrggbb"?,"preset":str? (tag only; does not resize),"guideIDs":[int]? (ignored recording metadata),"changeBackground":int? (1 or absent applies background/color; other integers give white; legacy true = 1),"recordedColor"? (ATN round-trip of the recorded color),"backgroundTypeOmitted":bool? (ATN: the descriptor omitted the background type)} → {layer, rect}"##,
|
||||
has_plain_group,
|
||||
artboard_from_group
|
||||
),
|
||||
|
||||
@@ -176,7 +176,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Calculations…",
|
||||
["Image"],
|
||||
None,
|
||||
r##"{"source1":{"document","layer","channel","invert"},"source2":{…},"blending":"multiply|…"="multiply","opacity":0..100=100,"scale":1..2=1,"offset":-255..255=0,"mask":{…}?,"result":"newChannel|newDocument|selection"="newChannel","name":str?} (source channel: {"targeted":true} for one targeted colour/alpha, {"name":text} for a literal alpha name, {"color":text} for a colour component; source layer: {"name":text} for a literal layer name)"##,
|
||||
r##"{"source1":{"document","layer","channel","invert"},"source2":{…},"blending":"multiply|…"="multiply","opacity":0..100=100,"scale":1..2=1,"offset":-255..255=0,"mask":{…}?,"result":"newChannel|newDocument|selection"="newChannel","name":str?,"source1Document"?,"source1Layer"?,"source1Channel"?,"source1Invert"?,"source2Document"?,"source2Layer"?,"source2Channel"?,"source2Invert"?,"maskDocument"?,"maskLayer"?,"maskChannel"?,"maskInvert"?} (flat form of source1/source2/mask; source channel: {"targeted":true} for one targeted colour/alpha, {"name":text} for a literal alpha name, {"color":text} for a colour component; source layer: {"name":text} for a literal layer name)"##,
|
||||
has_doc,
|
||||
calculations
|
||||
),
|
||||
|
||||
@@ -7,9 +7,18 @@ use serde_json::Value;
|
||||
|
||||
use crate::{EngineError, Result};
|
||||
|
||||
/// Params whose documented range is the dialog's (the canvas) while the doc says commands may
|
||||
/// pass values outside it: Lens Flare's centre may sit off the canvas.
|
||||
const DIALOG_RANGES: &[(&str, &str)] = &[("filter.render.lensFlare", "centerX"), ("filter.render.lensFlare", "centerY")];
|
||||
/// Params whose documented range is the dialog's, while commands still accept values outside
|
||||
/// it and clamp or place them: Lens Flare's centre may sit off the canvas; Camera Raw
|
||||
/// exposure and Selective Color ink sliders clamp ATN or legacy values to the documented range.
|
||||
const DIALOG_RANGES: &[(&str, &str)] = &[
|
||||
("filter.render.lensFlare", "centerX"),
|
||||
("filter.render.lensFlare", "centerY"),
|
||||
("filter.cameraRaw", "exposure"),
|
||||
("image.adjustments.selectiveColor", "cyan"),
|
||||
("image.adjustments.selectiveColor", "magenta"),
|
||||
("image.adjustments.selectiveColor", "yellow"),
|
||||
("image.adjustments.selectiveColor", "black"),
|
||||
];
|
||||
|
||||
/// The commands whose values are checked against their schema: the pixel filters (the gallery
|
||||
/// filters have their own typed catalogue, checked in `gallery_cmds`) and the adjustments.
|
||||
|
||||
@@ -35,7 +35,8 @@ fn newly_created_layer_masks_follow_document_depth() {
|
||||
}
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
let history = s.active().unwrap().history.past_len();
|
||||
s.execute(command, json!({"color": "#000000"})).unwrap();
|
||||
let params = if command.starts_with("layer.newFillLayer") { json!({"color": "#000000"}) } else { json!({}) };
|
||||
s.execute(command, params).unwrap();
|
||||
let d = s.active().unwrap();
|
||||
let m = mask(&d.doc);
|
||||
assert_eq!(m.surface.format(), PixelFormat::new(ColorMode::Grayscale, sample, false), "{command}, {depth}-bit {mode}");
|
||||
@@ -127,7 +128,8 @@ fn mask_creation_preserves_selection_coverage_and_existing_masks() {
|
||||
})
|
||||
.unwrap();
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
s.execute(command, json!({"from": [0, 0], "to": [64, 48]})).unwrap();
|
||||
let params = if command == "gradient.fill.create" { json!({"from": [0, 0], "to": [64, 48]}) } else { json!({}) };
|
||||
s.execute(command, params).unwrap();
|
||||
let after = &s.active().unwrap().doc;
|
||||
let added = after.layer(s.active().unwrap().active_layer.unwrap()).unwrap().mask.as_ref().unwrap();
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user