(Initial notes on arrows (still need to finish))
Revision as of 03:36, 13 December 2012
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. We'll need to make a new type of
Prim for holding
ScaleInv things (note it will need to handle freezing correctly; haven't thought too hard about that yet...).
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 individual segments (and compute the length of segments) XXX finish me
One might also want to have control over the middle of the arrow XXX finish me