Svg.js: Implement rounding for nodes

Created on 18 Oct 2018  路  3Comments  路  Source: svgdotjs/svg.js

Sometimes svg.js produces unrounded values like x="2.999999999999" or similar which can take a bunch if space in your database when you save them. It also slows down the browser.

Thats why we want to introduce rounding of nodes.

As wout suggested this will work like the following examples:

var svg = path.round(2).svg()

Or non-destructively:

var clone = path.clone().round(3)
var svg = clone.svg()
clone.remove()

We can also provide deep rounding for elements inheriting from SVG.Parent. Something like:

nested.round(2, true)

Note: Implementation has to be done on the 3.0 branch
For all questions head over to our gitter chat: https://gitter.im/svgdotjs/svg.js

Hacktoberfest good first issue

Most helpful comment

I'll work on this

All 3 comments

I'll work on this

Feel free to jump on gitter if you need help with anything :)

This was implemented in the latest commit

Was this page helpful?
0 / 5 - 0 ratings