Jump to content
Search Community

SVG path function

benoit test
Moderator Tag

Recommended Posts

Sure, you could use MorphSVGPlugin's stringToRawPath() method to convert a path data string into a RawPath (which is always cubic bezier based) and rawPathToString() to convert that back into a path data string. Like:

var pathData = "M0,0 C10,20,15,30,5,18 M0,100 C50,120,80,110,100,100"; // any valid path data, not limited to cubic beziers
var rawPath = MorphSVGPlugin.stringToRawPath(pathData);
var cubicPathData = MorphSVGPlugin.rawPathToString(rawPath); 

Is that what you're looking for? 

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

@benoit GSAP doesn't have anything like that built in. 

 

Tools like SVGOMG have this feature as part of their minification process (it's called "Round/rewrite numbers" on there). You should be using something like SVGOMG to reduce the file size of your SVGs anyway.

 

Alternatively you could use regex to truncate the numbers or regex + JS to round them quite easily.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...