mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-02 14:16:56 -06:00
Fix #4938: Dynamic symbols keep per-instance appearance linked to the symbol
This commit is contained in:
@@ -217,7 +217,7 @@ impl Exporter<'_> {
|
||||
let total = sym.map_or(0, |sym| self.symbol_nodes.saturating_add(sym.art.count() as u64));
|
||||
if let Some(sym) = sym.filter(|_| total <= vectorcraft_doc::MAX_SYMBOL_NODES) {
|
||||
self.symbol_nodes = total;
|
||||
let mut art = (*sym.art).clone();
|
||||
let mut art = vectorcraft_doc::symbol_overrides::dynamic_art(&sym.art, n);
|
||||
art.transform(*xf, false);
|
||||
self.node(s, &art, page, true);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ fn an_instance_whose_art_reaches_the_page_is_written() {
|
||||
// the 20 × 20 square around the origin, moved to (-60, -60) to (-40, -40), is off it.
|
||||
let mut d = doc(200.0, 100.0);
|
||||
let red = rect_node(Rect::new(100.0, 50.0, 140.0, 90.0), Color::rgb(1.0, 0.0, 0.0));
|
||||
let far = vectorcraft_doc::Symbol { name: "Far".into(), art: Arc::new(red) };
|
||||
let far = vectorcraft_doc::Symbol { dynamic: false, name: "Far".into(), art: Arc::new(red) };
|
||||
d.symbols.push(far.clone());
|
||||
let instance = Node::new(NodeId(0), NodeKind::SymbolInstance { symbol: "Far".into(), xf: Affine::translate((-50.0, -50.0)) });
|
||||
add(&mut d, instance.clone());
|
||||
@@ -228,7 +228,7 @@ fn an_instance_whose_brush_art_reaches_the_page_is_written() {
|
||||
let mut stroke = Appearance::basic(Paint::None, Paint::solid(Color::BLACK), 1.0);
|
||||
stroke.stroke_mut().unwrap().brush = Some("3 pt. Round".into());
|
||||
let line = Node::path(NodeId(0), shapes::line((0.0, 40.0).into(), (0.0, 60.0).into()), stroke);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { name: "Nib".into(), art: Arc::new(line) });
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Nib".into(), art: Arc::new(line) });
|
||||
add(&mut d, Node::new(NodeId(0), NodeKind::SymbolInstance { symbol: "Nib".into(), xf: Affine::translate((-5.0, 0.0)) }));
|
||||
let out = roundtrip(&d);
|
||||
let l = leaves(&out);
|
||||
|
||||
@@ -265,7 +265,7 @@ fn a_symbol_instance_prints_by_its_art() {
|
||||
let mut d = doc(100.0, 100.0, &[]);
|
||||
let red = Appearance::basic(rgb(1.0, 0.0, 0.0), Paint::None, 0.0);
|
||||
let art = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(100.0, 100.0, 140.0, 140.0)), red);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { name: "Far".into(), art: Arc::new(art) });
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Far".into(), art: Arc::new(art) });
|
||||
let (layer, id) = (d.default_layer().unwrap(), d.alloc_id());
|
||||
let xf = vectorcraft_geom::Affine::translate((-50.0, -50.0));
|
||||
d.insert(Some(layer), 0, Node::new(id, NodeKind::SymbolInstance { symbol: "Far".into(), xf })).unwrap();
|
||||
@@ -293,7 +293,7 @@ fn a_symbol_instances_brush_art_keeps_its_artboard_printed() {
|
||||
let mut stroke = Appearance::basic(Paint::None, rgb(1.0, 0.0, 0.0), 1.0);
|
||||
stroke.stroke_mut().unwrap().brush = Some("3 pt. Round".into());
|
||||
let art = Node::path(d.alloc_id(), shapes::line((0.0, 40.0).into(), (0.0, 60.0).into()), stroke);
|
||||
d.symbols.push(vectorcraft_doc::Symbol { name: "Nib".into(), art: Arc::new(art) });
|
||||
d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Nib".into(), art: Arc::new(art) });
|
||||
let (layer, id) = (d.default_layer().unwrap(), d.alloc_id());
|
||||
let xf = vectorcraft_geom::Affine::translate((-5.0, 0.0));
|
||||
d.insert(Some(layer), 0, Node::new(id, NodeKind::SymbolInstance { symbol: "Nib".into(), xf })).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user