-
Notifications
You must be signed in to change notification settings - Fork 521
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
d2renderer: #579 Circle Arrowhead #634
Conversation
what's the error? common issues: we're on go 1.18 |
I assume if I do the test data accept it goes away, just was not sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
(feel free to update the docs https://github.com/terrastruct/d2-docs/blame/master/docs/tour/connections.md#L135)
yep, because it has no expected, for new tests you'll want to run with that accept env variable. i'll add that flow to the CONTRIBUTING.md. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll need to run the tests with TESTDATA_ACCEPT and then check in the results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 thanks @Paracelsus-Rose
Particularly, I found a bit hard to follow some constants in d2svg
, not sure if we should change something in general so that we can include some ascii art about them. Most of them are just geometrical stuff for rendering, so having some drawings/examples could be useful in general.
Then, I believe this is related to offset
, I wonder why the circles aren't touching the shapes borders.
Finally, I believe it is worth changing some of the test cases to use other shapes, besides squares, just to see how the arrowheads are rendered
i think that's right, we don't want it touching the border, but I think we should leave like 1px of padding or something, right now I did notice it's a little too much. i'd be curious to see if no padding looks weird though or if i'm imagining it |
I was following the diamond's for render. Here I show what I was looking at locally. I see the crows feet and arrow both touch, the diamond was not and I was not sure. Having the circles touch looks a little strange, the padding I thought made more sense visually from a distance and zoomed in. This is them touching. Let me know which you prefer. |
This is how it currently stands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to look around and see what I can come up with. Have not worked with svg's prior to this. I see LineArrowhead is the only other one accounting for it hardcoded in, that and the offset on crows foot. Personally I liked the smallest gap thus far, and not touching the best, but it is not the same as everything else. Will play around and see. Just to make sure, you are saying that it is not pixel perfect on the edge connection there, due to not accounting for stroke width, correct? |
yes.
i do too, but maybe we'll like the third option best of perfectly touching (after accounting for stroke widths) |
You might want to check this PR for arrowhead overlaps 😂 It took me awhile to get it right (with the web app, d2, tala). What happens in that SVG borders grow in both directions ([in|out]ward) so you need to handle that when computing the overlap |
Still not right, and it feels so magic number-y now. I wrote out a TS script quick to check my numbers and that just made me even more confused. At least in regards to the cx. Will go back and attack it in a little bit. Svg's are interesting. Been good fun, apologize its been a crackpot job. |
About the diamond offset. I believe this is an issue as it should touch the shape. Consider the diagram below, where
The arrowhead adjustment I worked on was https://github.com/terrastruct/d2/blob/master/d2renderers/d2svg/d2svg.go#L300-L308 The idea is:
|
To expand on that, the end coordinate of the edge will be exactly on the border of the shape, but we need to move it back so the end of where the edge's stroke is rendered matches up to where the end of the shape's stroke is rendered. So if we have an edge ending at point
after moving down with the offset of 4:
|
@gavin-ts @ejulio-ts https://stackblitz.com/github/Paracelsus-Rose/svg-circles?file=src%2Fviews%2FSvgCircleView.vue https://github.com/Paracelsus-Rose/svg-circles Did not think it would become this when I was like, oh that looks easy :-). Cheers yall, its been fun. |
i haven't looked into your code, but there's a few likely offenders:
|
Appreciate the help @gavin-ts. This seems right now. Do apologize with the confusion. You were also correct, been thinking the last 3 days while I settled in at the new house about what @alixander said, how the SVG's are rendered from 0,0 in the top left. I knew when he said that I was trying to solve a problem on a false pretense. This should be corrected now, anything else which needs to be done let me know. Did not expect to get stuck on this, but wow did I learn a lot about SVG rendering. Yall inspired me to make some fun stuff in the last week. Cheers everyone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the test was added twice in a merge, other than that it looks good to go
e2etests/testdata/stable/circle_arrowhead#01/dagre/sketch.exp.svg
Outdated
Show resolved
Hide resolved
sweet, let's try to get this into the release |
Circles for arrowheads #579
./ci/test.sh Is failing. Not sure why, all else looks good.