Tuesday, December 15, 2015

Script to Reduce SVG Size by Rounding Decimal Points

Here is a small script, which rounds the decimal points for each path in a svg image:

function round(toRound, points) {
    return toRound.replace(/[ ][d][=]["']{1}((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']{1}/g, function(m){
        return m.replace(/[\d]*\.[\d]*/g, function(n){
            return +parseFloat(n).toFixed(points)
        });
    });
}


Try It:

Just copy the xml source of your svg image into the "Source" field, and click the "Round"-Button:

(394 Characters)


(0 Characters, 0% saved)

You will find the code of this example here: jsfiddle.net/aLhm2s2z/

2 comments:

  1. Casino Finder (Google Play) Reviews & Demos - Go
    Check Casino Finder (Google air jordan 18 retro men blue store Play). A 온라인 포커 look at air jordan 18 stockx online some of the best best jordan 18 white royal blue gambling sites in the world. They offer air jordan 18 retro varsity red online a full game library,

    ReplyDelete