d2
d2 copied to clipboard
option to add bridges/arcs to crossings/intersections
can be a configuration for those who want it. should be relatively simple to add
@alixander Hello ! I am interested in this issue. If it's okay, can I solve it?
@H0onnn Yes certainly!
Some pointers:
- I would add
intersection-bridgeas a boolean tod2-configs: https://github.com/terrastruct/d2/blob/7269d3000feeb8745f3952edb2edea3048742590/d2compiler/compile.go#L1394 - Add a visual e2e test that has a crossing to https://github.com/terrastruct/d2/blob/master/e2etests/testdata/txtar.txt . Grid diagrams are one way to trigger it: https://play.d2lang.com/?script=Si_KTNFNzs8pzc0rtlIw4krkSuJK5krh4kpU0LVTSOFKBlFJXIAAAAD__w%3D%3D& . After you add this test, you can keep running
TA=1 ./ci/test.sh ./e2etests -run TestE2E/txtar/your-test-name -vto see changes and keep opening the new svg to see what it looks like. - When the diagram is being exported, add logic to add a
bridge: truefield to connections which should have a bridge rendered: https://github.com/terrastruct/d2/blob/master/d2exporter/export.go . Note that this function which detects intersections may be useful: https://github.com/terrastruct/d2/blob/7269d3000feeb8745f3952edb2edea3048742590/lib/geo/segment.go#L41 . - When you render connections, for those that have a
bridge: truefield, you'll want to actually draw the little bridge at the intersection. This will probably be the hardest part, since you'll have to calculate svg paths. https://github.com/terrastruct/d2/blob/7269d3000feeb8745f3952edb2edea3048742590/d2renderers/d2svg/d2svg.go#L497
Here to answer any questions as you go. If you decide you're no longer interested (no worries), just un-assign yourself.
A test with orthogonal edges: https://play.d2lang.com/?script=XMxBCoMwEIXh_TvFw6VgELopWfQu0YzOQKjFBESKdy9Nu8pq5n2Lf04hZ8meb5BqMcrz95MpTJI8u66uXM4kbnuF2crpOYK8cGHdLQ77dmTPGxBc7fl_CRPmRiKkkQVrIwprBL07LBb1vI_onYqtWurAxOFBRfyeBZ8AAAD__w%3D%3D&
Probably worth adding both to make sure the arc looks good both diagonally and orthogonally
Thank you for your kind response ! I will keep this in mind as I proceed with the work.
Hi @H0onnn just checking in to see if you're still pursuing this
@alixander Sorry, I'm not good at it :(
Hey @alixander , interested in working on this, added the test in txtar.txt which generated svg in testdata/txtar. Added the boolean value in Config and changed compileConfig. If its not urgent, can i work on this ?
@H0onnn No worries, thanks for trying!
@briheet Go for it!
i quite like just an empty gap too
I'm inclined to just make the empty gap the default. Will see what comes up
is here what happens when you show up with a big 'elk'.
https://play.d2lang.com/?script=hMnNqsIwEMXx_XmKofsMly4umIXvcmYaS7Gk4EdBQt5d1E1Rg7vf_5yVp3Pshl7WP_3XXScFIkMffMmHaYzPFJl5W66XkPI45RQlzUeIVFQALCAM_ggr27TNUwGqh70plU3y62ovWpP-QW_SfpFvNHXgHgAA__8%3D&layout=elk&
how about the idea of using opacity?