Transparency: transparency.info reports the selected symbol part that transparency.set edits

With an object of a dynamic symbol instance selected by Direct Selection,
transparency.set without ids changes that object's opacity and blend mode
for the instance, and the Transparency panel shows those values. The
transparency.info command still reported the instance's own opacity and
blend mode. Without ids or id it now returns the panel's values
(Session::transparency_info), so it reports the part's opacity and blend
mode with the instance's isolate and knockout. With ids or id it still
reports those objects.
This commit is contained in:
dotCooCoo committed 2026-11-28 21:58:54 -08:00
1 parent 7a8866e036
commit ff47fc8699
3 files changed
+36 -6

No files matched your search

+11 -5
View File
@@ -105,7 +105,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Transparency Info",
[],
None,
"{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none); editingMask is the id of the object whose mask is being edited, or null; the page values are the document's",
"{id?|ids?} → {ids, opacity: 0..100, blend, isolate, knockout: \"on\"|\"off\"|\"neutral\", knockoutShape, editingMask, pageIsolatedBlending, pageKnockoutGroup} the Transparency panel's values for `ids`, the selection, or the object whose mask is being edited. A value is null where those objects differ (or there are none). Without ids or id, with an object of a dynamic symbol instance selected by Direct Selection, opacity and blend are that object's for this instance, as transparency.set changes them; editingMask is the id of the object whose mask is being edited, or null; the page values are the document's",
has_doc,
info
),
@@ -489,10 +489,16 @@ impl Session {
fn info(s: &mut Session, p: &Value) -> Result<Value> {
let st = s.doc()?;
let ids = transparency_targets(s, p)?;
// The points `transparency.set` with the same `ids` (or none) fades.
let points = if p.get("ids").is_none() && p.get("id").is_none() { s.mesh_points_picked() } else { super::paint::picked_mesh_points_of(s, &ids) };
let i = TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points);
// Without `ids` or `id`, the values `transparency.set` without them edits: those of the panel,
// whose picked mesh points and selected dynamic symbol part take the opacity (and the part the
// blend mode).
let i = if p.get("ids").is_none() && p.get("id").is_none() {
s.transparency_info()
} else {
let ids = transparency_targets(s, p)?;
let points = super::paint::picked_mesh_points_of(s, &ids);
TransparencyInfo::of(&st.doc, ids).with_mesh_points(&st.doc, points)
};
Ok(json!({
"ids": i.ids.iter().map(|id| id.0).collect::<Vec<_>>(),
"opacity": i.opacity,
@@ -1184,6 +1184,28 @@ fn opacity_and_blend_on_a_picked_object_go_through_transparency_set() {
assert!((node(&t, static_inst).opacity - 0.4).abs() < 1e-6);
}
#[test]
fn transparency_info_reports_the_picked_object_that_transparency_set_edits() {
let mut s = session();
let inst = pair(&mut s, "dynamic");
s.execute("transparency.set", &json!({"ids": [inst.0], "opacity": 75, "blend": "screen", "isolate": true, "knockout": "on"})).unwrap();
s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [1]})).unwrap();
s.execute("transparency.set", &json!({"opacity": 50, "blend": "multiply"})).unwrap();
let shown = |v: &Value| (v["ids"].clone(), v["opacity"].as_f64(), v["blend"].clone(), v["isolate"].clone(), v["knockout"].clone());
// Without ids, the picked object's opacity and blend mode, and the instance's isolate and knockout.
let info = s.execute("transparency.info", &json!({})).unwrap();
assert_eq!(shown(&info), (json!([inst.0]), Some(50.0), json!("Multiply"), json!(true), json!("on")));
let panel = s.transparency_info();
assert_eq!((panel.opacity, panel.blend.map(vectorcraft_color::BlendMode::label)), (Some(50.0), Some("Multiply")));
// The other object of the art draws as the symbol does.
s.execute("symbol.instance.selectPart", &json!({"id": inst.0, "path": [0]})).unwrap();
let info = s.execute("transparency.info", &json!({})).unwrap();
assert_eq!(shown(&info), (json!([inst.0]), Some(100.0), json!("Normal"), json!(true), json!("on")));
// With the instance's id, the instance itself, as transparency.set with that id edits it.
let info = s.execute("transparency.info", &json!({"id": inst.0})).unwrap();
assert_eq!(shown(&info), (json!([inst.0]), Some(75.0), json!("Screen"), json!(true), json!("on")));
}
#[test]
fn select_part_refuses_hidden_and_locked_objects_of_the_art() {
let mut s = session();
+3 -1
View File
@@ -5066,7 +5066,9 @@ already walks Image Trace. Short agent entry points:
`paint.setFill` and `paint.setStroke` (solid, none, gradient or pattern) and `paint.invert` and `paint.complement`
on a solid color change that object's fill or stroke for this instance only when `ids`, `id` and `item` are omitted.
`transparency.set` with opacity and/or blend does the same when `ids`, `id` and `item` are omitted; with `ids` or
`id` it edits those objects, so the instance's id changes the instance. `appearance.copyFrom` takes the source's
`id` it edits those objects, so the instance's id changes the instance. `transparency.info` without `ids` or `id`
reports that object's opacity and blend mode for this instance, with the instance's isolate and knockout values; with
the instance's id it reports the instance. `appearance.copyFrom` takes the source's
fill and stroke (including a gradient or pattern) for this instance only when `ids` is omitted and `reverse`,
`append` and `defaultsOnly` are false or omitted, and only for each paint the Eyedropper Options pick up and
apply; a paint disabled in either tree stays as it was. With `ids`, and `reverse` false or omitted, it copies