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

align "┌ ─ ┐ │ └ ┘" #860

Open
bo-ku-ra opened this issue Feb 21, 2023 · 9 comments
Open

align "┌ ─ ┐ │ └ ┘" #860

bo-ku-ra opened this issue Feb 21, 2023 · 9 comments
Labels
good first issue Good for newcomers improvement Something can be better render

Comments

@gavin-ts
Copy link
Contributor

Is the issue that the double border stroked dash lines don't line up (due to the outer path being longer than the inner one?

Screen Shot 2023-02-20 at 7 05 39 PM

Is the idea to have it lined up more like this (but with equal lengths)?
Screen Shot 2023-02-20 at 7 09 06 PM

@bo-ku-ra
Copy link
Contributor Author

i think

best:
all corners must be "┌ ┐ └ ┘".

better:
the inner line is shorter than the outer line.
or
your solution.

@alixander
Copy link
Collaborator

i think we have to use border-image for this lol. https://developer.mozilla.org/en-US/docs/Web/CSS/border-image

i'll tag as low-priority because that's just how CSS is. but if someone wants to try it, be my guest

@alixander alixander added good first issue Good for newcomers render improvement Something can be better labels Feb 21, 2023
@Nepo26
Copy link

Nepo26 commented Jun 27, 2023

Hi, I want to tackle this issue so I start to understand the codebase. Is it ok?


Replicating the Issue

To simulate the issue can it be done just using the following code?

1 -> 2

classes: {
  dashed: {
    style: {
      stroke-dash: 5
    }
  }
}

1: {
  class: dashed
  3: {
    class: dashed

    5: {
      class: dashed
    }

    7: {
      class: dashed
    }

    5 -> 7
  }
}

2: {
  class: dashed

  4: {
    class: dashed

    6: {
      class: dashed
    }

    8: {
      class: dashed
    }

    6 -> 8
  }
}

https://play.d2lang.com/?l=&script=jJBLDoAgDET3c4q5gAtQPmHhafQUhrubFtBojOmCQMt05oHjtNID_TcLD5CStW_tTGrSKKS8eAqDNitkVcA1mZqVbgNyHtPPC22F2_k9Jqa6JYMmyEPSAPFfICCXH5JoSMkGTRSS3EnOAAAA__8%3D&layout=tala&

image

@alixander
Copy link
Collaborator

alixander commented Jun 27, 2023

@Nepo26 no, when it's parent-child, it's far apart enough that no one will notice. double-border is when it's noticeable:

https://play.d2lang.com/?script=qqhMS7NSqOZSUAAbqIcSblYKJUWlqXA5JJdYKRhx1XIBAgAA__8%3D&

@Nepo26
Copy link

Nepo26 commented Jun 27, 2023

Oh Okay. Makes sense then.

@bo-ku-ra
Copy link
Contributor Author

bo-ku-ra commented Jun 28, 2023

https://play.d2lang.com/?script=qoCCSghIgwErhWouBQWwJXooYWmlUFJUmgqXQ3KdlYKhgYKygoGenqEBVy0XIAAA__8%3D&

image

this is not a beauty like d2 works.

@Nepo26
Copy link

Nepo26 commented Jun 28, 2023

So hey. I looked more into this issue. And this is what I found and how I am trying to make it work.

My Thought Process

  • I looked more into border-image and it don't seem like the correct solution as it uses an image.
  • Tried to manually find the perfect ratio of stroke-dasharray and stroke-dashoffset, didn't get far. I was able to get a corner created if the offset was width / height but it only worked if the stroke-width was above 15 and it looked ugly.
  • Found out that they were introducing a new property called stroke-dashcorner that would be perfect. Seems like it's yet premature to be used.
  • Then I saw a twitter thread of someone in tldraw who just fixed a similar problem to ours. Looking at their source code I saw that instead of using a rect property they use grouped lines.

In the end what am I doing?

I'm trying to replicate the DashedOutlineBox and the getPerfectDashProps to allow us the to create better boxes.

@alixander
Copy link
Collaborator

@Nepo26 nice find!

indeed, tldraw's dash treatment is 👨‍🍳 👌 . steve is a legend.

Screen Shot 2023-06-28 at 1 51 46 PM

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 improvement Something can be better render
Projects
Status: No status
Development

No branches or pull requests

4 participants