diagrams-lib ought to have a module with some convenient functions for creating arrows pointing from one part of a diagram to another. This page is for gathering ideas and plans for such a module.
There should probably be a collection of "standard" arrowheads for the user to choose from. In addition it ought to be possible for the user to specify any diagram they like for use as an arrowhead.
The idea is for arrowheads to be scale-invariant, just like line width. We now have a
ScaleInv wrapper for accomplishing this, which works correctly with freezing etc.
2 Drawing arrows
At the most basic level one could imagine an API like
arrow :: Arrowhead -> P2 -> P2 -> Diagram
and we probably should indeed have such a function, but we'll need to also generalize along several axes.
First, the most frequent use case will be drawing an arrow on top of an existing diagram in order to connect two points. So we want something like
arrow :: IsName n => Arrowhead -> n -> n -> (Diagram -> Diagram)
which draws an arrow between the named points on the given diagram. There are several ways this can be generalized:
- Instead of drawing an arrow between the named points one could draw the arrow between the named subdiagrams (using their traces to find the edges).
- There should also be a way to leave gaps, i.e. don't draw the arrow precisely from point to point or edge to edge, but leave a gap of a certain absolute size or a certain percentage of the arrow length on either end of the arrow.
Re: leaving gaps, this will require some generic code to shrink paths. There is already some code to shrink/extend individual segments (and compute the length of segments) in Diagrams.Segment. This would need to be extended to shrinking/extending trails and paths appropriately.
One might also want to have control over the middle of the arrow -- i.e. whether it curves, and if so how much and in which direction, etc.