Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alixander opened this issue May 3, 2024 · 8 comments
Open

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

alixander opened this issue May 3, 2024 · 8 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@alixander
Copy link
Collaborator

Screenshot 2024-05-03 at 9 15 45 AM

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

@alixander alixander added the good first issue Good for newcomers label May 3, 2024
@alixander alixander changed the title consider option to add bridges/arcs to crossings/intersections option to add bridges/arcs to crossings/intersections May 3, 2024
@H0onnn
Copy link

H0onnn commented May 6, 2024

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

@alixander
Copy link
Collaborator Author

@H0onnn Yes certainly!

Some pointers:

  1. I would add intersection-bridge as a boolean to d2-configs:
    func compileConfig(ir *d2ir.Map) (*d2target.Config, error) {
  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:
    func (segment Segment) Intersects(otherSegment Segment) bool {
    .
  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.
    func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Connection, markers map[string]struct{}, idToShape map[string]d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, _ error) {

Here to answer any questions as you go. If you decide you're no longer interested (no worries), just un-assign yourself.

@alixander
Copy link
Collaborator Author

@H0onnn
Copy link

H0onnn commented May 7, 2024

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

@alixander
Copy link
Collaborator Author

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

@H0onnn H0onnn removed their assignment May 27, 2024
@H0onnn
Copy link

H0onnn commented May 27, 2024

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

@briheet
Copy link

briheet commented May 27, 2024

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 ?

@alixander
Copy link
Collaborator Author

@H0onnn No worries, thanks for trying!

@briheet Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

3 participants