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

group padding is ignored when line is drawn to group's center #833

Open
lvgrr opened this issue Mar 9, 2025 · 2 comments
Open

group padding is ignored when line is drawn to group's center #833

lvgrr opened this issue Mar 9, 2025 · 2 comments
Assignees

Comments

@lvgrr
Copy link

lvgrr commented Mar 9, 2025

The following code draws a rectangle within a group with padding and a line to the group's center.

group({
    rect((0,0), (1,1))},
    name: "r",
    padding: .5cm,
)
line((-1,.5), "r")

The output is:

Image

Even though the border anchors with padding have been correctly computed, specifying the end coordinate for the line as the center of the group ignores its padding. Is this expected? I'd expect it to take padding into account, so the result would look like this:

Image

@johannes-wolf johannes-wolf self-assigned this Mar 9, 2025
@johannes-wolf
Copy link
Member

The line Element has a mode to use (path!) intersections if you pass element names. This is what happens here. I do not think padding should apply to intersections. Since groups have no border path, they do not cause intersections by themselves.
You could draw a hidden rect using hide(...) to simulate the group border. Or do you think that something should be changed/added here? Maybe an option?

@lvgrr
Copy link
Author

lvgrr commented Mar 9, 2025

I see, thanks for the explanation. I stand by my opinion that the line should end on the padding edge. That I think would be more consistent with the behaviour you get by referencing the group's border (i.e. in the example above r.north, r.east etc.), where the padding is indeed taken into account. But it's just my opinion, it'd be interesting to see what others think of this.

If anything this behaviour could be optional, depending on the value of a parameter of group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants