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

Reduce coordinate precision from .as_svg()? #107

Open
tristanryerparke opened this issue Sep 28, 2023 · 1 comment
Open

Reduce coordinate precision from .as_svg()? #107

tristanryerparke opened this issue Sep 28, 2023 · 1 comment

Comments

@tristanryerparke
Copy link

When saving my svgs made with drawsvg using the as_svg()

I get output like this:
stroke="rgb(109,55,49)" stroke-width="2.0" stroke-linecap="round" fill="none" />\n<path d="M180.21339416503906,245.65103149414062 Q179.613037109375,224.4796600341797,182.30447387695312,204.12168884277344"

Is there a way to decrease the precision upon export so that I have only two or three numbers after the decimal point?
I'm trying to save some file size and this seems over the top in terms of precision for the human eye.
Best,
T

@cduck
Copy link
Owner

cduck commented Sep 29, 2023

Hi @tristanryerparke. There is currently no built in way to reduce the precision of numbers in the generated SVG other than rounding them yourself. For example: path.M(round(x, 2), round(y, 2)).

If you are interested in contributing to drawsvg, I would definitely welcome a pull request that does this automatically. The way I might do it is by adding a precision attribute to Context so Path and any other types can adjust their generated output.

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