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

Fix transparency bounding box #181

Merged
merged 4 commits into from
Feb 1, 2025

Conversation

tonymarklove
Copy link
Contributor

The bounding box covering the transparency "graphics state" should now match the bounding box of the SVG element it is applied to. We also need to add the width of the stroke, since this isn't normally covered by the bounding box.

I was trying to be conservative previously by using prawn.state.page.dimensions to bound the whole page, but this doesn't always work. If the SVG has been scaled the page dimensions my only cover some of the coordinate space covered by the SVG.

Hopefully this is now correct. Prawn is a little bit inconsistent with how it handles bounding boxes and margins compared to other transformations. I had to use prawn.bounds.anchor to get the bounding box offset. So hopefully I'm not missing any other subtleties.

@mogest mogest merged commit 35fe01b into mogest:main Feb 1, 2025
6 checks passed
@mogest
Copy link
Owner

mogest commented Feb 1, 2025

Thanks again @tonymarklove, a pleasure to read your code as always!

mogest added a commit that referenced this pull request Feb 1, 2025
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

Successfully merging this pull request may close these issues.

2 participants