varkor / quiver

A modern commutative diagram editor for the web.
https://q.uiver.app
MIT License
2.37k stars 78 forks source link

Difference in rendering of arrows in Tikz and Quiver #111

Open pbustillo05 opened 2 years ago

pbustillo05 commented 2 years ago

I tried to dig into the PGF/TikZ and the tikz-cd manuals today to understand how the curves of the arrows are computed there. I noticed several disparities with what quiver seems to be doing. I say "seems to be doing" because I'm not completely sure of how the algorithm of quiver works. I looked at the source code a bit (but I don't really read JavaScript) and I played around with the software to understand its behavior, so it's a lot of guess work. Essentially the differences come down to this:

I suppose it's similar when the ending/starting points of the arrows are labels of other arrows, rather than cells (although I didn't explore this situation). Of course this is a lot of guess work so correct me if I'm mistaken. The difference of rendering between tikz-cd and quiver is only slightly noticable with straight arrows. However, with bended arrows the difference is very noticable. Is there a way to correct the differences above?

(also just out of curiosity, as I digged into the ways arrows are bended and rendered, I wondered: what's the reason behind using the "curve" key for fixed heights bending of arrows, rather than using the more common "bend right" and "bend left" keys?)

varkor commented 2 years ago

Thank you for this analysis: I have been aware that there are differences in how the positions and bouncing boxes were calculated, but did not dig into precisely what they were, so this is helpful. I personally think the diagrams in quiver are more aesthetic in this regard, so I would prefer to instead output modified TiKZ that matches the quiver diagrams, rather than modify quiver to look more like the default TikZ styles. But as I am not an expert with TikZ, it will take some time to figure out how to do this effectively.

(also just out of curiosity, as I digged into the ways arrows are bended and rendered, I wondered: what's the reason behind using the "curve" key for fixed heights bending of arrows, rather than using the more common "bend right" and "bend left" keys?)

The bend commands are very inflexible, and just allow you to specify an angle. It can be difficult to predict what the result will look like without rendering it, and often the most aesthetic curves are not possible this way. I find that curve (i.e. specifying a height, rather than an angle) is much more natural, and makes it easy to produce the correct TikZ code from quiver.

pbustillo05 commented 2 years ago

I agree that quiver often looks better! It's not a matter of correcting quiver to make it look like TikZ (or the opposite), but probably a matter of choosing each time the best option (and modifying the other).

For example, I think TikZ-CD idea of offsetting the center of the box by the "math axis height" is very cool. Their boxes look nicer in my opinion, except that rounded corners make more sense. So this could be a matter of rounding the corners of the "asymmetrical rectangle" shape, and matching it on quiver.

But for paths, in general the idea of quiver is more aesthetically pleasing. I'll try to think more about how the TikZ code can be modified to have better looking arrows.