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 bounding box/border anchors should be effected by rotation #488

Open
fenjalien opened this issue Feb 8, 2024 · 6 comments · May be fixed by #490
Open

Group bounding box/border anchors should be effected by rotation #488

fenjalien opened this issue Feb 8, 2024 · 6 comments · May be fixed by #490
Labels

Comments

@fenjalien
Copy link
Member

In the example I would expect the red circle to cover the blue one

rotate(45deg)
group({
  rect((0, 0), (1, 1), name: "rect")
  circle("rect.west", radius: 0.1, fill: blue)
}, name: "group")
circle("group.west", radius: 0.1, fill: red)

image

@johannes-wolf
Copy link
Member

johannes-wolf commented Feb 8, 2024

The bbox of groups is currently axis aligned, which is intended.
If we support rotated group bboxes, this has to be toggleable as a flag, because getting an axis aligned bbox is very useful.

As soon as nested anchors are merged, this example would be possible by using the rect instead of the group for anchor placement (#389).

EDIT: I think I got this wrong. Yes, if the transformation is outsides the group, its anchors should get transformed by that.

@johannes-wolf
Copy link
Member

johannes-wolf commented Feb 10, 2024

How should this work for groups containing elements with different z coordinates?
If we do not “flatten” the bounding box to an aabb, we can not correctly generate bounding boxes for such groups.

Second problem are groups with content(..) insides them. Content is not affected by transformations.

@johannes-wolf
Copy link
Member

Example with content:
grafik

The cleanest solution would be to implement setting a transformation matrix in Typst and transforming text like any other element.

@johannes-wolf johannes-wolf linked a pull request Feb 10, 2024 that will close this issue
@fenjalien
Copy link
Member Author

Hmm, I would rather not be transforming content until we get better control from Typst, otherwise it feels just to brittle and difficult to keep working.

My current work around is to hide a rectangle then copy its anchors, which works but does mean I have to calculate the bounds before hand and angle/path anchors don't work as expected. What might be an easier solution would be to allow completely overriding the anchors of a group.

The bounds anchors would be kept as default but it would require exposing anchor.setup in some form...

@johannes-wolf
Copy link
Member

All we need from Typst is it allowing to set a transformation matrix. Internally, it should use them already, so the missing part is a function to set one. Maybe we can make a PR for Typst implementing such function?

@johannes-wolf
Copy link
Member

My current work around is to hide a rectangle then copy its anchors, which works but does mean I have to calculate the bounds before hand and angle/path anchors don't work as expected. What might be an easier solution would be to allow completely overriding the anchors of a group.

What do you mean with allowing to override anchors of groups? Isn't that possible?

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

Successfully merging a pull request may close this issue.

2 participants