diagrams / diagrams-lib

Diagrams standard library
https://diagrams.github.io/
Other
138 stars 62 forks source link

arrowFromLocatedTrail doesn't do what the name seems to imply #320

Open robx opened 5 years ago

robx commented 5 years ago

If I ask for an arrow given a located trail, I'd expect the arrow to follow that trail. Instead, what seems to happen is that we take the located trail's shape, then append an arrowhead to the end, and then scale and rotate the whole arrow such that it starts at the intended start, and such that the tip of the arrow is at the original trail's end. That seems wrong.

In the example below, the arrows are drawn from located trails between centers of grid cells.

arrows-bug

What might help as a work-around is to shift the arrow-head back by its length, but I couldn't find a way to do that with the Arrows module.

byorgey commented 5 years ago

I agree this seems wrong, but it is tricky to figure out how to do "the right thing" in a way that works sensibly in all situations. Adjusting the end of the trail by the length of the arrowhead is relatively easy to do using Diagrams.Parametric.Adjust --- IF you know the length of the arrowhead. The problem is that arrowhead sizes can scale dynamically with the size of the diagram so it is impossible to know how big the arrowhead is going to be until late in the diagram compilation process. Still, at that point it should be possible to adjust the trail. But it is unclear what to do if (a) the trail is curved or (b) the arrowhead is longer than the final segment of the trail. Thoughts welcome!

robx commented 5 years ago

Don't think I know enough about the diagrams internals or the background of the arrow library design to have concrete input. Two ideas, though: