Jollywatt / typst-fletcher

Typst package for drawing diagrams with arrows, built on top of CeTZ.
MIT License
270 stars 6 forks source link

Feature Request: Anchor destinations for edges connecting nodes. #21

Open kdog3682 opened 3 months ago

kdog3682 commented 3 months ago

It would be really nice to have a way to specify where (with regard to a node) an arrow should point at.

Sample Code:

#diagram({
   node((0,0), [hi])
   edge(from: "north", to: "south-west") // coming from the north of the previous node and pointing to the southwest of the destination node.
   node((3, 3), [hi]) 

})
Jollywatt commented 3 months ago

Does something like the following do what you mean?

#import "@preview/fletcher:0.4.3": diagram, node, edge

#diagram({
  node((0,0), [start])
  edge("n,e,sssss,e,ne") // line goes [n]orth from previous node, then east, south 5 units, east, then north-east into the next node
  node((3,3), [end])
})

You have to describe the exact path yourself, though.