mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-23 19:04:25 +01:00
Symbols: a part's outline leaves out hidden art of instances nested in it
The outline of a dynamic instance's part walked the art of an instance nested in the part, drawn with that instance's fill and stroke effects, and outlined its hidden objects as well. It now skips a hidden object and what it holds, as the part pick does.
This commit is contained in:
1 parent
05d5befece
commit
d54cbce778
2 files changed
+28
-2
No files matched your search
@@ -2231,10 +2231,10 @@ fn limit_within(clip: &Node, limit: Option<Rect>, outline: bool) -> Option<Optio
|
||||
/// stroke effects reshape its art as that art drawn with them ([`InstanceArt::drawn`]), as
|
||||
/// [`FindPart`] tests them, except with `outline` and while a [`DrawnOff`] guard lives. Each object
|
||||
/// visited takes one object of the [`ArtWalk`] limit, and nothing more is outlined once the limit
|
||||
/// is used up.
|
||||
/// is used up. A hidden object and what it holds are not outlined, as [`FindPart`] passes over them.
|
||||
fn outline_within(n: &Node, symbols: &SymbolBoxes, limit: Option<Rect>, outline: bool, out: &mut BezPath) {
|
||||
use vectorcraft_geom::kurbo::Shape;
|
||||
if !ArtWalk::take(1) {
|
||||
if !n.visible || !ArtWalk::take(1) {
|
||||
return;
|
||||
}
|
||||
if matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. })
|
||||
|
||||
@@ -3128,6 +3128,32 @@ fn a_part_pick_walks_nested_reshaped_symbol_instances_within_one_limit() {
|
||||
assert_eq!(with_art_limit(300, || symbol_part_at(&d, n, Point::new(2.0, 2.0), opt)).0, Some(vec![29]), "the clipped art");
|
||||
}
|
||||
|
||||
/// The outline of a part of a dynamic symbol's instance leaves out the hidden objects in the art of
|
||||
/// an instance nested in the part whose fill's effects reshape it, as a part pick passes over them.
|
||||
#[test]
|
||||
fn a_parts_outline_leaves_out_hidden_art_of_nested_reshaped_symbol_instances() {
|
||||
use vectorcraft_geom::kurbo::Shape;
|
||||
set_image_paint(painted_far_away);
|
||||
set_instance_reshapes(reshapes_when_painted);
|
||||
let mut d = Document::new(600.0, 400.0);
|
||||
let l = d.layers[0].id;
|
||||
let shown = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(0.0, 0.0, 1.0, 1.0)), Appearance::default_art());
|
||||
let mut hidden = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(50.0, 50.0, 60.0, 60.0)), Appearance::default_art());
|
||||
hidden.visible = false;
|
||||
group_symbol(&mut d, "Painted hidden", vec![Arc::new(shown), Arc::new(hidden)]);
|
||||
let member = painted_instance_of(&mut d, "Painted hidden");
|
||||
group_symbol(&mut d, "Hides", vec![member]);
|
||||
let inst = instance_of(&mut d, "Hides");
|
||||
let id = inst.id;
|
||||
d.insert(Some(l), 0, Arc::unwrap_or_clone(inst)).unwrap();
|
||||
let n = d.node(id).unwrap();
|
||||
assert_eq!(symbol_part_at(&d, n, Point::new(55.0, 55.0), HitOptions::default()), None, "the hidden square is not picked");
|
||||
let outline = symbol_part_outline(&d, n, &[0]).unwrap();
|
||||
let squares = outline.elements().iter().filter(|e| matches!(e, vectorcraft_geom::kurbo::PathEl::MoveTo(_))).count();
|
||||
assert_eq!(squares, 1, "only the shown square is outlined");
|
||||
assert!(outline.bounding_box().x1 <= 1.0, "the outline reaches {:?}", outline.bounding_box());
|
||||
}
|
||||
|
||||
/// In a dynamic symbol's art that placing through its 9-slice guides could make more than
|
||||
/// [`crate::MAX_SYMBOL_NODES`] objects of, Direct Selection picks and outlines nothing, as the
|
||||
/// canvas draws nothing of it. At the art's natural size the same art is picked.
|
||||
|
||||
Reference in new issue
Block a user