Skip to content

Minimal viewBox for SVG exports#69

Open
fkettelhoit wants to merge 4 commits into
hundredrabbits:masterfrom
fkettelhoit:minimal-viewbox
Open

Minimal viewBox for SVG exports#69
fkettelhoit wants to merge 4 commits into
hundredrabbits:masterfrom
fkettelhoit:minimal-viewbox

Conversation

@fkettelhoit

Copy link
Copy Markdown

When I export to svg, I usually want the file to have the same dimensions as the content, without any empty space around it. Right now this is only possible by manually editing the .svg output and adding a viewBox attribute, which requires calculating the minimal x and y values as well as the width and height of the content while taking into account the line thickness. The whole process can be quite time-consuming and error-prone for larger files.

The PR automatically calculates and saves the viewBox and tries to make sure that the resulting svg fits into these bounds. In the case of round or beveled line joins this is quite easy, but in the case of miter line joins (which could theoretically overshoot the angle point by quite a large amount in the case of sharp angles) an offset equivalent to the line thickness is used (which should give an acceptable result in most cases).

@Ledmington

Copy link
Copy Markdown

Any updates on this?

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