drawsvg
drawsvg copied to clipboard
Reduce coordinate precision from .as_svg()?
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
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.