effect.add.anchor without params goes on the content

Null params left the target unset, so the anchor landed in the mask.
This commit is contained in:
Rafael Mendes committed 2026-11-10 18:32:29 -03:00
1 parent 10aaae2f51
commit 26d82b429c
2 files changed
+7 -8

No files matched your search

+4 -7
View File
@@ -378,13 +378,10 @@ fn size_weights(command: &str, value: &Value) -> Result<[f32; CurvatureDetail::S
/// An anchor point on the layer content (the default, as before anchors went on masks) or, with
/// `target: "mask"`, in its mask.
fn add_anchor(s: &mut Session, p: &Value) -> Result<Value> {
let mut params = p.clone();
if p.get("target").is_none()
&& let Some(o) = params.as_object_mut()
{
o.insert("target".into(), json!("content"));
}
push_effect(s, &params, EffectKind::Anchor, BlendMode::Normal)
// Params may be null or an object without a target: both default to the content.
let mut params = p.as_object().cloned().unwrap_or_default();
params.entry("target").or_insert_with(|| json!("content"));
push_effect(s, &Value::Object(params), EffectKind::Anchor, BlendMode::Normal)
}
/// A generator's micro detail from `microAnchor` / `microAmount` for a generator on layer
+3 -1
View File
@@ -106,9 +106,11 @@ fn anchor_points_in_masks_record_the_mask_for_layers_above() {
let layer = s.doc.project.layer(LayerId(low)).unwrap();
assert!(layer.mask.as_ref().unwrap().effects.iter().any(|e| e.id.0 == anchor), "in the mask");
assert!(layer.content_effects.is_empty(), "not on the content");
// Without a target it still goes on the content, as before.
// Without a target (or with no params at all) it still goes on the content, as before.
let content = id(execute(&mut s, "effect.add.anchor", &json!({"layer": low})).unwrap(), "effect");
assert!(s.doc.project.layer(LayerId(low)).unwrap().content_effects.iter().any(|e| e.id.0 == content));
let bare = id(execute(&mut s, "effect.add.anchor", &Value::Null).unwrap(), "effect");
assert!(s.doc.project.layer(LayerId(low)).unwrap().content_effects.iter().any(|e| e.id.0 == bare));
// Folders take anchors in their masks only.
let folder = id(execute(&mut s, "layer.add.group", &Value::Null).unwrap(), "layer");