I use Graphviz (mainly dot and fdp) to automatically generate some diagrams that I need. For these diagrams I need some special arrowheads that are not a part of the standard collection of arrows: A small black triangle inside a large white triangle, and the same with the black triangle pointing downwards.
What is the best way to add such arrowheads? I don't mind hacking the source code, if necessary. Where should I start?
You have to change to source code for that. Take a look at "lib/common/arrows.c". You will find that you have to:
In order to write your function take a look at arrow_type_normal(), it takes 6 parameters: job (you don't have to care about this, just use it like in this function), two points ('p' and 'u'), arrowsize, penwidth and flag. If you don't care about making different versions of your arrowhead, or if you wish to ignore the modifiers (inverted arrows and the like) ignore the flag parameter.
Then, the function basically takes the two points p and u (which are structures with 'x' and 'y' attributes in them) and combines them creating an array called a[] passed to gvrender_polygon() which will finally render your arrow shape. arrow_type_normal() also mess with the penwidth and arrowwidth.
Summarizing: prepare graphviz to accept your arrow name doing the first steps then create a function that will create the arrow shape and that will call gvrender_polygon or gvrender_polyline (if you wish).
I didn't try yet, but it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With