Skip to content

option to add bridges/arcs to crossings/intersections #1932

Closed

Description

@alixander

Screenshot 2024-05-03 at 9 15 45 AM

can be a configuration for those who want it. should be relatively simple to add

Activity

  1. changed the title [-]consider option to add bridges/arcs to crossings/intersections[/-] [+]option to add bridges/arcs to crossings/intersections[/+] on May 3, 2024
  2. H0onnn commented on May 6, 2024

    @H0onnn

    @alixander Hello ! I am interested in this issue. If it's okay, can I solve it?

  3. alixander commented on May 6, 2024

    @alixander
    CollaboratorAuthor

    @H0onnn Yes certainly!

    Some pointers:

    1. I would add intersection-bridge as a boolean to d2-configs: https://github.com/terrastruct/d2/blob/7269d3000feeb8745f3952edb2edea3048742590/d2compiler/compile.go#L1394
    2. 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 -v to see changes and keep opening the new svg to see what it looks like.
    3. When the diagram is being exported, add logic to add a bridge: true field 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 .
    4. When you render connections, for those that have a bridge: true field, 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.

  4. H0onnn commented on May 7, 2024

    @H0onnn

    Thank you for your kind response ! I will keep this in mind as I proceed with the work.

  5. alixander commented on May 23, 2024

    @alixander
    CollaboratorAuthor

    Hi @H0onnn just checking in to see if you're still pursuing this

  6. removed their assignment
    on May 27, 2024
  7. H0onnn commented on May 27, 2024

    @H0onnn

    @alixander Sorry, I'm not good at it :(

  8. briheet commented on May 27, 2024

    @briheet

    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 ?

  9. alixander commented on May 27, 2024

    @alixander
    CollaboratorAuthor

    @H0onnn No worries, thanks for trying!

    @briheet Go for it!

  10. removed their assignment
    on Jun 24, 2024
  11. alixander commented on Mar 27, 2025

    @alixander
    CollaboratorAuthor
    Image

    i quite like just an empty gap too

  12. alixander commented on Mar 28, 2025

    @alixander
    CollaboratorAuthor

    I'm inclined to just make the empty gap the default. Will see what comes up

  13. bo-ku-ra commented on Mar 29, 2025

    @bo-ku-ra
    Contributor

    how about the idea of using opacity?
    Image

    Image

  14. alixander commented on Nov 23, 2026

    @alixander
    CollaboratorAuthor

    We went with the empty gap discussed here. D2 now draws it by default, so existing diagrams get the crossing treatment when you render them again. This was merged in #3011 and will be in the next D2 release.

    At the red X in this SVG, the connection from g to a stays continuous. The connection from b to d has a small gap where they cross.

    D2 diagram showing a gap in the red connection from b to d where it crosses the continuous red connection from g to a.

    • sent from alixander's Codex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions